summaryrefslogtreecommitdiff
path: root/.github/workflows/CI.yml
blob: 6fe0e4e54e2982e9eb742c70ab5fec33a3e0e84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: CI

env:
  CARGO_TERM_COLOR: always
  MSRV: '1.60'

on:
  push:
    branches:
    - main
  pull_request: {}

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: arduino/setup-protoc@v1
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: beta
        override: true
        profile: minimal
        components: clippy, rustfmt
    - uses: Swatinem/rust-cache@v2
    - name: Check
      uses: actions-rs/cargo@v1
      with:
        command: clippy
        args: --workspace --all-targets --all-features -- -D warnings
    - name: rustfmt
      uses: actions-rs/cargo@v1
      with:
        command: fmt
        args: -- --check

  check-docs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: cargo doc
      env:
        RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests"
      run: cargo doc --all-features --no-deps

  cargo-hack:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: arduino/setup-protoc@v1
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Install cargo-hack
      run: |
        curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
    - name: cargo hack check
      run: cargo hack check --each-feature --no-dev-deps --all

  cargo-public-api-crates:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        crate: [axum, axum-core, axum-extra, axum-macros]
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: nightly
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Install cargo-public-api-crates
      run: |
        cargo install --git https://github.com/davidpdrsn/cargo-public-api-crates
    - name: cargo public-api-crates check
      run: cargo public-api-crates --manifest-path ${{ matrix.crate }}/Cargo.toml check

  test-versions:
    needs: check
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust: [stable, beta]
    steps:
    - uses: actions/checkout@master
    - uses: arduino/setup-protoc@v1
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: ${{ matrix.rust }}
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Run tests
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --all --all-features --all-targets

  # some examples doesn't support our MSRV so we only test axum itself on our MSRV
  test-nightly:
    needs: check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        # same as `axum-macros/rust-toolchain`
        toolchain: nightly-2022-11-18
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Run nightly tests
      working-directory: axum-macros
      run: |
        cargo test

  # some examples doesn't support our MSRV (such as async-graphql)
  # so we only test axum itself on our MSRV
  test-msrv:
    needs: check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: ${{ env.MSRV }}
        override: true
        profile: minimal
    - name: "install Rust nightly"
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: nightly
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Select minimal versions
      uses: actions-rs/cargo@v1
      with:
        command: update
        args: -Z minimal-versions
        toolchain: nightly
    - name: Fix up Cargo.lock
      uses: actions-rs/cargo@v1
      with:
        command: update
        args: -p crc32fast --precise 1.1.1
        toolchain: nightly
    - name: Run tests
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: >
          -p axum
          -p axum-extra
          -p axum-core
          --all-features
          --all-targets
          --locked
        toolchain: ${{ env.MSRV }}
    # the compiler errors are different on our MSRV which makes
    # the trybuild tests in axum-macros fail, so just run the doc
    # tests
    - name: Run axum-macros doc tests
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: >
          -p axum-macros
          --doc
          --all-features
          --locked
        toolchain: ${{ env.MSRV }}

  test-docs:
    needs: check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Run doc tests
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --all-features --doc

  deny-check:
    name: cargo-deny check
    runs-on: ubuntu-latest
    continue-on-error: ${{ matrix.checks == 'advisories' }}
    strategy:
      matrix:
        checks:
          - advisories
          - bans licenses sources
    steps:
      - uses: actions/checkout@v2
      - uses: EmbarkStudios/cargo-deny-action@v1
        with:
          command: check ${{ matrix.checks }}
          arguments: --all-features --manifest-path axum/Cargo.toml

  armv5te-unknown-linux-musleabi:
    needs: check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable
        target: armv5te-unknown-linux-musleabi
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Check
      uses: actions-rs/cargo@v1
      env:
        # Clang has native cross-compilation support
        CC: clang
      with:
        command: check
        args: >
          --all-targets
          --all-features
          -p axum
          -p axum-core
          -p axum-extra
          -p axum-macros
          --target armv5te-unknown-linux-musleabi

  wasm32-unknown-unknown:
    needs: check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: stable
        target: wasm32-unknown-unknown
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v1
    - name: Check
      uses: actions-rs/cargo@v1
      with:
        command: check
        args: >
          --manifest-path ./examples/simple-router-wasm/Cargo.toml
          --target wasm32-unknown-unknown

  dependencies-are-sorted:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: beta
        override: true
        profile: minimal
    - uses: Swatinem/rust-cache@v2
    - name: Install cargo-sort
      run: |
        cargo install cargo-sort
    # Work around cargo-sort not honoring workspace.exclude
    - name: Remove non-crate folder
      run: rm -rf examples/async-graphql
    - name: Check dependency tables
      run: |
        cargo sort --workspace --grouped --check