From 5ea9ba29acb934e96b06d07c5552ebaf315091bf 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 | 57 ++++++++++++++++++++++++++++++++++ .gitignore | 4 ++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..7080954f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,57 @@ +name: Test & Coverage + +on: + pull_request: + +jobs: + check: + name: Rust project + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Cache Cargo's directories + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + path: | + ./target + ~/.cargo + + - 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_pecent.txt | + AVG_COVERAGE=$(cat coverage_total_pecent.txt) | + echo "COVERAGE=$AVG_COVERAGE" >> $GITHUB_ENV + + - name: Checkout report repository + uses: actions/checkout@v2 + with: + repository: myyrakle/html_reports + token: ${{ secrets.REPORTS_GH_TOKEN }} + path: ./html_reports + + - name: Copy coverage report + run: | + random_report_name = $(date +%s) | + echo "REPORT_NAME=$random_report_name" >> $GITHUB_ENV | + cp ./tarpaulin-report.html ./html_reports/$random_report_name.html | + git add . | + git commit -m "Add report $random_report_name" | + git push + + - 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 }}) \ 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