feat(variabled): emit a warning instead of exiting #1279
Workflow file for this run
This file contains hidden or 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
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| merge_group: | |
| # See https://docs.github.com/en/actions/using-jobs/using-concurrency | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| name: coverage | |
| env: | |
| # Allows to fetch multiple private repo crates with different deploy keys. | |
| CARGO_NET_GIT_FETCH_WITH_CLI: true | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| name: ubuntu / stable / coverage | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Give GitHub Actions access to private crates | |
| uses: webfactory/ssh-agent@v0.8.0 | |
| with: | |
| ssh-private-key: | | |
| ${{ secrets.CAOS_OAUTH_DEPLOY_KEY }} | |
| ${{ secrets.CAOS_OPAMP_DEPLOY_KEY }} | |
| - name: Obtain Rust version from project | |
| run: | | |
| RUST_VERSION=$(grep "rust-version" Cargo.toml | cut -d "=" -f2 | tr -d "[:space:]") | |
| echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV | |
| - name: Install Rust ${{ env.RUST_VERSION }} | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| components: llvm-tools-preview | |
| toolchain: ${{ env.RUST_VERSION }} | |
| - name: cargo install cargo-llvm-cov | |
| uses: taiki-e/install-action@71765c00dd3e08a5484a5b9e82a4c88b86520e0e | |
| # uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: cargo generate-lockfile | |
| if: hashFiles('Cargo.lock') == '' | |
| run: cargo generate-lockfile | |
| - name: Generate coverage report | |
| run: COVERAGE_OUT_FORMAT=json COVERAGE_OUT_FILEPATH=jcov.info make coverage | |
| - name: Calculate and print total coverage | |
| run: | | |
| echo "Total functions coverage: $(jq '.data[].totals.functions.percent' jcov.info)" | |
| echo "Total lines coverage: $(jq '.data[].totals.lines.percent' jcov.info)" | |
| echo "Total regions coverage: $(jq '.data[].totals.regions.percent' jcov.info)" | |
| echo "Total instantiations coverage: $(jq '.data[].totals.instantiations.percent' jcov.info)" | |
| - name: Fail if function coverage is below 75% | |
| run: | | |
| fn_cov=$(jq '.data[].totals.functions.percent' jcov.info) | |
| expected=75 | |
| if (( $(echo "$fn_cov < $expected" | bc -l) )); then | |
| echo "Function coverage is below ${expected}%" | |
| exit 1 | |
| fi | |
| - name: Fail if line coverage is below 85% | |
| run: | | |
| ln_cov=$(jq '.data[].totals.lines.percent' jcov.info) | |
| expected=85 | |
| if (( $(echo "$ln_cov < $expected" | bc -l) )); then | |
| echo "Line coverage is below ${expected}%" | |
| exit 1 | |
| fi |