-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
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: coverage-${{ runner.os }}-cargo-${{ 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_pecent.txt | | ||
AVG_COVERAGE=$(cat coverage_total_pecent.txt) | | ||
echo "COVERAGE=$AVG_COVERAGE" >> $GITHUB_ENV | ||
- name: Checkout target repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: myyrakle/html_reports | ||
token: ${{ secrets.REPORTS_GH_TOKEN }} | ||
ref: master | ||
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 | | ||
cd ./html_reports | | ||
git config --global user.email "sssang97@naver.com" | | ||
git config --global user.name "myyrakle" | | ||
- name: Init | ||
run: | | ||
git init | | ||
git branch master | | ||
git switch master | | ||
echo "init success" | | ||
- name: Add | ||
run: | | ||
git add . | | ||
echo "add success" | | ||
- name: Commit | ||
run: | | ||
git commit -m "Add report" | | ||
echo "commit success" | ||
- name: Push | ||
run: | | ||
git push -f https://myyrakle:${{ secrets.REPORTS_GH_TOKEN }}@github.com/myyrakle/html_reports master | ||
- name: Add comment to PR | ||
uses: thollander/actions-comment-pull-request@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
message: | | ||
✅ **Total Coverage**: ${{ env.COVERAGE }} | | ||
 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,6 @@ Cargo.lock | |
|
||
.rrdb.config | ||
|
||
.vscode | ||
.vscode | ||
|
||
tarpaulin-report.html |