fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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