Repository navigation
nvx: name the timing bounds of the run command's foreground #435
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
| name: nvx coverage | |
| # Measures which code of the nvx crate its own tests reach, on Linux and | |
| # Windows, with scripts/nvx_coverage.py (doc/ci.md, "nvx coverage"). It | |
| # runs for the pushes to dev and the ready pull requests that change the crate | |
| # or how it is measured, and on demand. A pull request's summary also lists the | |
| # lines of production code that it adds or changes and that no test reaches. | |
| # Draft pull requests skip it, as they skip CI's other jobs, and no required | |
| # check depends on it. | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| paths: | |
| - nvx/** | |
| - rust-toolchain.toml | |
| - scripts/nvx_coverage.py | |
| - scripts/setup/tool-versions.conf | |
| - .github/workflows/nvx-coverage.yml | |
| # As in ci.yml, a pull request runs for any base, so that one stacked on | |
| # another pull request's branch lists the lines of its own changes. | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| paths: | |
| - nvx/** | |
| - rust-toolchain.toml | |
| - scripts/nvx_coverage.py | |
| - scripts/setup/tool-versions.conf | |
| - .github/workflows/nvx-coverage.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| # A push replaces the measurement of an earlier push to the same branch or pull | |
| # request that is still running. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| measure: | |
| name: measure / ${{ matrix.os }} | |
| if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 90 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| # A pull request measures its head, rather than its merge with its base, | |
| # so that the summary names the lines of its own changes, and fetches the | |
| # history that their merge base needs. The expression gives a pull request | |
| # the string '0', which, unlike the number 0, is truthy. | |
| - name: Checkout | |
| uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }} | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: "3.12" | |
| # The Rust release that rust-toolchain.toml pins, and the cargo-llvm-cov | |
| # release that the setup tool manifest pins. | |
| - name: Resolve the pinned tools | |
| id: tools | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| toolchain=$(sed -n 's/^channel = "\([^"]*\)".*/\1/p' rust-toolchain.toml) | |
| cargo_llvm_cov=$(sed -n 's/^cargo_llvm_cov\.version=//p' \ | |
| scripts/setup/tool-versions.conf) | |
| test -n "${toolchain}" | |
| test -n "${cargo_llvm_cov}" | |
| { | |
| echo "toolchain=${toolchain}" | |
| echo "cargo_llvm_cov=${cargo_llvm_cov}" | |
| } >> "${GITHUB_OUTPUT}" | |
| - name: Install Rust, its llvm-tools, and cargo-llvm-cov | |
| shell: bash | |
| env: | |
| TOOLCHAIN: ${{ steps.tools.outputs.toolchain }} | |
| CARGO_LLVM_COV: ${{ steps.tools.outputs.cargo_llvm_cov }} | |
| run: | | |
| set -euo pipefail | |
| rustup toolchain install "${TOOLCHAIN}" --profile minimal --component llvm-tools | |
| cargo "+${TOOLCHAIN}" install --locked cargo-llvm-cov --version "${CARGO_LLVM_COV}" | |
| # Fails when the measurement misses something, such as what tests that | |
| # failed twice would have reached, after it writes the reports. For a | |
| # pull request, the summary also lists the lines of production code that | |
| # it adds or changes since its merge base with its base and that no test | |
| # reaches. | |
| - name: Measure | |
| shell: bash | |
| env: | |
| BASE: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| set -euo pipefail | |
| options=(--output build/nvx-coverage) | |
| if [[ -n "${BASE}" ]]; then | |
| options+=(--base "${BASE}") | |
| fi | |
| python scripts/nvx_coverage.py "${options[@]}" | |
| - name: Write the summary | |
| if: ${{ !cancelled() && hashFiles('build/nvx-coverage/summary.md') != '' }} | |
| shell: bash | |
| run: cat build/nvx-coverage/summary.md >> "${GITHUB_STEP_SUMMARY}" | |
| # A rerun of the job replaces the reports of its earlier attempt. | |
| - name: Upload the reports | |
| if: ${{ !cancelled() && hashFiles('build/nvx-coverage/**') != '' }} | |
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | |
| with: | |
| name: nvx-coverage-${{ runner.os }}-${{ github.run_id }} | |
| path: build/nvx-coverage | |
| if-no-files-found: error | |
| overwrite: true | |
| retention-days: 30 |