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