Document feature flags and scrape examples (#672)
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 test-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 test-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 # No features
41 test-features-none:
42 name: "Test Suite [no features]"
43 runs-on: ubuntu-latest
44 steps:
45 - uses: actions/checkout@v4
46 - uses: dtolnay/rust-toolchain@stable
47 - run: cargo build --no-default-features
48 - run: cargo test --no-default-features --features taffy_tree
49
50 # Default
51 test-features-default:
52 name: "Test Suite [default features]"
53 runs-on: ubuntu-latest
54 steps:
55 - uses: actions/checkout@v4
56 - uses: dtolnay/rust-toolchain@stable
57 - run: cargo build
58 - run: cargo test
59
60 test-features-default-with-serde:
61 name: "Test Suite [default + serde]"
62 runs-on: ubuntu-latest
63 steps:
64 - uses: actions/checkout@v4
65 - uses: dtolnay/rust-toolchain@stable
66 - run: cargo build --features serde
67 - run: cargo test --features serde
68
69 test-features-default-except-content-size:
70 name: "Test Suite [default except content_size]"
71 runs-on: ubuntu-latest
72 steps:
73 - uses: actions/checkout@v4
74 - uses: dtolnay/rust-toolchain@stable
75 - run: cargo build --no-default-features --features std,taffy_tree,grid,flexbox,block_layout
76 - run: cargo test --no-default-features --features std,taffy_tree,grid,flexbox,block_layout
77
78 test-features-no-grid-nor-flexbox:
79 name: "Test Suite [std (no algorithms)]"
80 runs-on: ubuntu-latest
81 steps:
82 - uses: actions/checkout@v4
83 - uses: dtolnay/rust-toolchain@stable
84 - run: cargo build --no-default-features --features std
85 - run: cargo build --no-default-features --features std,taffy_tree
86 - run: cargo test --no-default-features --features std,taffy_tree
87
88 # With std feature
89 test-features-flexbox:
90 name: "Test Suite [std + flexbox]"
91 runs-on: ubuntu-latest
92 steps:
93 - uses: actions/checkout@v4
94 - uses: dtolnay/rust-toolchain@stable
95 - run: cargo build --no-default-features --features flexbox,std
96 - run: cargo build --no-default-features --features flexbox,std,taffy_tree
97 - run: cargo test --no-default-features --features flexbox,std,taffy_tree
98
99 test-features-grid:
100 name: "Test Suite [std + grid]"
101 runs-on: ubuntu-latest
102 steps:
103 - uses: actions/checkout@v4
104 - uses: dtolnay/rust-toolchain@stable
105 - run: cargo build --no-default-features --features grid,std
106 - run: cargo build --no-default-features --features grid,std,taffy_tree
107 - run: cargo test --no-default-features --features grid,std,taffy_tree
108
109 test-features-block:
110 name: "Test Suite [std + block)]"
111 runs-on: ubuntu-latest
112 steps:
113 - uses: actions/checkout@v4
114 - uses: dtolnay/rust-toolchain@stable
115 - run: cargo build --no-default-features --features block_layout,std
116 - run: cargo build --no-default-features --features block_layout,std,taffy_tree
117 - run: cargo test --no-default-features --features block_layout,std,taffy_tree
118
119 # With alloc feature
120
121 test-features-grid-with-alloc:
122 name: "Test Suite [alloc + no algorithms]"
123 runs-on: ubuntu-latest
124 steps:
125 - uses: actions/checkout@v4
126 - uses: dtolnay/rust-toolchain@stable
127 - run: cargo build --no-default-features --features alloc
128 - run: cargo build --no-default-features --features alloc,taffy_tree
129 - run: cargo test --no-default-features --features alloc,taffy_tree
130
131 test-features-alloc:
132 name: "Test Suite [alloc + all algorithms]"
133 runs-on: ubuntu-latest
134 steps:
135 - uses: actions/checkout@v4
136 - uses: dtolnay/rust-toolchain@stable
137 - run: cargo build --no-default-features --features alloc,grid,flexbox,block_layout
138 - run: cargo build --no-default-features --features alloc,grid,flexbox,block_layout,taffy_tree
139 - run: cargo test --no-default-features --features alloc,grid,flexbox,block_layout,taffy_tree
140
141 fmt:
142 name: Rustfmt
143 runs-on: ubuntu-latest
144 steps:
145 - uses: actions/checkout@v4
146 - uses: dtolnay/rust-toolchain@master
147 with:
148 toolchain: stable
149 components: rustfmt
150 - run: cargo fmt --all -- --check
151
152 clippy:
153 name: Clippy
154 runs-on: ubuntu-latest
155 steps:
156 - uses: actions/checkout@v4
157 - uses: dtolnay/rust-toolchain@master
158 with:
159 toolchain: nightly
160 components: clippy
161 - run: cargo +nightly clippy --workspace -- -D warnings
162
163 # Run rustdoc with the `docsrs` cfg to ensure that the documentation is compatible with docs.rs.
164 # This enables the doc_auto_cfg feature, which requires the nightly toolchain.
165 # Also checks that the examples can be scraped.
166 doc:
167 name: Documentation
168 runs-on: ubuntu-latest
169 env:
170 RUSTDOCFLAGS: "--cfg docsrs"
171 steps:
172 - uses: actions/checkout@v4
173 - uses: dtolnay/rust-toolchain@master
174 with:
175 toolchain: nightly
176 components: clippy
177 - run: cargo +nightly doc -Zunstable-options -Zrustdoc-scrape-examples --all-features --no-deps
178
179 markdownlint:
180 name: Markdown Lint
181 runs-on: ubuntu-latest
182 steps:
183 - uses: actions/checkout@v4
184 - name: Run Markdown Lint
185 uses: DavidAnson/markdownlint-cli2-action@v16
186 with:
187 globs: "**/*.md"
188
189 fixture-format:
190 name: Test Fixture Formatting
191 runs-on: ubuntu-latest
192 steps:
193 - uses: actions/checkout@v4
194 - name: Run format script
195 run: cargo format-fixtures
196 - name: Ensure no changes
197 run: |
198 if [ -z "$(git status --porcelain)" ]; then
199 echo "Fixtures formatted correctly"
200 else
201 git status && echo -e "\nTest fixtures are not formatted correctly. Please run 'cargo format-fixtures'"
202 exit 1
203 fi
204
205 benchmarks:
206 name: Build Benchmarks
207 runs-on: ubuntu-latest
208 steps:
209 - uses: actions/checkout@v4
210 - uses: dtolnay/rust-toolchain@stable
211 - run: cargo xbench --no-run
212 name: Build benchmarks
213 env:
214 RUSTFLAGS: "-C opt-level=0"
215
216 benchmarks-with-yoga:
217 name: Build Benchmarks (w/ yoga)
218 runs-on: ubuntu-latest
219 steps:
220 - uses: actions/checkout@v4
221 - uses: dtolnay/rust-toolchain@stable
222 - run: cargo xbench --no-run --features yoga
223 name: Build benchmarks (w/yoga)
224 env:
225 RUSTFLAGS: "-C opt-level=0"