1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
env:
RUST_STABLE_VER: "1.86"
# Rationale
#
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with
# dev dependencies enabled, which does not match how they would be compiled by users.
# A dev dependency might enable a feature that we need for a regular dependency,
# and checking with --all-targets would not find our feature requirements lacking.
# This problem still applies to cargo resolver version 2.
# Thus we split all the targets into two steps, one with --lib --bins
# and another with --tests --benches --examples.
# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages.
# Luckily the default behavior of cargo with no explicit targets is the same but without the error.
#
# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across
# the whole workspace. While cargo-hack will instead check each workspace package separately.
#
# Using cargo-hack also allows us to more easily test the feature matrix of our packages.
# We use --each-feature & --optional-deps which will run a separate check for every feature.
#
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
# Checking is limited to packages that are intended for publishing to keep MSRV as low as possible.
#
# If the workspace uses debug_assertions then we verify code twice, with it set to true or false.
# We always keep it true for external dependencies so that we can reuse the cache for faster builds.
#
# We don't save caches in the merge-group cases, because those caches will never be re-used (apart
# from the very rare cases where there are multiple PRs in the merge queue).
# This is because GitHub doesn't share caches between merge queues and the main branch.
name: CI
on:
pull_request:
merge_group:
# We run on push, even though the commit is the same as when we ran in merge_group.
# This allows the cache to be primed.
# See https://github.com/orgs/community/discussions/66430
push:
branches:
- main
jobs:
fmt:
name: formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust ${{ env.RUST_STABLE_VER }}
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: ${{ env.RUST_STABLE_VER }}
components: rustfmt
- name: Run cargo fmt
run: cargo fmt --all --check
- name: Install Taplo
uses: uncenter/setup-taplo@09968a8ae38d66ddd3d23802c44bf6122d7aa991 # v1
with:
version: "0.9.3"
- name: Run taplo fmt
run: taplo fmt --check --diff
- name: Install ripgrep
run: |
sudo apt update
sudo apt install ripgrep
clippy-stable:
name: cargo clippy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust ${{ env.RUST_STABLE_VER }}
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: ${{ env.RUST_STABLE_VER }}
components: clippy
- name: Restore cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
save-if: ${{ github.event_name != 'merge_group' }}
- name: Run cargo clippy
run: cargo clippy --workspace --locked -- -D warnings
- name: Run cargo clippy (auxiliary)
run: cargo clippy --workspace --locked --tests --benches --examples -- -D warnings
- name: Run cargo clippy (no debug_assertions)
if: env.USING_DEBUG_ASSERTIONS == 'true'
run: cargo clippy --workspace --locked -- -D warnings
env:
CARGO_PROFILE_CI_DEBUG_ASSERTIONS: "false"
- name: Run cargo clippy (auxiliary) (no debug_assertions)
if: env.USING_DEBUG_ASSERTIONS == 'true'
run: cargo clippy --workspace --locked --tests --benches --examples -- -D warnings
env:
CARGO_PROFILE_CI_DEBUG_ASSERTIONS: "false"
test-stable:
name: cargo test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore cache
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
with:
save-if: ${{ github.event_name != 'merge_group' }}
- name: Run cargo test
run: cargo test --workspace --locked --all-features --no-fail-fast
env:
# We do not run the masonry render tests on platforms without a working GPU,
# because those require Vello rendering to be working
# See also https://github.com/linebender/vello/pull/610
SKIP_RENDER_TESTS: ${{ matrix.skip_gpu }}
doc:
name: cargo doc
# NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu.
# If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that.
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}
# We test documentation using nightly to match docs.rs.
- name: Run cargo doc
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples
env:
RUSTDOCFLAGS: '--cfg docsrs -D warnings'
# If this fails, consider changing your text or adding something to .typos.toml.
typos:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check typos
uses: crate-ci/typos@v1.31.1