Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add codecov github action (#573)
Co-authored-by: qing <qing@imideMacBook-Air.local>
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
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,72 @@ | ||
# Run cargo-llvm-cov and upload to codecov.io | ||
|
||
name: Code Coverage | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
# branches: | ||
# - main | ||
paths: | ||
- '**.rs' | ||
- '.github/workflows/codecov.yml' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref_name != 'main' }} | ||
|
||
jobs: | ||
coverage: | ||
name: Code Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: moonrepo/setup-rust@v1 | ||
with: | ||
bins: just, taplo-cli | ||
cache-base: main | ||
components: clippy,rustfmt,llvm-tools-preview | ||
|
||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-llvm-cov | ||
|
||
- name: Run | ||
run: cargo llvm-cov --lcov --output-path lcov.info | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: codecov | ||
path: lcov.info | ||
|
||
# codecov often fails, use another workflow for retry | ||
upload-codecov: | ||
name: Upload coverage file | ||
runs-on: ubuntu-latest | ||
needs: coverage | ||
# Check if the event is not triggered by a fork by checking whether CODECOV_TOKEN is set | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
if: env.CODECOV_TOKEN | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download coverage file | ||
if: env.CODECOV_TOKEN | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: codecov | ||
|
||
- name: Upload to codecov.io | ||
if: env.CODECOV_TOKEN | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
files: lcov.info |