]> git.lizzy.rs Git - rust.git/blob - .github/workflows/ci.yml
Use new module naming
[rust.git] / .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. As a result, we still run that
98           # one under travis.
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               ;;
114             native)
115               echo "RUSTFLAGS=-Ctarget-cpu=native" >> $GITHUB_ENV
116               ;;
117             *)
118               echo "RUSTFLAGS=-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   cross-tests:
145     name: "${{ matrix.target }} (via cross)"
146     runs-on: ubuntu-latest
147     strategy:
148       fail-fast: false
149       # TODO: Sadly, we cant configure target-feature in a meaningful way
150       # because `cross` doesn't tell qemu to enable any non-default cpu
151       # features, nor does it give us a way to do so.
152       #
153       # Ultimately, we'd like to do something like [rust-lang/stdarch][stdarch].
154       # This is a lot more complex... but in practice it's likely that we can just
155       # snarf the docker config from around [here][1000-dockerfiles].
156       #
157       # [stdarch]: https://github.com/rust-lang/stdarch/blob/a5db4eaf/.github/workflows/main.yml#L67
158       # [1000-dockerfiles]: https://github.com/rust-lang/stdarch/tree/a5db4eaf/ci/docker
159
160       matrix:
161         target:
162           - i586-unknown-linux-gnu
163           # 32-bit arm has a few idiosyncracies like having subnormal flushing
164           # to zero on by default. Ideally we'd set
165           - armv7-unknown-linux-gnueabihf
166           # Note: The issue above means neither of these mips targets will use
167           # MSA (mips simd) but MIPS uses a nonstandard binary representation
168           # for NaNs which makes it worth testing on despite that.
169           - mips-unknown-linux-gnu
170           - mips64-unknown-linux-gnuabi64
171           - riscv64gc-unknown-linux-gnu
172
173     steps:
174       - uses: actions/checkout@v2
175       - name: Setup Rust
176         run: |
177           rustup update nightly --no-self-update
178           rustup default nightly
179           rustup target add ${{ matrix.target }}
180           rustup component add rust-src
181
182       - name: Install Cross
183         # Equivalent to `cargo install cross`, but downloading a prebuilt
184         # binary. Ideally we wouldn't hardcode a version, but the version number
185         # being part of the tarball means we can't just use the download/latest
186         # URL :(
187         run: |
188           CROSS_URL=https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz
189           mkdir -p "$HOME/.bin"
190           curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin"
191           echo "$HOME/.bin" >> $GITHUB_PATH
192
193       - name: Test (debug)
194         run: cross test --verbose --target=${{ matrix.target }}
195
196       - name: Test (release)
197         run: cross test --verbose --target=${{ matrix.target }} --release
198