Skip to content

Commit 032e862

Browse files
authored
Update to our latest CI standard (#414)
This was most recently updated in linebender/vello#505 The main differences are: 1) Greater concurrency between clippy and testing 2) More explanations 3) MSRV checking 4) Use of `cargo hack` 5) WASM checked in CI I've also added the current values of our MSRVs to the main three crates.
1 parent 26f3202 commit 032e862

File tree

6 files changed

+275
-45
lines changed

6 files changed

+275
-45
lines changed

.github/workflows/ci.yml

Lines changed: 208 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,51 @@ env:
33
# version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still
44
# come automatically. If the version specified here is no longer the latest stable version,
55
# then please feel free to submit a PR that adjusts it along with the potential clippy fixes.
6-
RUST_STABLE_VER: "1.79" # In quotes because otherwise 1.70 would be interpreted as 1.7
7-
# We do not run the masonry snapshot tests, because those require a specific font stack
6+
RUST_STABLE_VER: "1.79" # In quotes because otherwise (e.g.) 1.70 would be interpreted as 1.7
7+
# The purpose of checking with the minimum supported Rust toolchain is to detect its staleness.
8+
# If the compilation fails, then the version specified here needs to be bumped up to reality.
9+
# Be sure to also update the rust-version property in the workspace Cargo.toml file,
10+
# plus all the README.md files of the affected packages.
11+
RUST_MIN_VER: "1.77"
12+
# List of packages that will be checked with the minimum supported Rust version.
13+
# This should be limited to packages that are intended for publishing.
14+
# If updating, synchronise RUST_MIN_VER_WASM_PKGS
15+
RUST_MIN_VER_PKGS: "-p xilem -p xilem_core -p masonry"
16+
17+
# List of packages that can not target Wasm.
18+
# If updating, synchronise RUST_MIN_VER_WASM_PKGS
19+
NO_WASM_PKGS: "--exclude masonry --exclude xilem"
20+
# RUST_MIN_VER_PKGS + NO_WASM_PKGS, evaluated.
21+
# This is required because `cargo hack` does not support -p {x} --exclude {x}
22+
RUST_MIN_VER_WASM_PKGS: "-p xilem_core"
23+
24+
# We do not run the masonry snapshot tests, because those currently require a specific font stack
25+
# See https://github.com/linebender/xilem/pull/233
826
SKIP_RENDER_SNAPSHOTS: 1
927
# We do not run the masonry render tests, because those require Vello rendering to be working
10-
# See https://github.com/linebender/vello/pull/439
28+
# See also https://github.com/linebender/vello/pull/610
1129
SKIP_RENDER_TESTS: 1
1230

1331
# Rationale
1432
#
1533
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with
1634
# dev dependencies enabled, which does not match how they would be compiled by users.
17-
# A dev dependency might enable a feature of a regular dependency that we need, but testing
18-
# with --all-targets would not catch that. Thus we split --lib & --bins into a separate step.
35+
# A dev dependency might enable a feature that we need for a regular dependency,
36+
# and checking with --all-targets would not find our feature requirements lacking.
37+
# This problem still applies to cargo resolver version 2.
38+
# Thus we split all the targets into two steps, one with --lib --bins
39+
# and another with --tests --benches --examples.
40+
# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages.
41+
# Luckily the default behavior of cargo with no explicit targets is the same but without the error.
42+
#
43+
# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across
44+
# the whole workspace. While cargo-hack will instead check each workspace package separately.
45+
#
46+
# Using cargo-hack also allows us to more easily test the feature matrix of our packages.
47+
# We use --each-feature & --optional-deps which will run a separate check for every feature.
48+
#
49+
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
50+
# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
1951

2052
name: CI
2153

@@ -24,9 +56,9 @@ on:
2456
merge_group:
2557

2658
jobs:
27-
rustfmt:
28-
runs-on: ubuntu-latest
59+
fmt:
2960
name: cargo fmt
61+
runs-on: ubuntu-latest
3062
steps:
3163
- uses: actions/checkout@v4
3264

@@ -47,79 +79,212 @@ jobs:
4779
- name: check copyright headers
4880
run: bash .github/copyright.sh
4981

50-
test-stable:
82+
clippy-stable:
83+
name: cargo clippy
5184
runs-on: ${{ matrix.os }}
5285
strategy:
5386
matrix:
5487
os: [windows-latest, macos-latest, ubuntu-latest]
55-
name: cargo clippy + test
5688
steps:
5789
- uses: actions/checkout@v4
5890

59-
- name: install additional linux dependencies
60-
run: |
61-
sudo apt update
62-
sudo apt install libwayland-dev libxkbcommon-x11-dev
63-
if: contains(matrix.os, 'ubuntu')
91+
- name: restore cache
92+
uses: Swatinem/rust-cache@v2
6493

6594
- name: install stable toolchain
6695
uses: dtolnay/rust-toolchain@master
6796
with:
6897
toolchain: ${{ env.RUST_STABLE_VER }}
6998
components: clippy
7099

100+
- name: install cargo-hack
101+
uses: taiki-e/install-action@v2
102+
with:
103+
tool: cargo-hack
104+
105+
- name: install native dependencies
106+
if: matrix.os == 'ubuntu-latest'
107+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
108+
109+
- name: cargo clippy
110+
run: cargo hack clippy --workspace --locked --each-feature --optional-deps -- -D warnings
111+
112+
- name: cargo clippy (auxiliary)
113+
run: cargo hack clippy --workspace --locked --each-feature --optional-deps --tests --benches --examples -- -D warnings
114+
115+
clippy-stable-wasm:
116+
name: cargo clippy (wasm32)
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v4
120+
71121
- name: restore cache
72122
uses: Swatinem/rust-cache@v2
73123

74-
- name: cargo clippy (no default features)
75-
run: cargo clippy --workspace --lib --bins --no-default-features -- -D warnings
76-
# No default features means no backend on Linux, so we won't run it
77-
if: contains(matrix.os, 'ubuntu') == false
124+
- name: install stable toolchain
125+
uses: dtolnay/rust-toolchain@master
126+
with:
127+
toolchain: ${{ env.RUST_STABLE_VER }}
128+
targets: wasm32-unknown-unknown
129+
components: clippy
78130

79-
- name: cargo clippy (no default features) (auxiliary)
80-
run: cargo clippy --workspace --tests --benches --examples --no-default-features -- -D warnings
81-
# No default features means no backend on Linux, so we won't run it
82-
if: contains(matrix.os, 'ubuntu') == false
131+
- name: install cargo-hack
132+
uses: taiki-e/install-action@v2
133+
with:
134+
tool: cargo-hack
83135

84-
- name: cargo clippy (default features)
85-
run: cargo clippy --workspace --lib --bins -- -D warnings
136+
- name: cargo clippy
137+
run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps -- -D warnings
86138

87-
- name: cargo clippy (default features) (auxiliary)
88-
run: cargo clippy --workspace --tests --benches --examples -- -D warnings
139+
- name: cargo clippy (auxiliary)
140+
run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps --tests --benches --examples -- -D warnings
89141

90-
- name: cargo clippy (all features)
91-
run: cargo clippy --workspace --lib --bins --all-features -- -D warnings
142+
test-stable:
143+
name: cargo test
144+
runs-on: ${{ matrix.os }}
145+
strategy:
146+
matrix:
147+
os: [windows-latest, macos-latest, ubuntu-latest]
148+
steps:
149+
- uses: actions/checkout@v4
150+
151+
- name: restore cache
152+
uses: Swatinem/rust-cache@v2
153+
154+
- name: install stable toolchain
155+
uses: dtolnay/rust-toolchain@master
156+
with:
157+
toolchain: ${{ env.RUST_STABLE_VER }}
92158

93-
- name: cargo clippy (all features) (auxiliary)
94-
run: cargo clippy --workspace --tests --benches --examples --all-features -- -D warnings
159+
- name: install native dependencies
160+
if: matrix.os == 'ubuntu-latest'
161+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
162+
163+
# Adapted from https://github.com/bevyengine/bevy/blob/b446374392adc70aceb92621b080d1a6cf7a7392/.github/workflows/validation-jobs.yml#L74-L79
164+
- name: install xvfb, llvmpipe and lavapipe
165+
if: matrix.os == 'ubuntu-latest'
166+
# https://launchpad.net/~kisak/+archive/ubuntu/turtle
167+
run: |
168+
sudo apt-get update -y -qq
169+
sudo add-apt-repository ppa:kisak/turtle -y
170+
sudo apt-get update
171+
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
95172
96173
- name: cargo test
97-
run: cargo test --workspace --all-features
174+
run: cargo test --workspace --locked --all-features
98175

99-
docs:
100-
name: cargo doc
176+
test-stable-wasm:
177+
name: cargo test (wasm32)
178+
runs-on: ubuntu-latest
179+
steps:
180+
- uses: actions/checkout@v4
181+
182+
- name: restore cache
183+
uses: Swatinem/rust-cache@v2
184+
185+
- name: install stable toolchain
186+
uses: dtolnay/rust-toolchain@master
187+
with:
188+
toolchain: ${{ env.RUST_STABLE_VER }}
189+
targets: wasm32-unknown-unknown
190+
191+
# TODO: Find a way to make tests work. Until then the tests are merely compiled.
192+
- name: cargo test compile
193+
run: cargo test --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --all-features --no-run
194+
195+
check-stable-android:
196+
name: cargo check (aarch64-android)
197+
runs-on: ubuntu-latest
198+
steps:
199+
- uses: actions/checkout@v4
200+
201+
- name: restore cache
202+
uses: Swatinem/rust-cache@v2
203+
204+
- name: install stable toolchain
205+
uses: dtolnay/rust-toolchain@master
206+
with:
207+
toolchain: ${{ env.RUST_STABLE_VER }}
208+
targets: aarch64-linux-android
209+
210+
- name: install cargo apk
211+
run: cargo install cargo-apk
212+
213+
- name: cargo apk check (android)
214+
run: cargo apk check -p xilem --example mason_android
215+
env:
216+
# This is a bit of a hack, but cargo apk doesn't seem to allow customising this otherwise
217+
RUSTFLAGS: '-D warnings'
218+
219+
check-msrv:
220+
name: cargo check (msrv)
101221
runs-on: ${{ matrix.os }}
102222
strategy:
103223
matrix:
104224
os: [windows-latest, macos-latest, ubuntu-latest]
105225
steps:
106226
- uses: actions/checkout@v4
107227

108-
- name: install additional linux dependencies
109-
run: |
110-
sudo apt update
111-
sudo apt install libwayland-dev libxkbcommon-x11-dev
112-
if: contains(matrix.os, 'ubuntu')
228+
- name: restore cache
229+
uses: Swatinem/rust-cache@v2
113230

114-
- name: install nightly toolchain
115-
uses: dtolnay/rust-toolchain@nightly
231+
- name: install msrv toolchain
232+
uses: dtolnay/rust-toolchain@master
233+
with:
234+
toolchain: ${{ env.RUST_MIN_VER }}
235+
236+
- name: install cargo-hack
237+
uses: taiki-e/install-action@v2
238+
with:
239+
tool: cargo-hack
240+
241+
- name: install native dependencies
242+
if: matrix.os == 'ubuntu-latest'
243+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
244+
245+
- name: cargo check
246+
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --each-feature --optional-deps
247+
248+
check-msrv-wasm:
249+
name: cargo check (msrv) (wasm32)
250+
runs-on: ubuntu-latest
251+
steps:
252+
- uses: actions/checkout@v4
253+
254+
- name: restore cache
255+
uses: Swatinem/rust-cache@v2
256+
257+
- name: install msrv toolchain
258+
uses: dtolnay/rust-toolchain@master
259+
with:
260+
toolchain: ${{ env.RUST_MIN_VER }}
261+
targets: wasm32-unknown-unknown
262+
263+
- name: install cargo-hack
264+
uses: taiki-e/install-action@v2
265+
with:
266+
tool: cargo-hack
267+
268+
- name: cargo check
269+
run: cargo hack check ${{ env.RUST_MIN_VER_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps
270+
271+
doc:
272+
name: cargo doc
273+
# NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu.
274+
# If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that.
275+
runs-on: ubuntu-latest
276+
steps:
277+
- uses: actions/checkout@v4
116278

117279
- name: restore cache
118280
uses: Swatinem/rust-cache@v2
119281

282+
- name: install nightly toolchain
283+
uses: dtolnay/rust-toolchain@nightly
284+
285+
# We test documentation using nightly to match docs.rs. This prevents potential breakages
120286
- name: cargo doc
121-
# We currently skip checking masonry's docs
122-
run: cargo doc --workspace --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples --exclude masonry
287+
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples
123288

124289
# If this fails, consider changing your text or adding something to .typos.toml
125290
typos:
@@ -128,4 +293,4 @@ jobs:
128293
- uses: actions/checkout@v4
129294

130295
- name: check typos
131-
uses: crate-ci/typos@v1.21.0
296+
uses: crate-ci/typos@v1.22.9

.typos.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ FillStrat = "FillStrat" # short for strategy
2424
seeked = "seeked" # Part of the HTML standard
2525

2626
[files]
27+
# Include .github, .cargo, etc.
28+
ignore-hidden = false
2729
extend-exclude = [
28-
"masonry/resources/i18n"
30+
"masonry/resources/i18n",
31+
# /.git isn't in .gitignore, because git never tracks it.
32+
# Typos doesn't know that, though.
33+
"/.git",
2934
]

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ members = [
1515

1616
[workspace.package]
1717
edition = "2021"
18+
# Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files.
19+
rust-version = "1.77"
1820
license = "Apache-2.0"
1921
repository = "https://github.com/linebender/xilem"
2022
homepage = "https://xilem.dev/"

masonry/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,26 @@ fn main() {
8888
}
8989
```
9090

91+
## Minimum supported Rust Version (MSRV)
92+
93+
This version of Masonry has been verified to compile with **Rust 1.77** and later.
94+
95+
Future versions of Masonry might increase the Rust version requirement.
96+
It will not be treated as a breaking change and as such can even happen with small patch releases.
97+
98+
<details>
99+
<summary>Click here if compiling fails.</summary>
100+
101+
As time has passed, some of Masonry's dependencies could have released versions with a higher Rust requirement.
102+
If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.
103+
104+
```sh
105+
# Use the problematic dependency's name and version
106+
cargo update -p package_name --precise 0.1.1
107+
```
108+
109+
</details>
110+
91111
## Community
92112

93113
Discussion of Masonry development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#masonry stream](https://xi.zulipchat.com/#narrow/stream/317477-masonry).

xilem/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ Xilem's reactive layer is built on top of a wide array of foundational Rust UI p
3131
Xilem can currently be considered to be in an alpha state.
3232
Lots of things need improvements.
3333

34+
## Minimum supported Rust Version (MSRV)
35+
36+
This version of Xilem has been verified to compile with **Rust 1.77** and later.
37+
38+
Future versions of Xilem might increase the Rust version requirement.
39+
It will not be treated as a breaking change and as such can even happen with small patch releases.
40+
41+
<details>
42+
<summary>Click here if compiling fails.</summary>
43+
44+
As time has passed, some of Xilem's dependencies could have released versions with a higher Rust requirement.
45+
If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.
46+
47+
```sh
48+
# Use the problematic dependency's name and version
49+
cargo update -p package_name --precise 0.1.1
50+
```
51+
52+
</details>
53+
3454
## Community
3555

3656
Discussion of Xilem development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#xilem stream](https://xi.zulipchat.com/#narrow/stream/354396-xilem).

0 commit comments

Comments
 (0)