|
| 1 | +# This workflow runs whenever a PR is opened or updated, or a commit is pushed to aurora. It runs |
| 2 | +# several checks: |
| 3 | +# - fmt: checks that the code is formatted according to rustfmt |
| 4 | +# - clippy: checks that the code does not contain any clippy warnings |
| 5 | +# - doc: checks that the code can be documented without errors |
| 6 | +# - hack: check combinations of feature flags |
| 7 | +# - msrv: check that the msrv specified in the crate is correct |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | +# This configuration allows auroratainers of this repo to create a branch and pull request based on |
| 11 | +# the new branch. Restricting the push trigger to the aurora branch ensures that the PR only gets |
| 12 | +# built once. |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [aurora] |
| 16 | + pull_request: |
| 17 | +# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that |
| 18 | +# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | +name: check |
| 23 | +jobs: |
| 24 | + fmt: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + name: stable / fmt |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + submodules: true |
| 31 | + - name: Install stable |
| 32 | + uses: dtolnay/rust-toolchain@stable |
| 33 | + with: |
| 34 | + components: rustfmt |
| 35 | + - name: cargo fmt --check |
| 36 | + run: cargo fmt --check |
| 37 | + clippy: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + name: ${{ matrix.toolchain }} / clippy |
| 40 | + permissions: |
| 41 | + contents: read |
| 42 | + checks: write |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + # Get early warning of new lints which are regularly introduced in beta channels. |
| 47 | + toolchain: [stable, beta] |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + submodules: true |
| 52 | + - name: Install ${{ matrix.toolchain }} |
| 53 | + uses: dtolnay/rust-toolchain@master |
| 54 | + with: |
| 55 | + toolchain: ${{ matrix.toolchain }} |
| 56 | + components: clippy |
| 57 | + - name: cargo clippy |
| 58 | + uses: actions-rs/clippy-check@v1 |
| 59 | + with: |
| 60 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + doc: |
| 62 | + # run docs generation on nightly rather than stable. This enables features like |
| 63 | + # https://doc.rust-lang.org/beta/unstable-book/language-features/doc-cfg.html which allows an |
| 64 | + # API be documented as only available in some specific platforms. |
| 65 | + runs-on: ubuntu-latest |
| 66 | + name: nightly / doc |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + submodules: true |
| 71 | + - name: Install nightly |
| 72 | + uses: dtolnay/rust-toolchain@nightly |
| 73 | + - name: cargo doc |
| 74 | + run: cargo doc --no-deps --all-features |
| 75 | + env: |
| 76 | + RUSTDOCFLAGS: --cfg docsrs |
| 77 | + hack: |
| 78 | + # cargo-hack checks combinations of feature flags to ensure that features are all additive |
| 79 | + # which is required for feature unification |
| 80 | + runs-on: ubuntu-latest |
| 81 | + name: ubuntu / stable / features |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + submodules: true |
| 86 | + - name: Install stable |
| 87 | + uses: dtolnay/rust-toolchain@stable |
| 88 | + - name: cargo install cargo-hack |
| 89 | + uses: taiki-e/install-action@cargo-hack |
| 90 | + # intentionally no target specifier; see https://github.com/jonhoo/rust-ci-conf/pull/4 |
| 91 | + # --feature-powerset runs for every combination of features |
| 92 | + - name: cargo hack |
| 93 | + run: cargo hack --feature-powerset check |
| 94 | + msrv: |
| 95 | + # check that we can build using the minimal rust version that is specified by this crate |
| 96 | + runs-on: ubuntu-latest |
| 97 | + # we use a matrix here just because env can't be used in job names |
| 98 | + # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability |
| 99 | + strategy: |
| 100 | + matrix: |
| 101 | + msrv: ["1.65.0"] # 2021 edition requires 1.56 |
| 102 | + name: ubuntu / ${{ matrix.msrv }} |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + with: |
| 106 | + submodules: true |
| 107 | + - name: Install ${{ matrix.msrv }} |
| 108 | + uses: dtolnay/rust-toolchain@master |
| 109 | + with: |
| 110 | + toolchain: ${{ matrix.msrv }} |
| 111 | + - name: cargo +${{ matrix.msrv }} check |
| 112 | + run: cargo check |
| 113 | + |
| 114 | + lint: |
| 115 | + name: Lint |
| 116 | + runs-on: ubuntu-latest |
| 117 | + steps: |
| 118 | + - name: Checkout the repository |
| 119 | + if: github.event_name != 'pull_request' |
| 120 | + uses: actions/checkout@v4 |
| 121 | + - name: Checkout the repository |
| 122 | + if: github.event_name == 'pull_request' |
| 123 | + uses: actions/checkout@v4 |
| 124 | + with: |
| 125 | + ref: ${{ github.event.pull_request.head.sha }} |
| 126 | + |
| 127 | + - name: Install Rust |
| 128 | + uses: actions-rs/toolchain@v1 |
| 129 | + with: |
| 130 | + profile: minimal |
| 131 | + toolchain: stable |
| 132 | + override: true |
| 133 | + components: rustfmt, clippy |
| 134 | + |
| 135 | + - name: Cache Cargo dependencies |
| 136 | + uses: Swatinem/rust-cache@v2 |
| 137 | + |
| 138 | + - name: Run cargo-deny |
| 139 | + uses: EmbarkStudios/cargo-deny-action@v1 |
| 140 | + with: |
| 141 | + command: check licenses sources |
| 142 | + |
| 143 | + - name: Run cargo-audit |
| 144 | + uses: actions-rs/audit-check@v1 |
| 145 | + with: |
| 146 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 147 | + |
| 148 | + - name: Run committed |
| 149 | + uses: crate-ci/committed@master |
| 150 | + with: |
| 151 | + args: "-vv" |
| 152 | + commits: "HEAD" |
| 153 | + |
| 154 | + - name: Run lychee |
| 155 | + uses: lycheeverse/lychee-action@v1 |
| 156 | + with: |
| 157 | + args: -v *.md |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + |
| 161 | + - name: Run codespell |
| 162 | + uses: codespell-project/actions-codespell@master |
| 163 | + with: |
| 164 | + check_filenames: true |
| 165 | + check_hidden: true |
| 166 | + ignore_words_file: .codespellignore |
| 167 | + skip: target,.git,_typos.toml |
0 commit comments