Build examples separately in CI (#727)
1on:
2 pull_request:
3 push:
4 branches:
5 - main
6 - 0.2.x
7 - 0.3.x
8
9name: CI
10
11env:
12 RUSTDOCFLAGS: "-D warnings"
13 CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse"
14
15jobs:
16 # MSRV check.
17 # Taffy only guarantees "latest stable". However we have this check here to ensure that we advertise
18 # our MSRV. We also make an effort not to increase MSRV in patch versions of Taffy.
19 #
20 # We only run `cargo build` (not `cargo test`) so as to avoid requiring dev-dependencies to build with the MSRV
21 # version. Building is likely sufficient as runtime errors varying between rust versions is very unlikely.
22 build-features-msrv:
23 name: "MSRV Build [Rust 1.65]"
24 runs-on: ubuntu-latest
25 steps:
26 - uses: actions/checkout@v4
27 - uses: dtolnay/rust-toolchain@master
28 with:
29 toolchain: 1.65
30 - run: cargo build
31
32 build-features-debug:
33 name: "Build [debug feature]"
34 runs-on: ubuntu-latest
35 steps:
36 - uses: actions/checkout@v4
37 - uses: dtolnay/rust-toolchain@stable
38 - run: cargo build --features debug
39
40 build-examples:
41 name: "Build Examples"
42 runs-on: ubuntu-latest
43 steps:
44 - uses: actions/checkout@v4
45 - uses: dtolnay/rust-toolchain@stable
46 - run: cargo build --examples
47
48 # No features
49 test-features-none:
50 name: "Test Suite [no features]"
51 runs-on: ubuntu-latest
52 steps:
53 - uses: actions/checkout@v4
54 - uses: dtolnay/rust-toolchain@stable
55 - run: cargo build --no-default-features
56 - run: cargo test --tests --no-default-features --features taffy_tree
57
58 # Default
59 test-features-default:
60 name: "Test Suite [default features]"
61 runs-on: ubuntu-latest
62 steps:
63 - uses: actions/checkout@v4
64 - uses: dtolnay/rust-toolchain@stable
65 - run: cargo build
66 - run: cargo test --tests
67
68 test-features-default-with-serde:
69 name: "Test Suite [default + serde]"
70 runs-on: ubuntu-latest
71 steps:
72 - uses: actions/checkout@v4
73 - uses: dtolnay/rust-toolchain@stable
74 - run: cargo build --features serde
75 - run: cargo test --tests --features serde
76
77 test-features-default-except-content-size:
78 name: "Test Suite [default except content_size]"
79 runs-on: ubuntu-latest
80 steps:
81 - uses: actions/checkout@v4
82 - uses: dtolnay/rust-toolchain@stable
83 - run: cargo build --no-default-features --features std,taffy_tree,grid,flexbox,block_layout
84 - run: cargo test --tests --no-default-features --features std,taffy_tree,grid,flexbox,block_layout
85
86 test-features-no-grid-nor-flexbox:
87 name: "Test Suite [std (no algorithms)]"
88 runs-on: ubuntu-latest
89 steps:
90 - uses: actions/checkout@v4
91 - uses: dtolnay/rust-toolchain@stable
92 - run: cargo build --no-default-features --features std
93 - run: cargo build --no-default-features --features std,taffy_tree
94 - run: cargo test --tests --no-default-features --features std,taffy_tree
95
96 # With std feature
97 test-features-flexbox:
98 name: "Test Suite [std + flexbox]"
99 runs-on: ubuntu-latest
100 steps:
101 - uses: actions/checkout@v4
102 - uses: dtolnay/rust-toolchain@stable
103 - run: cargo build --no-default-features --features flexbox,std
104 - run: cargo build --no-default-features --features flexbox,std,taffy_tree
105 - run: cargo test --tests --no-default-features --features flexbox,std,taffy_tree
106
107 test-features-grid:
108 name: "Test Suite [std + grid]"
109 runs-on: ubuntu-latest
110 steps:
111 - uses: actions/checkout@v4
112 - uses: dtolnay/rust-toolchain@stable
113 - run: cargo build --no-default-features --features grid,std
114 - run: cargo build --no-default-features --features grid,std,taffy_tree
115 - run: cargo test --tests --no-default-features --features grid,std,taffy_tree
116
117 test-features-block:
118 name: "Test Suite [std + block)]"
119 runs-on: ubuntu-latest
120 steps:
121 - uses: actions/checkout@v4
122 - uses: dtolnay/rust-toolchain@stable
123 - run: cargo build --no-default-features --features block_layout,std
124 - run: cargo build --no-default-features --features block_layout,std,taffy_tree
125 - run: cargo test --tests --no-default-features --features block_layout,std,taffy_tree
126
127 # With alloc feature
128
129 test-features-grid-with-alloc:
130 name: "Test Suite [alloc + no algorithms]"
131 runs-on: ubuntu-latest
132 steps:
133 - uses: actions/checkout@v4
134 - uses: dtolnay/rust-toolchain@stable
135 - run: cargo build --no-default-features --features alloc
136 - run: cargo build --no-default-features --features alloc,taffy_tree
137 - run: cargo test --tests --no-default-features --features alloc,taffy_tree
138
139 test-features-alloc:
140 name: "Test Suite [alloc + all algorithms]"
141 runs-on: ubuntu-latest
142 steps:
143 - uses: actions/checkout@v4
144 - uses: dtolnay/rust-toolchain@stable
145 - run: cargo build --no-default-features --features alloc,grid,flexbox,block_layout
146 - run: cargo build --no-default-features --features alloc,grid,flexbox,block_layout,taffy_tree
147 - run: cargo test --tests --no-default-features --features alloc,grid,flexbox,block_layout,taffy_tree
148
149 fmt:
150 name: Rustfmt
151 runs-on: ubuntu-latest
152 steps:
153 - uses: actions/checkout@v4
154 - uses: dtolnay/rust-toolchain@master
155 with:
156 toolchain: stable
157 components: rustfmt
158 - run: cargo fmt --all -- --check
159
160 clippy:
161 name: Clippy
162 runs-on: ubuntu-latest
163 steps:
164 - uses: actions/checkout@v4
165 - uses: dtolnay/rust-toolchain@master
166 with:
167 toolchain: nightly
168 components: clippy
169 - run: cargo +nightly clippy --workspace -- -D warnings
170
171 # Run rustdoc with the `docsrs` cfg to ensure that the documentation is compatible with docs.rs.
172 # This enables the doc_auto_cfg feature, which requires the nightly toolchain.
173 # Also checks that the examples can be scraped.
174 doc:
175 name: Documentation
176 runs-on: ubuntu-latest
177 env:
178 RUSTDOCFLAGS: "--cfg docsrs"
179 steps:
180 - uses: actions/checkout@v4
181 - uses: dtolnay/rust-toolchain@master
182 with:
183 toolchain: nightly
184 components: clippy
185 - run: cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples --all-features --no-deps
186
187 markdownlint:
188 name: Markdown Lint
189 runs-on: ubuntu-latest
190 steps:
191 - uses: actions/checkout@v4
192 - name: Run Markdown Lint
193 uses: DavidAnson/markdownlint-cli2-action@v17
194 with:
195 globs: "**/*.md"
196
197 fixture-format:
198 name: Test Fixture Formatting
199 runs-on: ubuntu-latest
200 steps:
201 - uses: actions/checkout@v4
202 - name: Run format script
203 run: cargo format-fixtures
204 - name: Ensure no changes
205 run: |
206 if [ -z "$(git status --porcelain)" ]; then
207 echo "Fixtures formatted correctly"
208 else
209 git status && echo -e "\nTest fixtures are not formatted correctly. Please run 'cargo format-fixtures'"
210 exit 1
211 fi
212
213 benchmarks:
214 name: Build Benchmarks
215 runs-on: ubuntu-latest
216 steps:
217 - uses: actions/checkout@v4
218 - uses: dtolnay/rust-toolchain@stable
219 - run: cargo xbench --no-run
220 name: Build benchmarks
221 env:
222 RUSTFLAGS: "-C opt-level=0"
223
224 benchmarks-with-yoga:
225 name: Build Benchmarks (w/ yoga)
226 runs-on: ubuntu-latest
227 steps:
228 - uses: actions/checkout@v4
229 - uses: dtolnay/rust-toolchain@stable
230 - run: cargo xbench --no-run --features yoga
231 name: Build benchmarks (w/yoga)
232 env:
233 RUSTFLAGS: "-C opt-level=0"