• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: test
2
3on:
4  push:
5  pull_request:
6
7env:
8  CARGO_TERM_COLOR: always
9  RUST_BACKTRACE: full
10
11jobs:
12  test:
13    name: Build & test
14    strategy:
15      fail-fast: false
16      matrix:
17        os:
18          - ubuntu-latest
19          - macos-latest
20          - windows-latest
21        rust:
22          - stable
23          - beta
24          - nightly
25          # 1.45.0 # The weak-into-raw feature stabilized
26          # 1.31.0 is tested separately, because it is supposed to only build
27
28    runs-on: ${{ matrix.os }}
29
30    steps:
31      - name: checkout
32        uses: actions/checkout@v2
33
34      - name: Install Rust
35        uses: actions-rs/toolchain@v1
36        with:
37          toolchain: ${{ matrix.rust }}
38          default: true
39          profile: minimal
40
41      - name: Restore cache
42        uses: Swatinem/rust-cache@v1
43
44      - name: Build & test
45        env:
46          RUST_VERSION: ${{ matrix.rust }}
47          OS: ${{ matrix.os }}
48          RUSTFLAGS: -D warnings
49        run: cargo test --all-features
50
51  big-tests:
52    name: Run the big ignored tests
53    runs-on: ubuntu-latest
54    steps:
55      - name: checkout
56        uses: actions/checkout@v2
57
58      - name: Install Rust
59        uses: actions-rs/toolchain@v1
60        with:
61          toolchain: stable
62          default: true
63          profile: minimal
64
65      - name: Restore cache
66        uses: Swatinem/rust-cache@v1
67
68      - name: Build & test
69        env:
70          RUSTFLAGS: -D warnings
71        run: cargo test --all-features --release -- --ignored
72
73  bits32:
74    name: 32bit tests
75    runs-on: ubuntu-latest
76    steps:
77      - name: checkout
78        uses: actions/checkout@v2
79
80      - name: Install Rust
81        uses: actions-rs/toolchain@v1
82        with:
83          toolchain: stable
84          default: true
85          profile: minimal
86          target: x86_64-unknown-linux-musl
87
88      - name: Restore cache
89        uses: Swatinem/rust-cache@v1
90
91      - name: Build & test
92        env:
93          RUSTFLAGS: -D warnings
94        run: cargo test --all-features --target x86_64-unknown-linux-musl
95
96  rustfmt:
97    name: Check formatting
98    runs-on: ubuntu-latest
99    steps:
100      - name: checkout
101        uses: actions/checkout@v2
102
103      - name: Install Rust
104        uses: actions-rs/toolchain@v1
105        with:
106          profile: minimal
107          toolchain: stable
108          default: true
109          components: rustfmt
110
111      - run: cargo fmt --all -- --check
112
113  links:
114    name: Check documentation links
115    runs-on: ubuntu-latest
116    steps:
117      - name: checkout
118        uses: actions/checkout@v2
119
120      - name: Install Rust
121        uses: actions-rs/toolchain@v1
122        with:
123          toolchain: stable
124          default: true
125
126      - name: Restore cache
127        uses: Swatinem/rust-cache@v1
128
129      - name: Check links
130        run: cargo rustdoc --all-features -- -D warnings
131
132  clippy:
133    name: Clippy lints
134    runs-on: ubuntu-latest
135    steps:
136      - name: Checkout repository
137        uses: actions/checkout@v2
138
139      - name: Install Rust
140        uses: actions-rs/toolchain@v1
141        with:
142          toolchain: stable
143          profile: minimal
144          default: true
145          components: clippy
146
147      - name: Restore cache
148        uses: Swatinem/rust-cache@v1
149
150      - name: Run clippy linter
151        run: cargo clippy --all --all-features --tests -- -D clippy::all -D warnings
152
153  bench:
154    name: Verify benchmarks compile
155    runs-on: ubuntu-latest
156    steps:
157      - name: Checkout repository
158        uses: actions/checkout@v2
159
160      - name: Install Rust
161        uses: actions-rs/toolchain@v1
162        with:
163          toolchain: stable
164          profile: minimal
165          default: true
166
167      - name: Restore cache
168        uses: Swatinem/rust-cache@v1
169
170      - name: Run clippy linter
171        run: cargo test --all --release --benches --all-features
172
173  semi-ancient:
174    name: Check it compiles on old Rust (1.45.0)
175    runs-on: ubuntu-latest
176    steps:
177      - name: Checkout repository
178        uses: actions/checkout@v2
179
180      - name: Install Rust
181        uses: actions-rs/toolchain@v1
182        with:
183          toolchain: 1.45.0
184          profile: minimal
185          default: true
186
187      - name: Restore cache
188        uses: Swatinem/rust-cache@v1
189
190      - name: Run check
191        run: rm Cargo.lock && cargo check --all-features
192
193  ancient:
194    name: Check it compiles on old Rust (1.31.0)
195    runs-on: ubuntu-latest
196    steps:
197      - name: Checkout repository
198        uses: actions/checkout@v2
199
200      - name: Install Rust
201        uses: actions-rs/toolchain@v1
202        with:
203          toolchain: 1.31.0
204          profile: minimal
205          default: true
206
207      - name: Restore cache
208        uses: Swatinem/rust-cache@v1
209
210      - name: Run check
211        run: rm Cargo.lock && cargo check
212
213  miri:
214    name: Miri checks
215    runs-on: ubuntu-latest
216    steps:
217      - name: Checkout repository
218        uses: actions/checkout@v2
219
220      - name: Install Rust
221        uses: actions-rs/toolchain@v1
222        with:
223          toolchain: nightly
224          profile: minimal
225          default: true
226          components: "miri"
227
228      - name: Restore cache
229        uses: Swatinem/rust-cache@v1
230
231      - name: Run miri
232        env:
233          PROPTEST_CASES: "10"
234          MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-permissive-provenance"
235        run: cargo miri test --all-features
236
237  thread_sanitizer-MacOS:
238    name: Thread Sanitizer checks MacOS
239    runs-on: macos-latest
240
241    steps:
242    - uses: actions/checkout@v2
243    - uses: actions/cache@v2
244      with:
245        path: |
246          ~/.cargo/bin/
247          ~/.cargo/registry/index/
248          ~/.cargo/registry/cache/
249          ~/.cargo/git/db/
250          target/
251        key: ${{ github.event.repository.name }}-${{ runner.os }}-cargo-thread_sanitizer-v2
252    - name: Install latest nightly
253      uses: actions-rs/toolchain@v1
254      with:
255          toolchain: nightly
256          override: true
257          components: rust-src
258    - name: Run thread sanitizer
259      run: |
260        # Thread sanitizer isn't guaranteed to catch all data races, it can only catch it
261        # the data race if it happens when running the program.
262        #
263        # Running the tests multiple times increase the chances that data races are found
264        # by the thread sanitizer.
265        for _ in $(seq 1 10); do cargo +nightly test -Z build-std --target $(uname -m)-apple-darwin; done
266      env:
267        RUSTDOCFLAGS: "-Zsanitizer=thread"
268        RUSTFLAGS: "-Zsanitizer=thread"
269