Skip to content

Commit cd7bb75

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 4c8a5e3 commit cd7bb75

File tree

1 file changed

+57
-48
lines changed

1 file changed

+57
-48
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ permissions:
3030
jobs:
3131
# This job does our basic build+test for supported platforms.
3232
test:
33-
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
4533
runs-on: ${{ matrix.os }}
4634
strategy:
4735
fail-fast: false
@@ -50,18 +38,6 @@ jobs:
5038
- build: stable
5139
os: ubuntu-latest
5240
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
6541
- build: beta
6642
os: ubuntu-latest
6743
rust: beta
@@ -84,8 +60,57 @@ jobs:
8460
uses: dtolnay/rust-toolchain@master
8561
with:
8662
toolchain: ${{ matrix.rust }}
63+
- name: Show CPU info for debugging
64+
if: matrix.os == 'ubuntu-latest'
65+
run: lscpu
66+
- name: Basic build
67+
run: cargo build --verbose
68+
- name: Build docs
69+
run: cargo doc --verbose
70+
- name: Run subset of tests
71+
run: cargo test --verbose --test integration
72+
- name: Build regex-syntax docs
73+
run: cargo doc --verbose -p regex-syntax
74+
- name: Run subset of regex-syntax tests
75+
run: cargo test --verbose -p regex-syntax
76+
- name: Build regex-automata docs
77+
run: cargo doc --verbose -p regex-automata
78+
- name: Run subset of regex-automata tests
79+
if: matrix.build != 'win-gnu' # Just horrifically slow.
80+
run: cargo test --verbose -p regex-automata
81+
- name: Run regex-lite tests
82+
run: cargo test --verbose -p regex-lite
83+
- name: Run regex-cli tests
84+
run: cargo test --verbose -p regex-cli
85+
86+
# This job runs tests on cross compiled targets.
87+
#
88+
# We used to just have one test and do the same thing on normal targets and
89+
# cross targets, but cross tests can take an obscenely long time. Especially
90+
# the doc tests, where each one is compiled individually. (We haven't moved
91+
# to Rust 2024 yet.)
92+
cross:
93+
env:
94+
# Bump this as appropriate. We pin to a version to make sure CI
95+
# continues to work as cross releases in the past have broken things
96+
# in subtle ways.
97+
CROSS_VERSION: v0.2.5
98+
runs-on: ${{ matrix.os }}
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
target:
103+
- i686-unknown-linux-gnu
104+
- aarch64-unknown-linux-gnu
105+
- powerpc-unknown-linux-gnu
106+
- powerpc64-unknown-linux-gnu
107+
- s390x-unknown-linux-gnu
108+
- x86_64-linux-android
109+
- aarch64-linux-android
110+
steps:
111+
- name: Checkout repository
112+
uses: actions/checkout@v4
87113
- name: Install and configure Cross
88-
if: matrix.os == 'ubuntu-latest' && matrix.target != ''
89114
run: |
90115
# In the past, new releases of 'cross' have broken CI. So for now, we
91116
# pin it. We also use their pre-compiled binary releases because cross
@@ -96,34 +121,18 @@ jobs:
96121
cd "$dir"
97122
curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz"
98123
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
108124
- name: Basic build
109-
run: ${{ env.CARGO }} build --verbose $TARGET
110-
- name: Build docs
111-
run: ${{ env.CARGO }} doc --verbose $TARGET
125+
run: cross build --all --verbose --target ${{ matrix.target }}
112126
- 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
127+
run: ${{ env.CARGO }} test --verbose --test integration --target ${{ matrix.target }}
116128
- 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
129+
run: ${{ env.CARGO }} test --verbose -p regex-syntax --lib --target ${{ matrix.target }}
120130
- 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
131+
run: ${{ env.CARGO }} test --verbose -p regex-automata --lib --target ${{ matrix.target }}
123132
- name: Run regex-lite tests
124-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-lite/Cargo.toml $TARGET
133+
run: ${{ env.CARGO }} test --verbose -p regex-lite --lib --target ${{ matrix.target }}
125134
- name: Run regex-cli tests
126-
run: ${{ env.CARGO }} test --verbose --manifest-path regex-cli/Cargo.toml $TARGET
135+
run: ${{ env.CARGO }} test --verbose -p regex-cli --lib --target ${{ matrix.target }}
127136

128137
# This job runs a stripped down version of CI to test the MSRV. The specific
129138
# reason for doing this is that the regex crate's dev-dependencies tend to
@@ -222,7 +231,7 @@ jobs:
222231
toolchain: nightly
223232
components: miri
224233
- name: Run full test suite
225-
run: cargo miri test --manifest-path regex-automata/Cargo.toml
234+
run: cargo miri test -p regex-automata
226235

227236
# Tests that everything is formatted correctly.
228237
rustfmt:

0 commit comments

Comments
 (0)