From c612fbd529c518a7d2c5d0f4db465fae264e1277 Mon Sep 17 00:00:00 2001 From: myyrakle Date: Sun, 30 Jun 2024 01:54:53 +0900 Subject: [PATCH] =?UTF-8?q?[#99]=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BB=A4?= =?UTF-8?q?=EB=B2=84=EB=A6=AC=EC=A7=80=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/coverage.yml | 96 ++++++++++++++++++++++++++++++++++ .gitignore | 4 +- coverage_total_percent.txt | 1 + 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml create mode 100644 coverage_total_percent.txt diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..1b1c940e --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,96 @@ +name: Test & Coverage + +on: + pull_request: + +permissions: # Job-level permissions configuration starts here + contents: write # 'write' access to repository contents + pull-requests: write # 'write' access to pull requests + +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 }}-coverage-${{ hashFiles('Cargo.lock') }} + path: | + ./target + ~/.cargo + ~/.cargo/registry + ~/.cargo/git + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + + - name: Install cargo-tarpaulin + run: cargo install cargo-tarpaulin + + - 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=$(cat coverage_total_percent.txt)" >> $GITHUB_ENV + + - name: Clone html_reports repository + run: | + git clone https://github.com/myyrakle/html_reports + + - name: Generate Random Name + run: | + echo "REPORT_NAME=$(date +%s)" >> $GITHUB_ENV + + - name: Copy coverage report + run: | + cp ./tarpaulin-report.html ./html_reports/${{ env.REPORT_NAME }}.html | + cd ./html_reports + + - name: Add + working-directory: html_reports + run: | + git add . + + - name: ls + working-directory: html_reports + run: | + ls -lah + + - name: Commit + working-directory: html_reports + run: | + git config user.email "sssang97@naver.com" | + git config user.name "myyrakle" | + git commit -m "Add report" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GH_TOKEN }} + directory: html_reports + repository: myyrakle/html_reports + force: true + ref: master + + - name: Add comment to PR + uses: thollander/actions-comment-pull-request@v1 + with: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + message: | + βœ… **Total Coverage**: ${{ env.COVERAGE }} | + [πŸ”— Coverage View](https://myyrakle.github.io/html_reports/${{ env.REPORT_NAME }}) + | (Coverage View νŽ˜μ΄μ§€ λ‘œλ“œμ—λŠ” μ΅œλŒ€ λͺ‡λΆ„ μ •λ„μ˜ μ§€μ—°μ‹œκ°„μ΄ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.) \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2370ccbb..4151c3fb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,6 @@ Cargo.lock .rrdb.config -.vscode \ No newline at end of file +.vscode + +tarpaulin-report.html \ No newline at end of file diff --git a/coverage_total_percent.txt b/coverage_total_percent.txt new file mode 100644 index 00000000..10348530 --- /dev/null +++ b/coverage_total_percent.txt @@ -0,0 +1 @@ +38.20%