Skip to content

Commit 4872901

Browse files
authored
Merge pull request #30 from thomcc/wfci
Completely overhaul CI
2 parents 0a46ca4 + e8a7f47 commit 4872901

File tree

2 files changed

+184
-216
lines changed

2 files changed

+184
-216
lines changed

.github/workflows/ci.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
x86-tests:
15+
name: "${{ matrix.target_feature }} on ${{ matrix.target }}"
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin]
21+
# `default` means we use the default target config for the target,
22+
# `native` means we run with `-Ctarget-cpu=native`, and anything else is
23+
# an arg to `-Ctarget-feature`
24+
target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2]
25+
26+
exclude:
27+
# The macos runners seem to only reliably support up to `avx`.
28+
- { target: x86_64-apple-darwin, target_feature: +avx2 }
29+
# These features are statically known to be present for all 64 bit
30+
# macs, and thus are covered by the `default` test
31+
- { target: x86_64-apple-darwin, target_feature: +sse3 }
32+
- { target: x86_64-apple-darwin, target_feature: +ssse3 }
33+
# -Ctarget-cpu=native sounds like bad-news if target != host
34+
- { target: i686-pc-windows-msvc, target_feature: native }
35+
- { target: i586-pc-windows-msvc, target_feature: native }
36+
37+
include:
38+
# Populate the `matrix.os` field
39+
- { target: x86_64-apple-darwin, os: macos-latest }
40+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
41+
- { target: x86_64-pc-windows-msvc, os: windows-latest }
42+
- { target: i686-pc-windows-msvc, os: windows-latest }
43+
- { target: i586-pc-windows-msvc, os: windows-latest }
44+
45+
# These are globally available on all the other targets.
46+
- { target: i586-pc-windows-msvc, target_feature: +sse, os: windows-latest }
47+
- { target: i586-pc-windows-msvc, target_feature: +sse2, os: windows-latest }
48+
49+
# Annoyingly, the x86_64-unknown-linux-gnu runner *almost* always has
50+
# avx512vl, but occasionally doesn't. As a result, we still run that
51+
# one under travis.
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Setup Rust
56+
run: |
57+
rustup update nightly --no-self-update
58+
rustup default nightly
59+
rustup target add ${{ matrix.target }}
60+
61+
- name: Configure RUSTFLAGS
62+
shell: bash
63+
run: |
64+
case "${{ matrix.target_feature }}" in
65+
default)
66+
;;
67+
native)
68+
echo "RUSTFLAGS=-Ctarget-cpu=native" >> $GITHUB_ENV
69+
;;
70+
*)
71+
echo "RUSTFLAGS=-Ctarget-feature=${{ matrix.target_feature }}" >> $GITHUB_ENV
72+
;;
73+
esac
74+
75+
# Super useful for debugging why a SIGILL occurred.
76+
- name: Dump target configuration and support
77+
run: |
78+
rustc -Vv
79+
80+
echo "Caveat: not all target features are expected to be logged"
81+
82+
echo "## Requested target configuration (RUSTFLAGS=$RUSTFLAGS)"
83+
rustc --print=cfg --target=${{ matrix.target }} $RUSTFLAGS
84+
85+
echo "## Supported target configuration for --target=${{ matrix.target }}"
86+
rustc --print=cfg --target=${{ matrix.target }} -Ctarget-cpu=native
87+
88+
echo "## Natively supported target configuration"
89+
rustc --print=cfg -Ctarget-cpu=native
90+
91+
- name: Test (debug)
92+
run: cargo test --verbose --target=${{ matrix.target }}
93+
94+
- name: Test (release)
95+
run: cargo test --verbose --target=${{ matrix.target }} --release
96+
97+
cross-tests:
98+
name: "${{ matrix.target }} (via cross)"
99+
runs-on: ubuntu-latest
100+
strategy:
101+
fail-fast: false
102+
# TODO: Sadly, we cant configure target-feature in a meaningful way
103+
# because `cross` doesn't tell qemu to enable any non-default cpu
104+
# features, nor does it give us a way to do so.
105+
#
106+
# Ultimately, we'd like to do something like [rust-lang/stdarch][stdarch].
107+
# This is a lot more complex... but in practice it's likely that we can just
108+
# snarf the docker config from around [here][1000-dockerfiles].
109+
#
110+
# [stdarch]: https://github.com/rust-lang/stdarch/blob/a5db4eaf/.github/workflows/main.yml#L67
111+
# [1000-dockerfiles]: https://github.com/rust-lang/stdarch/tree/a5db4eaf/ci/docker
112+
113+
matrix:
114+
target:
115+
- i586-unknown-linux-gnu
116+
# 32-bit arm has a few idiosyncracies like having subnormal flushing
117+
# to zero on by default. Ideally we'd set
118+
- armv7-unknown-linux-gnueabihf
119+
# Note: The issue above means neither of these mips targets will use
120+
# MSA (mips simd) but MIPS uses a nonstandard binary representation
121+
# for NaNs which makes it worth testing on despite that.
122+
- mips-unknown-linux-gnu
123+
- mips64-unknown-linux-gnuabi64
124+
- riscv64gc-unknown-linux-gnu
125+
126+
steps:
127+
- uses: actions/checkout@v2
128+
- name: Setup Rust
129+
run: |
130+
rustup update nightly --no-self-update
131+
rustup default nightly
132+
rustup target add ${{ matrix.target }}
133+
rustup component add rust-src
134+
135+
- name: Install Cross
136+
# Equivalent to `cargo install cross`, but downloading a prebuilt
137+
# binary. Ideally we wouldn't hardcode a version, but the version number
138+
# being part of the tarball means we can't just use the download/latest
139+
# URL :(
140+
run: |
141+
CROSS_URL=https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz
142+
mkdir -p "$HOME/.bin"
143+
curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin"
144+
echo "$HOME/.bin" >> $GITHUB_PATH
145+
146+
- name: Test (debug)
147+
run: cross test --verbose --target=${{ matrix.target }}
148+
149+
- name: Test (release)
150+
run: cross test --verbose --target=${{ matrix.target }} --release
151+

0 commit comments

Comments
 (0)