Skip to content

Commit 1cbfcde

Browse files
authored
improve build times by extracting asset opt into its own crate (#3273)
* improve build types by extracing asset opt as a dylib * dont use dylib, but let regular workspace caching do the heavy lifting * add prebuild to cli for better lock contention * hoist deps * disable slow tests * re-enable sequential, debug=0 for dev * use vfs for windows * dont cache on failure, fix windows vfs caceh * free disk space re-order * add clippy + fmt to windows channel * yoink makefile * proper rustfmt/clippy on toolchain * set incremental to zero since cargo-cache disables it
1 parent 79a2f02 commit 1cbfcde

File tree

25 files changed

+608
-612
lines changed

25 files changed

+608
-612
lines changed

.docker/Dockerfile_test

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM dioxus-pre-test
33
RUN mkdir run_test
44
COPY tmp /run_test
55
WORKDIR /run_test
6-
RUN cargo make tests
6+
RUN cargo test --workspace --tests
77
RUN cargo cache -a
88

99
CMD ["exit"]

.github/workflows/main.yml

+63-44
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ concurrency:
3737

3838
env:
3939
CARGO_TERM_COLOR: always
40-
CARGO_INCREMENTAL: "1"
40+
CARGO_INCREMENTAL: 0 # todo(jon): cargo-cache wipes incremental artifacts, but we eventually want to cache them
4141
RUST_BACKTRACE: 1
4242
rust_nightly: nightly-2024-10-20
4343

@@ -48,11 +48,10 @@ jobs:
4848
runs-on: ubuntu-latest
4949
steps:
5050
- uses: actions/checkout@v4
51-
- uses: dtolnay/rust-toolchain@stable
51+
- uses: dtolnay/rust-toolchain@1.79.0
5252
- uses: Swatinem/rust-cache@v2
5353
with:
5454
cache-all-crates: "true"
55-
cache-on-failure: "true"
5655
# https://github.com/foresterre/cargo-msrv/blob/4345edfe3f4fc91cc8ae6c7d6804c0748fae92ae/.github/workflows/msrv.yml
5756
- name: install_cargo_msrv
5857
run: cargo install cargo-msrv --all-features
@@ -78,53 +77,50 @@ jobs:
7877
swap-storage: false
7978
- run: sudo apt-get update
8079
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
81-
- uses: dtolnay/rust-toolchain@stable
80+
- uses: dtolnay/[email protected]
81+
with:
82+
components: rustfmt, clippy
8283
- uses: Swatinem/rust-cache@v2
8384
with:
8485
cache-all-crates: "true"
85-
cache-on-failure: "true"
86-
- uses: davidB/rust-cargo-make@v1
8786
- uses: browser-actions/setup-firefox@latest
88-
- uses: jetli/[email protected]
89-
- run: cargo make tests
87+
- run: cargo test --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile
9088

9189
release-test:
9290
if: github.event.pull_request.draft == false
9391
name: Test Suite with Optimizations
9492
runs-on: ubuntu-latest
9593
steps:
9694
- uses: actions/checkout@v4
97-
- run: sudo apt-get update
98-
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
99-
- uses: dtolnay/rust-toolchain@stable
100-
- uses: Swatinem/rust-cache@v2
101-
with:
102-
cache-all-crates: "true"
103-
cache-on-failure: "true"
104-
- uses: davidB/rust-cargo-make@v1
105-
- uses: browser-actions/setup-firefox@latest
106-
- uses: jetli/[email protected]
10795
- name: Free Disk Space (Ubuntu)
10896
uses: jlumbroso/[email protected]
10997
with: # speed things up a bit
11098
large-packages: false
11199
docker-images: false
112100
swap-storage: false
113-
- run: cargo test --profile release-unoptimized --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile
101+
- run: sudo apt-get update
102+
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
103+
- uses: dtolnay/[email protected]
104+
with:
105+
components: rustfmt, clippy
106+
- uses: Swatinem/rust-cache@v2
107+
with:
108+
cache-all-crates: "true"
109+
- uses: browser-actions/setup-firefox@latest
110+
- run: cargo test --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile --profile release-unoptimized
114111

115112
fmt:
116113
if: github.event.pull_request.draft == false
117114
name: Rustfmt
118115
runs-on: ubuntu-latest
119116
steps:
120117
- uses: actions/checkout@v4
121-
- uses: dtolnay/rust-toolchain@stable
118+
- uses: dtolnay/rust-toolchain@1.79.0
122119
with:
123120
components: rustfmt
124121
- uses: Swatinem/rust-cache@v2
125122
with:
126123
cache-all-crates: "true"
127-
cache-on-failure: "true"
128124
- run: cargo fmt --all -- --check
129125

130126
typos:
@@ -151,7 +147,6 @@ jobs:
151147
- uses: Swatinem/rust-cache@v2
152148
with:
153149
cache-all-crates: "true"
154-
cache-on-failure: "true"
155150
- name: "doc --lib --all-features"
156151
run: |
157152
cargo doc --workspace --no-deps --all-features --document-private-items
@@ -189,11 +184,10 @@ jobs:
189184
- uses: actions/checkout@v4
190185
- run: sudo apt-get update
191186
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
192-
- uses: dtolnay/rust-toolchain@stable
187+
- uses: dtolnay/rust-toolchain@1.79.0
193188
- uses: Swatinem/rust-cache@v2
194189
with:
195190
cache-all-crates: "true"
196-
cache-on-failure: "true"
197191
- run: cargo check --workspace --all-features --all-targets
198192

199193
clippy:
@@ -204,13 +198,12 @@ jobs:
204198
- uses: actions/checkout@v4
205199
- run: sudo apt-get update
206200
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
207-
- uses: dtolnay/rust-toolchain@stable
201+
- uses: dtolnay/rust-toolchain@1.79.0
208202
with:
209203
components: rustfmt, clippy
210204
- uses: Swatinem/rust-cache@v2
211205
with:
212206
cache-all-crates: "true"
213-
cache-on-failure: "true"
214207
- run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings
215208

216209
nix:
@@ -237,6 +230,12 @@ jobs:
237230
steps:
238231
# Do our best to cache the toolchain and node install steps
239232
- uses: actions/checkout@v4
233+
- name: Free Disk Space (Ubuntu)
234+
uses: jlumbroso/[email protected]
235+
with: # speed things up a bit
236+
large-packages: false
237+
docker-images: false
238+
swap-storage: false
240239
- uses: actions/setup-node@v4
241240
with:
242241
node-version: 16
@@ -248,13 +247,9 @@ jobs:
248247
- uses: Swatinem/rust-cache@v2
249248
with:
250249
cache-all-crates: "true"
251-
cache-on-failure: "true"
252-
- name: Free Disk Space (Ubuntu)
253-
uses: jlumbroso/[email protected]
254-
with: # speed things up a bit
255-
large-packages: false
256-
docker-images: false
257-
swap-storage: false
250+
- name: Prebuild CLI
251+
run: |
252+
cargo build --package dioxus-cli --release
258253
- name: Playwright
259254
working-directory: ./packages/playwright-tests
260255
run: |
@@ -277,14 +272,6 @@ jobs:
277272
strategy:
278273
matrix:
279274
platform:
280-
- {
281-
target: x86_64-pc-windows-msvc,
282-
os: windows-latest,
283-
toolchain: "1.79.0",
284-
cross: false,
285-
command: "test",
286-
args: "--all --tests",
287-
}
288275
- {
289276
target: aarch64-apple-darwin,
290277
os: macos-latest,
@@ -340,19 +327,51 @@ jobs:
340327

341328
- name: Install cross
342329
if: ${{ matrix.platform.cross == true }}
343-
344330
uses: taiki-e/install-action@cross
345331

346332
- uses: Swatinem/rust-cache@v2
347333
with:
348334
key: "matrix-${{ matrix.platform.target }}"
349335
cache-all-crates: "true"
350-
cache-on-failure: "true"
351336

352337
- name: test
353338
run: |
354339
${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
355340
341+
# borrowed from uv
342+
# https://raw.githubusercontent.com/astral-sh/uv/refs/heads/main/.github/workflows/ci.yml
343+
cargo-test-windows:
344+
if: github.event.pull_request.draft == false
345+
runs-on:
346+
labels: "windows-latest"
347+
name: "cargo test | windows"
348+
steps:
349+
- uses: actions/checkout@v4
350+
- name: Create Dev Drive using ReFS
351+
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
352+
353+
# actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
354+
- name: Copy Git Repo to Dev Drive
355+
run: |
356+
Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.UV_WORKSPACE }}" -Recurse
357+
358+
- uses: dtolnay/[email protected]
359+
with:
360+
components: rustfmt, clippy
361+
- uses: Swatinem/rust-cache@v2
362+
with:
363+
workspaces: ${{ env.UV_WORKSPACE }}
364+
cache-all-crates: "true"
365+
366+
- name: "Install Rust toolchain"
367+
working-directory: ${{ env.UV_WORKSPACE }}
368+
run: rustup show
369+
370+
- name: "Cargo test"
371+
working-directory: ${{ env.UV_WORKSPACE }}
372+
run: |
373+
cargo test --workspace --tests
374+
356375
# Only run semver checks if the PR is not a draft and does not have the breaking label
357376
# Breaking PRs don't need to follow semver since they are breaking changes
358377
# However, this means we won't attempt to backport them, so you should be careful about using this label, as it will
@@ -369,7 +388,7 @@ jobs:
369388
# runs-on: ubuntu-latest
370389
# steps:
371390
# - uses: actions/checkout@v4
372-
# - uses: dtolnay/rust-toolchain@stable
391+
# - uses: dtolnay/rust-toolchain@1.79.0
373392
# - uses: Swatinem/rust-cache@v2
374393
# with:
375394
# cache-all-crates: "true"

.github/workflows/setup-dev-drive.ps1

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This creates a 20GB dev drive, and exports all required environment
2+
# variables so that rustup, uv and others all use the dev drive as much
3+
# as possible.
4+
$Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 20GB |
5+
Mount-VHD -Passthru |
6+
Initialize-Disk -Passthru |
7+
New-Partition -AssignDriveLetter -UseMaximumSize |
8+
Format-Volume -FileSystem ReFS -Confirm:$false -Force
9+
10+
Write-Output $Volume
11+
12+
$Drive = "$($Volume.DriveLetter):"
13+
$Tmp = "$($Drive)/uv-tmp"
14+
15+
# Create the directory ahead of time in an attempt to avoid race-conditions
16+
New-Item $Tmp -ItemType Directory
17+
18+
Write-Output `
19+
"DEV_DRIVE=$($Drive)" `
20+
"TMP=$($Tmp)" `
21+
"TEMP=$($Tmp)" `
22+
"RUSTUP_HOME=$($Drive)/.rustup" `
23+
"CARGO_HOME=$($Drive)/.cargo" `
24+
"UV_WORKSPACE=$($Drive)/uv" `
25+
>> $env:GITHUB_ENV

Cargo.lock

+49-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)