Skip to content

Commit e90a139

Browse files
Update to Linebender CI configuration
This removes `--benches` and `no_std` checking as those don't currently work.
1 parent c7b6eda commit e90a139

File tree

4 files changed

+329
-22
lines changed

4 files changed

+329
-22
lines changed

.github/workflows/ci.yml

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
env:
2+
# We aim to always test with the latest stable Rust toolchain, however we pin to a specific
3+
# version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still
4+
# come automatically. If the version specified here is no longer the latest stable version,
5+
# then please feel free to submit a PR that adjusts it along with the potential clippy fixes.
6+
RUST_STABLE_VER: "1.82" # 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.65"
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+
RUST_MIN_VER_PKGS: "-p svgtypes"
15+
16+
17+
# Rationale
18+
#
19+
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with
20+
# dev dependencies enabled, which does not match how they would be compiled by users.
21+
# A dev dependency might enable a feature that we need for a regular dependency,
22+
# and checking with --all-targets would not find our feature requirements lacking.
23+
# This problem still applies to cargo resolver version 2.
24+
# Thus we split all the targets into two steps, one with --lib --bins
25+
# and another with --tests --examples.
26+
# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages.
27+
# Luckily the default behavior of cargo with no explicit targets is the same but without the error.
28+
#
29+
# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across
30+
# the whole workspace. While cargo-hack will instead check each workspace package separately.
31+
#
32+
# Using cargo-hack also allows us to more easily test the feature matrix of our packages.
33+
# We use --each-feature & --optional-deps which will run a separate check for every feature.
34+
#
35+
# We use cargo-nextest, which has a faster concurrency model for running tests.
36+
# However cargo-nextest does not support running doc tests, so we also have a cargo test --doc step.
37+
# For more information see https://github.com/nextest-rs/nextest/issues/16
38+
#
39+
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
40+
# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
41+
#
42+
# We don't save caches in the merge-group cases, because those caches will never be re-used (apart
43+
# from the very rare cases where there are multiple PRs in the merge queue).
44+
# This is because GitHub doesn't share caches between merge queues and the main branch.
45+
46+
name: CI
47+
48+
on:
49+
pull_request:
50+
merge_group:
51+
# We run on push, even though the commit is the same as when we ran in merge_group.
52+
# This allows the cache to be primed.
53+
# See https://github.com/orgs/community/discussions/66430
54+
push:
55+
branches:
56+
- main
57+
58+
jobs:
59+
fmt:
60+
name: formatting
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: install stable toolchain
66+
uses: dtolnay/rust-toolchain@master
67+
with:
68+
toolchain: ${{ env.RUST_STABLE_VER }}
69+
components: rustfmt
70+
71+
- name: cargo fmt
72+
run: cargo fmt --all --check
73+
74+
- name: install ripgrep
75+
run: |
76+
sudo apt update
77+
sudo apt install ripgrep
78+
79+
- name: check copyright headers
80+
run: bash .github/copyright.sh
81+
82+
clippy-stable:
83+
name: cargo clippy
84+
runs-on: ${{ matrix.os }}
85+
strategy:
86+
matrix:
87+
os: [windows-latest, macos-latest, ubuntu-latest]
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: install stable toolchain
92+
uses: dtolnay/rust-toolchain@master
93+
with:
94+
toolchain: ${{ env.RUST_STABLE_VER }}
95+
targets: x86_64-unknown-none
96+
components: clippy
97+
98+
- name: install cargo-hack
99+
uses: taiki-e/install-action@v2
100+
with:
101+
tool: cargo-hack
102+
103+
- name: restore cache
104+
uses: Swatinem/rust-cache@v2
105+
with:
106+
save-if: ${{ github.event_name != 'merge_group' }}
107+
108+
- name: cargo clippy
109+
run: cargo hack clippy --workspace --locked --optional-deps --each-feature -- -D warnings
110+
111+
- name: cargo clippy (auxiliary)
112+
run: cargo hack clippy --workspace --locked --optional-deps --each-feature --tests --examples -- -D warnings
113+
114+
clippy-stable-wasm:
115+
name: cargo clippy (wasm32)
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- name: install stable toolchain
121+
uses: dtolnay/rust-toolchain@master
122+
with:
123+
toolchain: ${{ env.RUST_STABLE_VER }}
124+
targets: wasm32-unknown-unknown
125+
components: clippy
126+
127+
- name: install cargo-hack
128+
uses: taiki-e/install-action@v2
129+
with:
130+
tool: cargo-hack
131+
132+
- name: restore cache
133+
uses: Swatinem/rust-cache@v2
134+
with:
135+
save-if: ${{ github.event_name != 'merge_group' }}
136+
137+
- name: cargo clippy
138+
run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature -- -D warnings
139+
140+
- name: cargo clippy (auxiliary)
141+
run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature --tests --examples -- -D warnings
142+
143+
test-stable:
144+
name: cargo test
145+
runs-on: ${{ matrix.os }}
146+
strategy:
147+
matrix:
148+
os: [windows-latest, macos-latest, ubuntu-latest]
149+
steps:
150+
- uses: actions/checkout@v4
151+
152+
- name: install stable toolchain
153+
uses: dtolnay/rust-toolchain@master
154+
with:
155+
toolchain: ${{ env.RUST_STABLE_VER }}
156+
157+
- name: install cargo-nextest
158+
uses: taiki-e/install-action@v2
159+
with:
160+
tool: cargo-nextest
161+
162+
- name: restore cache
163+
uses: Swatinem/rust-cache@v2
164+
with:
165+
save-if: ${{ github.event_name != 'merge_group' }}
166+
167+
- name: cargo nextest
168+
run: cargo nextest run --workspace --locked --all-features --no-fail-fast
169+
170+
- name: cargo test --doc
171+
run: cargo test --doc --workspace --locked --all-features --no-fail-fast
172+
173+
test-stable-wasm:
174+
name: cargo test (wasm32)
175+
runs-on: ubuntu-latest
176+
steps:
177+
- uses: actions/checkout@v4
178+
179+
- name: install stable toolchain
180+
uses: dtolnay/rust-toolchain@master
181+
with:
182+
toolchain: ${{ env.RUST_STABLE_VER }}
183+
targets: wasm32-unknown-unknown
184+
185+
- name: restore cache
186+
uses: Swatinem/rust-cache@v2
187+
with:
188+
save-if: ${{ github.event_name != 'merge_group' }}
189+
190+
# TODO: Find a way to make tests work. Until then the tests are merely compiled.
191+
- name: cargo test compile
192+
run: cargo test --workspace --locked --target wasm32-unknown-unknown --all-features --no-run
193+
194+
check-msrv:
195+
name: cargo check (msrv)
196+
runs-on: ${{ matrix.os }}
197+
strategy:
198+
matrix:
199+
os: [windows-latest, macos-latest, ubuntu-latest]
200+
steps:
201+
- uses: actions/checkout@v4
202+
203+
- name: install msrv toolchain
204+
uses: dtolnay/rust-toolchain@master
205+
with:
206+
toolchain: ${{ env.RUST_MIN_VER }}
207+
targets: x86_64-unknown-none
208+
209+
- name: install cargo-hack
210+
uses: taiki-e/install-action@v2
211+
with:
212+
tool: cargo-hack
213+
214+
- name: restore cache
215+
uses: Swatinem/rust-cache@v2
216+
with:
217+
save-if: ${{ github.event_name != 'merge_group' }}
218+
219+
- name: cargo check
220+
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature
221+
222+
check-msrv-wasm:
223+
name: cargo check (msrv) (wasm32)
224+
runs-on: ubuntu-latest
225+
steps:
226+
- uses: actions/checkout@v4
227+
228+
- name: install msrv toolchain
229+
uses: dtolnay/rust-toolchain@master
230+
with:
231+
toolchain: ${{ env.RUST_MIN_VER }}
232+
targets: wasm32-unknown-unknown
233+
234+
- name: install cargo-hack
235+
uses: taiki-e/install-action@v2
236+
with:
237+
tool: cargo-hack
238+
239+
- name: restore cache
240+
uses: Swatinem/rust-cache@v2
241+
with:
242+
save-if: ${{ github.event_name != 'merge_group' }}
243+
244+
- name: cargo check
245+
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature
246+
247+
doc:
248+
name: cargo doc
249+
# NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu.
250+
# If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that.
251+
runs-on: ubuntu-latest
252+
steps:
253+
- uses: actions/checkout@v4
254+
255+
- name: install nightly toolchain
256+
uses: dtolnay/rust-toolchain@nightly
257+
258+
- name: restore cache
259+
uses: Swatinem/rust-cache@v2
260+
with:
261+
save-if: ${{ github.event_name != 'merge_group' }}
262+
263+
# We test documentation using nightly to match docs.rs.
264+
- name: cargo doc
265+
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items
266+
env:
267+
RUSTDOCFLAGS: '--cfg docsrs -D warnings'
268+
269+
# If this fails, consider changing your text or adding something to .typos.toml.
270+
typos:
271+
runs-on: ubuntu-latest
272+
steps:
273+
- uses: actions/checkout@v4
274+
275+
- name: check typos
276+
uses: crate-ci/[email protected]

.github/workflows/main.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
target
22
**/*.rs.bk
3-
Cargo.lock
43
/.idea
54
/svgtypes.iml

Cargo.lock

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)