feat(ci): add code coverage report #1354
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
name: check | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
RUSTFLAGS: -D warnings | |
RUST_BACKTRACE: 1 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
quick-check: | |
if: startsWith(github.head_ref, 'dependabot/') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo check --tests --examples | |
test: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
env: | |
BEERUS_TEST_RUN: 1 | |
STARKNET_MAINNET_URL: https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }} | |
STARKNET_SEPOLIA_URL: https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: rm -rf /opt/hostedtoolcache | |
- run: cargo test | |
wasm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: rustup target add wasm32-unknown-unknown | |
- run: cd web/beerus-web && cargo check --target wasm32-unknown-unknown | |
clippy: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo clippy --all --all-features --all-targets -- -D warnings | |
lint: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo fmt --all -- --check | |
udeps: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@nightly | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- run: cargo install cargo-udeps --locked | |
- run: cargo +nightly udeps --all-targets --all-features | |
typos: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: crate-ci/typos@v1.24.1 | |
with: | |
files: . | |
coverage: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
env: | |
BEERUS_TEST_RUN: 1 | |
STARKNET_MAINNET_URL: https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }} | |
STARKNET_SEPOLIA_URL: https://starknet-sepolia.g.alchemy.com/starknet/version/rpc/v0_7/${{ secrets.ALCHEMY_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
# - name: (Free disk space) | |
# run: rm -rf /opt/hostedtoolcache | |
- uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Generate coverage report | |
run: cargo llvm-cov --json --output-path coverage.json | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
files: ./coverage.json | |
#token: ${{ secrets.CODECOV_TOKEN }} | |
# - name: View context attributes | |
# uses: actions/github-script@v7 | |
# with: | |
# script: console.log(context) |