[#222] test: 파서 property 기반 테스트 도입 (+ CR 공백 처리 1줄) #369
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test & Coverage | |
| on: | |
| pull_request: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check: | |
| name: Rust project | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Cache Cargo's directories | |
| uses: actions/cache@v4 | |
| with: | |
| save-always: true | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| ./target | |
| - name: Cache cargo-tarpaulin | |
| id: cache-tarpaulin | |
| uses: actions/cache@v4 | |
| with: | |
| key: ${{ runner.os }}-tarpaulin-v0.30 | |
| path: ~/.cargo/bin/cargo-tarpaulin | |
| - name: Install cargo-tarpaulin | |
| if: steps.cache-tarpaulin.outputs.cache-hit != 'true' | |
| # `--force` because the two cache steps above overlap: the Cargo | |
| # directory cache restores all of `~/.cargo/bin/` (which contains | |
| # cargo-tarpaulin) via `restore-keys`, while this step's own cache | |
| # needs an exact key match. When that key has been evicted but the | |
| # directory cache still hit, the binary is already present and a | |
| # plain `cargo install` aborts with | |
| # `error: binary \`cargo-tarpaulin\` already exists in destination`. | |
| run: cargo install cargo-tarpaulin --locked --force | |
| - name: Run cargo-tarpaulin | |
| run: | | |
| cargo tarpaulin -l --out Html | tail -n 1 | grep -o '[^+][0-9]\+\.[0-9]\+%' > coverage_total_percent.txt | |
| - name: Set coverage env variable | |
| run: | | |
| echo "COVERAGE=$(head -n 1 coverage_total_percent.txt)" >> $GITHUB_ENV | |
| - name: Check token availability | |
| id: token_check | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| run: | | |
| if [ -n "$GH_TOKEN" ]; then | |
| echo "has_token=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_token=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Clone html_reports repository | |
| if: steps.token_check.outputs.has_token == 'true' | |
| run: | | |
| git clone https://github.com/myyrakle/html_reports | |
| - name: Generate Random Name | |
| if: steps.token_check.outputs.has_token == 'true' | |
| run: | | |
| echo "REPORT_NAME=$(date +%s)" >> $GITHUB_ENV | |
| - name: Copy coverage report | |
| if: steps.token_check.outputs.has_token == 'true' | |
| run: | | |
| cp ./tarpaulin-report.html ./html_reports/${{ env.REPORT_NAME }}.html | | |
| cd ./html_reports | |
| - name: Add | |
| if: steps.token_check.outputs.has_token == 'true' | |
| working-directory: html_reports | |
| run: | | |
| git add . | |
| - name: Commit | |
| if: steps.token_check.outputs.has_token == 'true' | |
| working-directory: html_reports | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" && | |
| git config --global user.name "github-actions[bot]" && | |
| git commit -m "Add report" | |
| - name: Push changes | |
| if: steps.token_check.outputs.has_token == 'true' | |
| uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # v0.8.0 | |
| with: | |
| github_token: ${{ secrets.GH_TOKEN }} | |
| directory: html_reports | |
| repository: myyrakle/html_reports | |
| - name: Add comment to PR | |
| if: steps.token_check.outputs.has_token == 'true' | |
| uses: thollander/actions-comment-pull-request@v1 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
| message: | | |
| ✅ **Total Coverage**: ${{ env.COVERAGE }} | |
| ${{ steps.token_check.outputs.has_token == 'true' && format('🔗 [Coverage View](https://myyrakle.github.io/html_reports/{0}) <sub>(최대 몇분 정도의 지연시간이 발생할 수 있습니다.)</sub>', env.REPORT_NAME) || '<sub>(fork PR: coverage HTML upload skipped)</sub>' }} | |
| - name: Coverage summary (fork PR fallback) | |
| if: steps.token_check.outputs.has_token != 'true' | |
| run: | | |
| echo "::notice::Total Coverage: ${{ env.COVERAGE }} (fork PR: coverage HTML upload and PR comment skipped)" |