Skip to content

Commit e1d0a3b

Browse files
committed
ci: refactor testing
Recently, `cross test` started running doc tests. This is A Good Thing, but the tests take *forever* because each test is compiled individually. In Rust 2024, this should hopefully be fixed since most doc tests will be combined together into one executable. But we haven't moved to Rust 2024 yet. We do this by splitting up the tests for "native" targets versus "cross" targets. This overall leads to a simpler configuration IMO.
1 parent 71233b5 commit e1d0a3b

File tree

1 file changed

+57
-47
lines changed

1 file changed

+57
-47
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ jobs:
3131
# This job does our basic build+test for supported platforms.
3232
test:
3333
env:
34-
# For some builds, we use cross to test on 32-bit and big-endian
35-
# systems.
36-
CARGO: cargo
37-
# When CARGO is set to CROSS, TARGET is set to `--target matrix.target`.
38-
# Note that we only use cross on Linux, so setting a target on a
39-
# different OS will just use normal cargo.
40-
TARGET:
41-
# Bump this as appropriate. We pin to a version to make sure CI
42-
# continues to work as cross releases in the past have broken things
43-
# in subtle ways.
44-
CROSS_VERSION: v0.2.5
4534
runs-on: ${{ matrix.os }}
4635
strategy:
4736
fail-fast: false
@@ -50,18 +39,6 @@ jobs:
5039
- build: stable
5140
os: ubuntu-latest
5241
rust: stable
53-
- build: stable-32
54-
os: ubuntu-latest
55-
rust: stable
56-
target: i686-unknown-linux-gnu
57-
- build: stable-powerpc64
58-
os: ubuntu-latest
59-
rust: stable
60-
target: powerpc64-unknown-linux-gnu
61-
- build: stable-s390x
62-
os: ubuntu-latest
63-
rust: stable
64-
target: s390x-unknown-linux-gnu
6542
- build: beta
6643
os: ubuntu-latest
6744
rust: beta
@@ -84,8 +61,57 @@ jobs:
8461
uses: dtolnay/rust-toolchain@master
8562
with:
8663
toolchain: ${{ matrix.rust }}
64+
- name: Show CPU info for debugging
65+
if: matrix.os == 'ubuntu-latest'
66+
run: lscpu
67+
- name: Basic build
68+
run: cargo build --verbose
69+
- name: Build docs
70+
run: cargo doc --verbose
71+
- name: Run subset of tests
72+
run: cargo test --verbose --test integration
73+
- name: Build regex-syntax docs
74+
run: cargo doc --verbose -p regex-syntax
75+
- name: Run subset of regex-syntax tests
76+
run: cargo test --verbose -p regex-syntax
77+
- name: Build regex-automata docs
78+
run: cargo doc --verbose -p regex-automata
79+
- name: Run subset of regex-automata tests
80+
if: matrix.build != 'win-gnu' # Just horrifically slow.
81+
run: cargo test --verbose -p regex-automata
82+
- name: Run regex-lite tests
83+
run: cargo test --verbose -p regex-lite
84+
- name: Run regex-cli tests
85+
run: cargo test --verbose -p regex-cli
86+
87+
# This job runs tests on cross compiled targets.
88+
#
89+
# We used to just have one test and do the same thing on normal targets and
90+
# cross targets, but cross tests can take an obscenely long time. Especially
91+
# the doc tests, where each one is compiled individually. (We haven't moved
92+
# to Rust 2024 yet.)
93+
cross:
94+
env:
95+
# Bump this as appropriate. We pin to a version to make sure CI
96+
# continues to work as cross releases in the past have broken things
97+
# in subtle ways.
98+
CROSS_VERSION: v0.2.5
99+
runs-on: ${{ matrix.os }}
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
target:
104+
- i686-unknown-linux-gnu
105+
- aarch64-unknown-linux-gnu
106+
- powerpc-unknown-linux-gnu
107+
- powerpc64-unknown-linux-gnu
108+
- s390x-unknown-linux-gnu
109+
- x86_64-linux-android
110+
- aarch64-linux-android
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
87114
- name: Install and configure Cross
88-
if: matrix.os == 'ubuntu-latest' && matrix.target != ''
89115
run: |
90116
# In the past, new releases of 'cross' have broken CI. So for now, we
91117
# pin it. We also use their pre-compiled binary releases because cross
@@ -96,34 +122,18 @@ jobs:
96122
cd "$dir"
97123
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
98124
tar xf cross-x86_64-unknown-linux-musl.tar.gz
99-
echo "CARGO=cross" >> $GITHUB_ENV
100-
echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
101-
- name: Show command used for Cargo
102-
run: |
103-
echo "cargo command is: $CARGO"
104-
echo "target flag is: $TARGET"
105-
- name: Show CPU info for debugging
106-
if: matrix.os == 'ubuntu-latest'
107-
run: lscpu
108125
- name: Basic build
109-
run: ${{ env.CARGO }} build --verbose $TARGET
110-
- name: Build docs
111-
run: ${{ env.CARGO }} doc --verbose $TARGET
126+
run: cross build --all --verbose --target ${{ matrix.target }}
112127
- name: Run subset of tests
113-
run: ${{ env.CARGO }} test --verbose --test integration $TARGET
114-
- name: Build regex-syntax docs
115-
run: ${{ env.CARGO }} doc --verbose --manifest-path regex-syntax/Cargo.toml $TARGET
128+
run: ${{ env.CARGO }} test --verbose --test integration --target ${{ matrix.target }}
116129
- name: Run subset of regex-syntax tests
117-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-syntax/Cargo.toml $TARGET
118-
- name: Build regex-automata docs
119-
run: ${{ env.CARGO }} doc --verbose --manifest-path regex-automata/Cargo.toml $TARGET
130+
run: ${{ env.CARGO }} test --verbose -p regex-syntax --lib --target ${{ matrix.target }}
120131
- name: Run subset of regex-automata tests
121-
if: matrix.build != 'win-gnu' # Just horrifically slow.
122-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-automata/Cargo.toml $TARGET
132+
run: ${{ env.CARGO }} test --verbose -p regex-automata --lib --target ${{ matrix.target }}
123133
- name: Run regex-lite tests
124-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-lite/Cargo.toml $TARGET
134+
run: ${{ env.CARGO }} test --verbose -p regex-lite --lib --target ${{ matrix.target }}
125135
- name: Run regex-cli tests
126-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-cli/Cargo.toml $TARGET
136+
run: ${{ env.CARGO }} test --verbose -p regex-cli --lib --target ${{ matrix.target }}
127137

128138
# This job runs a stripped down version of CI to test the MSRV. The specific
129139
# reason for doing this is that the regex crate's dev-dependencies tend to
@@ -222,7 +232,7 @@ jobs:
222232
toolchain: nightly
223233
components: miri
224234
- name: Run full test suite
225-
run: cargo miri test --manifest-path regex-automata/Cargo.toml
235+
run: cargo miri test -p regex-automata
226236

227237
# Tests that everything is formatted correctly.
228238
rustfmt:

0 commit comments

Comments
 (0)