]> git.lizzy.rs Git - rust.git/blob - library/portable-simd/.github/workflows/ci.yml
Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillot
[rust.git] / library / portable-simd / .github / workflows / ci.yml
1 name: CI
2
3 on:
4   pull_request:
5   push:
6     branches:
7       - master
8
9 env:
10   CARGO_NET_RETRY: 10
11   RUSTUP_MAX_RETRIES: 10
12
13 jobs:
14   rustfmt:
15     name: "rustfmt"
16     runs-on: ubuntu-latest
17
18     steps:
19       - uses: actions/checkout@v2
20       - name: Setup Rust
21         run: |
22           rustup update nightly --no-self-update
23           rustup default nightly
24           rustup component add rustfmt
25       - name: Run rustfmt
26         run: cargo fmt --all -- --check
27
28   clippy:
29     name: "clippy on ${{ matrix.target }}"
30     runs-on: ubuntu-latest
31     strategy:
32       fail-fast: false
33       matrix:
34         target:
35           # We shouldn't really have any OS-specific code, so think of this as a list of architectures
36           - x86_64-unknown-linux-gnu
37           - i686-unknown-linux-gnu
38           - i586-unknown-linux-gnu
39           - aarch64-unknown-linux-gnu
40           - armv7-unknown-linux-gnueabihf
41           - mips-unknown-linux-gnu
42           - mips64-unknown-linux-gnuabi64
43           - powerpc-unknown-linux-gnu
44           - powerpc64-unknown-linux-gnu
45           - riscv64gc-unknown-linux-gnu
46           - s390x-unknown-linux-gnu
47           - sparc64-unknown-linux-gnu
48           - wasm32-unknown-unknown
49
50     steps:
51       - uses: actions/checkout@v2
52       - name: Setup Rust
53         run: |
54           rustup update nightly --no-self-update
55           rustup default nightly
56           rustup target add ${{ matrix.target }}
57           rustup component add clippy
58       - name: Run Clippy
59         run: cargo clippy --all-targets --target ${{ matrix.target }}
60
61   x86-tests:
62     name: "${{ matrix.target_feature }} on ${{ matrix.target }}"
63     runs-on: ${{ matrix.os }}
64     strategy:
65       fail-fast: false
66       matrix:
67         target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin]
68         # `default` means we use the default target config for the target,
69         # `native` means we run with `-Ctarget-cpu=native`, and anything else is
70         # an arg to `-Ctarget-feature`
71         target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2]
72
73         exclude:
74           # The macos runners seem to only reliably support up to `avx`.
75           - { target: x86_64-apple-darwin, target_feature: +avx2 }
76           # These features are statically known to be present for all 64 bit
77           # macs, and thus are covered by the `default` test
78           - { target: x86_64-apple-darwin, target_feature: +sse3 }
79           - { target: x86_64-apple-darwin, target_feature: +ssse3 }
80           # -Ctarget-cpu=native sounds like bad-news if target != host
81           - { target: i686-pc-windows-msvc, target_feature: native }
82           - { target: i586-pc-windows-msvc, target_feature: native }
83
84         include:
85           # Populate the `matrix.os` field
86           - { target: x86_64-apple-darwin,      os: macos-latest }
87           - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
88           - { target: x86_64-pc-windows-msvc,   os: windows-latest }
89           - { target: i686-pc-windows-msvc,     os: windows-latest }
90           - { target: i586-pc-windows-msvc,     os: windows-latest }
91
92           # These are globally available on all the other targets.
93           - { target: i586-pc-windows-msvc, target_feature: +sse, os: windows-latest }
94           - { target: i586-pc-windows-msvc, target_feature: +sse2, os: windows-latest }
95
96           # Annoyingly, the x86_64-unknown-linux-gnu runner *almost* always has
97           # avx512vl, but occasionally doesn't.  Maybe one day we can enable it.
98
99     steps:
100       - uses: actions/checkout@v2
101       - name: Setup Rust
102         run: |
103           rustup update nightly --no-self-update
104           rustup default nightly
105           rustup target add ${{ matrix.target }}
106
107       - name: Configure RUSTFLAGS
108         shell: bash
109         run: |
110           case "${{ matrix.target_feature }}" in
111             default)
112               echo "RUSTFLAGS=-Dwarnings" >> $GITHUB_ENV;;
113             native)
114               echo "RUSTFLAGS=-Dwarnings -Ctarget-cpu=native" >> $GITHUB_ENV
115               ;;
116             *)
117               echo "RUSTFLAGS=-Dwarnings -Ctarget-feature=${{ matrix.target_feature }}" >> $GITHUB_ENV
118               ;;
119           esac
120
121       # Super useful for debugging why a SIGILL occurred.
122       - name: Dump target configuration and support
123         run: |
124           rustc -Vv
125
126           echo "Caveat: not all target features are expected to be logged"
127
128           echo "## Requested target configuration (RUSTFLAGS=$RUSTFLAGS)"
129           rustc --print=cfg --target=${{ matrix.target }} $RUSTFLAGS
130
131           echo "## Supported target configuration for --target=${{ matrix.target }}"
132           rustc --print=cfg --target=${{ matrix.target }} -Ctarget-cpu=native
133
134           echo "## Natively supported target configuration"
135           rustc --print=cfg -Ctarget-cpu=native
136
137       - name: Test (debug)
138         run: cargo test --verbose --target=${{ matrix.target }}
139
140       - name: Test (release)
141         run: cargo test --verbose --target=${{ matrix.target }} --release
142
143   wasm-tests:
144     name: "wasm (firefox, ${{ matrix.name }})"
145     runs-on: ubuntu-latest
146     strategy:
147       matrix:
148         include:
149           - { name: default, RUSTFLAGS: "" }
150           - { name: simd128, RUSTFLAGS: "-C target-feature=+simd128" }
151     steps:
152       - uses: actions/checkout@v2
153       - name: Setup Rust
154         run: |
155           rustup update nightly --no-self-update
156           rustup default nightly
157       - name: Install wasm-pack
158         run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
159       - name: Test (debug)
160         run: wasm-pack test --firefox --headless crates/core_simd
161         env:
162             RUSTFLAGS: ${{ matrix.rustflags }}
163       - name: Test (release)
164         run: wasm-pack test --firefox --headless crates/core_simd --release
165         env:
166             RUSTFLAGS: ${{ matrix.rustflags }}
167
168   cross-tests:
169     name: "${{ matrix.target }} (via cross)"
170     runs-on: ubuntu-latest
171     strategy:
172       fail-fast: false
173       # TODO: Sadly, we cant configure target-feature in a meaningful way
174       # because `cross` doesn't tell qemu to enable any non-default cpu
175       # features, nor does it give us a way to do so.
176       #
177       # Ultimately, we'd like to do something like [rust-lang/stdarch][stdarch].
178       # This is a lot more complex... but in practice it's likely that we can just
179       # snarf the docker config from around [here][1000-dockerfiles].
180       #
181       # [stdarch]: https://github.com/rust-lang/stdarch/blob/a5db4eaf/.github/workflows/main.yml#L67
182       # [1000-dockerfiles]: https://github.com/rust-lang/stdarch/tree/a5db4eaf/ci/docker
183
184       matrix:
185         target:
186           - i586-unknown-linux-gnu
187           # 32-bit arm has a few idiosyncracies like having subnormal flushing
188           # to zero on by default. Ideally we'd set
189           - armv7-unknown-linux-gnueabihf
190           - aarch64-unknown-linux-gnu
191           # Note: The issue above means neither of these mips targets will use
192           # MSA (mips simd) but MIPS uses a nonstandard binary representation
193           # for NaNs which makes it worth testing on despite that.
194           - mips-unknown-linux-gnu
195           - mips64-unknown-linux-gnuabi64
196           - riscv64gc-unknown-linux-gnu
197           # TODO this test works, but it appears to time out
198           # - powerpc-unknown-linux-gnu
199           # TODO this test is broken, but it appears to be a problem with QEMU, not us.
200           # - powerpc64le-unknown-linux-gnu
201           # TODO enable this once a new version of cross is released
202           # - powerpc64-unknown-linux-gnu
203
204     steps:
205       - uses: actions/checkout@v2
206       - name: Setup Rust
207         run: |
208           rustup update nightly --no-self-update
209           rustup default nightly
210           rustup target add ${{ matrix.target }}
211           rustup component add rust-src
212
213       - name: Install Cross
214         # Equivalent to `cargo install cross`, but downloading a prebuilt
215         # binary. Ideally we wouldn't hardcode a version, but the version number
216         # being part of the tarball means we can't just use the download/latest
217         # URL :(
218         run: |
219           CROSS_URL=https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz
220           mkdir -p "$HOME/.bin"
221           curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin"
222           echo "$HOME/.bin" >> $GITHUB_PATH
223
224       - name: Test (debug)
225         run: cross test --verbose --target=${{ matrix.target }}
226
227       - name: Test (release)
228         run: cross test --verbose --target=${{ matrix.target }} --release
229
230   features:
231     name: "Check cargo features (${{ matrix.simd }} × ${{ matrix.features }})"
232     runs-on: ubuntu-latest
233     strategy:
234       fail-fast: false
235       matrix:
236         simd:
237           - ""
238           - "avx512"
239         features:
240           - ""
241           - "--features std"
242           - "--features generic_const_exprs"
243           - "--features std --features generic_const_exprs"
244
245     steps:
246       - uses: actions/checkout@v2
247       - name: Setup Rust
248         run: |
249           rustup update nightly --no-self-update
250           rustup default nightly
251       - name: Detect AVX512
252         run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV
253       - name: Check build
254         if: ${{ matrix.simd == '' }}
255         run: RUSTFLAGS="-Dwarnings" cargo check --all-targets --no-default-features ${{ matrix.features }}
256       - name: Check AVX
257         if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }}
258         run: |
259           echo "Found AVX features: $CPU_FEATURE"
260           RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo check --all-targets --no-default-features ${{ matrix.features }}