|
| 1 | +name: test |
| 2 | +# This is the main CI workflow that runs the test suite on all pushes to main |
| 3 | +# and all pull requests. It runs the following jobs: |
| 4 | +# - required: runs the test suite on ubuntu with stable and beta rust |
| 5 | +# toolchains. |
| 6 | +# - minimal: runs the test suite with the minimal versions of the dependencies |
| 7 | +# that satisfy the requirements of this crate, and its dependencies. |
| 8 | +# - os-check: runs the test suite on mac and windows. |
| 9 | +# - coverage: runs the test suite and collects coverage information. |
| 10 | +# See `check.yml` for information about how the concurrency cancellation and |
| 11 | +# workflow triggering works. |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + paths-ignore: |
| 18 | + - "**.md" |
| 19 | + - "**.adoc" |
| 20 | + pull_request: |
| 21 | + paths-ignore: |
| 22 | + - "**.md" |
| 23 | + - "**.adoc" |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 26 | + cancel-in-progress: true |
| 27 | +env: |
| 28 | + CARGO_TERM_COLOR: always |
| 29 | +jobs: |
| 30 | + required: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + name: ubuntu / ${{ matrix.toolchain }} |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + # Run on stable and beta to ensure that tests won't break on the next |
| 36 | + # version of the rust toolchain. |
| 37 | + toolchain: [stable, beta] |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + submodules: true |
| 42 | + - name: Install ${{ matrix.toolchain }} |
| 43 | + uses: dtolnay/rust-toolchain@master |
| 44 | + with: |
| 45 | + toolchain: ${{ matrix.toolchain }} |
| 46 | + - name: cargo generate-lockfile |
| 47 | + # Enable this ci template to run regardless of whether the lockfile is |
| 48 | + # checked in or not. |
| 49 | + if: hashFiles('Cargo.lock') == '' |
| 50 | + run: cargo generate-lockfile |
| 51 | + # https://twitter.com/jonhoo/status/1571290371124260865 |
| 52 | + - name: cargo test --locked |
| 53 | + run: cargo test --locked --all-features --all-targets |
| 54 | + # https://github.com/rust-lang/cargo/issues/6669 |
| 55 | + - name: cargo test --doc |
| 56 | + run: cargo test --locked --all-features --doc |
| 57 | + os-check: |
| 58 | + # Run cargo test on MacOS and Windows. |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + name: ${{ matrix.os }} / stable |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + os: [macos-latest, windows-latest] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + submodules: true |
| 69 | + - name: Install stable |
| 70 | + uses: dtolnay/rust-toolchain@stable |
| 71 | + - name: cargo generate-lockfile |
| 72 | + if: hashFiles('Cargo.lock') == '' |
| 73 | + run: cargo generate-lockfile |
| 74 | + - name: cargo test |
| 75 | + run: cargo test --locked --all-features --all-targets |
| 76 | + coverage: |
| 77 | + # Use llvm-cov to build and collect coverage and outputs in a format that |
| 78 | + # is compatible with codecov.io. |
| 79 | + # |
| 80 | + # Note that codecov as of v4 requires that CODECOV_TOKEN from |
| 81 | + # |
| 82 | + # https://app.codecov.io/gh/<user or org>/<project>/settings |
| 83 | + # |
| 84 | + # is set in two places on your repo: |
| 85 | + # |
| 86 | + # - https://github.com/jonhoo/guardian/settings/secrets/actions |
| 87 | + # - https://github.com/jonhoo/guardian/settings/secrets/dependabot |
| 88 | + # |
| 89 | + # (the former is needed for codecov uploads to work with Dependabot PRs) |
| 90 | + # |
| 91 | + # PRs coming from forks of your repo will not have access to the token, but |
| 92 | + # for those, codecov allows uploading coverage reports without a token. |
| 93 | + # it's all a little weird and inconvenient. see |
| 94 | + # |
| 95 | + # https://github.com/codecov/feedback/issues/112 |
| 96 | + # |
| 97 | + # for lots of more discussion. |
| 98 | + runs-on: ubuntu-latest |
| 99 | + name: ubuntu / stable / coverage |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + with: |
| 103 | + submodules: true |
| 104 | + - name: Install stable |
| 105 | + uses: dtolnay/rust-toolchain@stable |
| 106 | + with: |
| 107 | + components: llvm-tools-preview |
| 108 | + - name: cargo install cargo-llvm-cov |
| 109 | + uses: taiki-e/install-action@cargo-llvm-cov |
| 110 | + - name: cargo generate-lockfile |
| 111 | + if: hashFiles('Cargo.lock') == '' |
| 112 | + run: cargo generate-lockfile |
| 113 | + - name: cargo llvm-cov |
| 114 | + run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info |
| 115 | + - name: Record Rust version |
| 116 | + run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV" |
| 117 | + - name: Upload to codecov.io |
| 118 | + uses: codecov/codecov-action@v4 |
| 119 | + with: |
| 120 | + fail_ci_if_error: true |
| 121 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 122 | + env_vars: OS,RUST |
0 commit comments