|
| 1 | +# Taken from https://github.com/jonhoo/rust-ci-conf/blob/main/.github/workflows/test.yml |
| 2 | + |
| 3 | +# This is the main CI workflow that runs the test suite on all pushes to main and all pull requests. |
| 4 | +# It runs the following jobs: |
| 5 | +# - required: runs the test suite on ubuntu with stable and beta rust toolchains |
| 6 | +# - minimal: runs the test suite with the minimal versions of the dependencies that satisfy the |
| 7 | +# 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 workflow triggering works |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [main] |
| 16 | + pull_request: |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 19 | + cancel-in-progress: true |
| 20 | +name: test |
| 21 | +jobs: |
| 22 | + required: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + name: ubuntu / ${{ matrix.toolchain }} |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + # run on stable and beta to ensure that tests won't break on the next version of the rust |
| 28 | + # toolchain |
| 29 | + toolchain: [stable, beta] |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + submodules: true |
| 34 | + - name: Install ${{ matrix.toolchain }} |
| 35 | + uses: dtolnay/rust-toolchain@master |
| 36 | + with: |
| 37 | + toolchain: ${{ matrix.toolchain }} |
| 38 | + - name: cargo generate-lockfile |
| 39 | + # enable this ci template to run regardless of whether the lockfile is checked in or not |
| 40 | + if: hashFiles('Cargo.lock') == '' |
| 41 | + run: cargo generate-lockfile |
| 42 | + # https://twitter.com/jonhoo/status/1571290371124260865 |
| 43 | + - name: cargo test --locked |
| 44 | + run: cargo test --locked --all-features --all-targets |
| 45 | + # https://github.com/rust-lang/cargo/issues/6669 |
| 46 | + - name: cargo test --doc |
| 47 | + run: cargo test --locked --all-features --doc |
| 48 | + minimal: |
| 49 | + # This action chooses the oldest version of the dependencies permitted by Cargo.toml to ensure |
| 50 | + # that this crate is compatible with the minimal version that this crate and its dependencies |
| 51 | + # require. This will pickup issues where this create relies on functionality that was introduced |
| 52 | + # later than the actual version specified (e.g., when we choose just a major version, but a |
| 53 | + # method was added after this version). |
| 54 | + # |
| 55 | + # This particular check can be difficult to get to succeed as often transitive dependencies may |
| 56 | + # be incorrectly specified (e.g., a dependency specifies 1.0 but really requires 1.1.5). There |
| 57 | + # is an alternative flag available -Zdirect-minimal-versions that uses the minimal versions for |
| 58 | + # direct dependencies of this crate, while selecting the maximal versions for the transitive |
| 59 | + # dependencies. Alternatively, you can add a line in your Cargo.toml to artificially increase |
| 60 | + # the minimal dependency, which you do with e.g.: |
| 61 | + # ```toml |
| 62 | + # # for minimal-versions |
| 63 | + # [target.'cfg(any())'.dependencies] |
| 64 | + # openssl = { version = "0.10.55", optional = true } # needed to allow foo to build with -Zminimal-versions |
| 65 | + # ``` |
| 66 | + # The optional = true is necessary in case that dependency isn't otherwise transitively required |
| 67 | + # by your library, and the target bit is so that this dependency edge never actually affects |
| 68 | + # Cargo build order. See also |
| 69 | + # https://github.com/jonhoo/fantoccini/blob/fde336472b712bc7ebf5b4e772023a7ba71b2262/Cargo.toml#L47-L49. |
| 70 | + # This action is run on ubuntu with the stable toolchain, as it is not expected to fail |
| 71 | + runs-on: ubuntu-latest |
| 72 | + name: ubuntu / stable / minimal-versions |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + submodules: true |
| 77 | + - name: Install stable |
| 78 | + uses: dtolnay/rust-toolchain@stable |
| 79 | + - name: Install nightly for -Zminimal-versions |
| 80 | + uses: dtolnay/rust-toolchain@nightly |
| 81 | + - name: rustup default stable |
| 82 | + run: rustup default stable |
| 83 | + - name: cargo update -Zminimal-versions |
| 84 | + run: cargo +nightly update -Zminimal-versions |
| 85 | + - name: cargo test |
| 86 | + run: cargo test --locked --all-features --all-targets |
| 87 | + os-check: |
| 88 | + # run cargo test on mac and windows |
| 89 | + runs-on: ${{ matrix.os }} |
| 90 | + name: ${{ matrix.os }} / stable |
| 91 | + strategy: |
| 92 | + fail-fast: false |
| 93 | + matrix: |
| 94 | + os: [macos-latest, windows-latest] |
| 95 | + steps: |
| 96 | + # if your project needs OpenSSL, uncomment this to fix Windows builds. |
| 97 | + # it's commented out by default as the install command takes 5-10m. |
| 98 | + # - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 99 | + # if: runner.os == 'Windows' |
| 100 | + # - run: vcpkg install openssl:x64-windows-static-md |
| 101 | + # if: runner.os == 'Windows' |
| 102 | + - uses: actions/checkout@v4 |
| 103 | + with: |
| 104 | + submodules: true |
| 105 | + - name: Install stable |
| 106 | + uses: dtolnay/rust-toolchain@stable |
| 107 | + - name: cargo generate-lockfile |
| 108 | + if: hashFiles('Cargo.lock') == '' |
| 109 | + run: cargo generate-lockfile |
| 110 | + - name: cargo test |
| 111 | + run: cargo test --locked --all-features --all-targets |
| 112 | + # # TODO: Setup code coverage. |
| 113 | + # coverage: |
| 114 | + # # use llvm-cov to build and collect coverage and outputs in a format that |
| 115 | + # # is compatible with codecov.io |
| 116 | + # # |
| 117 | + # # note that codecov as of v4 requires that CODECOV_TOKEN from |
| 118 | + # # |
| 119 | + # # https://app.codecov.io/gh/<user or org>/<project>/settings |
| 120 | + # # |
| 121 | + # # is set in two places on your repo: |
| 122 | + # # |
| 123 | + # # - https://github.com/jonhoo/guardian/settings/secrets/actions |
| 124 | + # # - https://github.com/jonhoo/guardian/settings/secrets/dependabot |
| 125 | + # # |
| 126 | + # # (the former is needed for codecov uploads to work with Dependabot PRs) |
| 127 | + # # |
| 128 | + # # PRs coming from forks of your repo will not have access to the token, but |
| 129 | + # # for those, codecov allows uploading coverage reports without a token. |
| 130 | + # # it's all a little weird and inconvenient. see |
| 131 | + # # |
| 132 | + # # https://github.com/codecov/feedback/issues/112 |
| 133 | + # # |
| 134 | + # # for lots of more discussion |
| 135 | + # runs-on: ubuntu-latest |
| 136 | + # name: ubuntu / stable / coverage |
| 137 | + # steps: |
| 138 | + # - uses: actions/checkout@v4 |
| 139 | + # with: |
| 140 | + # submodules: true |
| 141 | + # - name: Install stable |
| 142 | + # uses: dtolnay/rust-toolchain@stable |
| 143 | + # with: |
| 144 | + # components: llvm-tools-preview |
| 145 | + # - name: cargo install cargo-llvm-cov |
| 146 | + # uses: taiki-e/install-action@cargo-llvm-cov |
| 147 | + # - name: cargo generate-lockfile |
| 148 | + # if: hashFiles('Cargo.lock') == '' |
| 149 | + # run: cargo generate-lockfile |
| 150 | + # - name: cargo llvm-cov |
| 151 | + # run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info |
| 152 | + # - name: Record Rust version |
| 153 | + # run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV" |
| 154 | + # - name: Upload to codecov.io |
| 155 | + # uses: codecov/codecov-action@v5 |
| 156 | + # with: |
| 157 | + # fail_ci_if_error: true |
| 158 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 159 | + # env_vars: OS,RUST |
0 commit comments