Skip to content

Commit

Permalink
improve build times by extracting asset opt into its own crate (#3273)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jkelleyrtp authored Dec 3, 2024
1 parent 79a2f02 commit 1cbfcde
Show file tree
Hide file tree
Showing 25 changed files with 608 additions and 612 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile_test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM dioxus-pre-test
RUN mkdir run_test
COPY tmp /run_test
WORKDIR /run_test
RUN cargo make tests
RUN cargo test --workspace --tests
RUN cargo cache -a

CMD ["exit"]
107 changes: 63 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ concurrency:

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

Expand All @@ -48,11 +48,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.79.0
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
# https://github.com/foresterre/cargo-msrv/blob/4345edfe3f4fc91cc8ae6c7d6804c0748fae92ae/.github/workflows/msrv.yml
- name: install_cargo_msrv
run: cargo install cargo-msrv --all-features
Expand All @@ -78,53 +77,50 @@ jobs:
swap-storage: false
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.79.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- uses: davidB/rust-cargo-make@v1
- uses: browser-actions/setup-firefox@latest
- uses: jetli/wasm-pack-action@v0.4.0
- run: cargo make tests
- run: cargo test --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile

release-test:
if: github.event.pull_request.draft == false
name: Test Suite with Optimizations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- uses: davidB/rust-cargo-make@v1
- uses: browser-actions/setup-firefox@latest
- uses: jetli/wasm-pack-action@v0.4.0
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
- run: cargo test --profile release-unoptimized --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@1.79.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
- uses: browser-actions/setup-firefox@latest
- run: cargo test --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile --profile release-unoptimized

fmt:
if: github.event.pull_request.draft == false
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.79.0
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- run: cargo fmt --all -- --check

typos:
Expand All @@ -151,7 +147,6 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- name: "doc --lib --all-features"
run: |
cargo doc --workspace --no-deps --all-features --document-private-items
Expand Down Expand Up @@ -189,11 +184,10 @@ jobs:
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.79.0
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- run: cargo check --workspace --all-features --all-targets

clippy:
Expand All @@ -204,13 +198,12 @@ jobs:
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.79.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings

nix:
Expand All @@ -237,6 +230,12 @@ jobs:
steps:
# Do our best to cache the toolchain and node install steps
- uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/setup-node@v4
with:
node-version: 16
Expand All @@ -248,13 +247,9 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
cache-on-failure: "true"
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with: # speed things up a bit
large-packages: false
docker-images: false
swap-storage: false
- name: Prebuild CLI
run: |
cargo build --package dioxus-cli --release
- name: Playwright
working-directory: ./packages/playwright-tests
run: |
Expand All @@ -277,14 +272,6 @@ jobs:
strategy:
matrix:
platform:
- {
target: x86_64-pc-windows-msvc,
os: windows-latest,
toolchain: "1.79.0",
cross: false,
command: "test",
args: "--all --tests",
}
- {
target: aarch64-apple-darwin,
os: macos-latest,
Expand Down Expand Up @@ -340,19 +327,51 @@ jobs:

- name: Install cross
if: ${{ matrix.platform.cross == true }}

uses: taiki-e/install-action@cross

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

- name: test
run: |
${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }}
# borrowed from uv
# https://raw.githubusercontent.com/astral-sh/uv/refs/heads/main/.github/workflows/ci.yml
cargo-test-windows:
if: github.event.pull_request.draft == false
runs-on:
labels: "windows-latest"
name: "cargo test | windows"
steps:
- uses: actions/checkout@v4
- name: Create Dev Drive using ReFS
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1

# actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
- name: Copy Git Repo to Dev Drive
run: |
Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.UV_WORKSPACE }}" -Recurse
- uses: dtolnay/rust-toolchain@1.79.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.UV_WORKSPACE }}
cache-all-crates: "true"

- name: "Install Rust toolchain"
working-directory: ${{ env.UV_WORKSPACE }}
run: rustup show

- name: "Cargo test"
working-directory: ${{ env.UV_WORKSPACE }}
run: |
cargo test --workspace --tests
# Only run semver checks if the PR is not a draft and does not have the breaking label
# Breaking PRs don't need to follow semver since they are breaking changes
# However, this means we won't attempt to backport them, so you should be careful about using this label, as it will
Expand All @@ -369,7 +388,7 @@ jobs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: dtolnay/rust-toolchain@1.79.0
# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: "true"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/setup-dev-drive.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This creates a 20GB dev drive, and exports all required environment
# variables so that rustup, uv and others all use the dev drive as much
# as possible.
$Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 20GB |
Mount-VHD -Passthru |
Initialize-Disk -Passthru |
New-Partition -AssignDriveLetter -UseMaximumSize |
Format-Volume -FileSystem ReFS -Confirm:$false -Force

Write-Output $Volume

$Drive = "$($Volume.DriveLetter):"
$Tmp = "$($Drive)/uv-tmp"

# Create the directory ahead of time in an attempt to avoid race-conditions
New-Item $Tmp -ItemType Directory

Write-Output `
"DEV_DRIVE=$($Drive)" `
"TMP=$($Tmp)" `
"TEMP=$($Tmp)" `
"RUSTUP_HOME=$($Drive)/.rustup" `
"CARGO_HOME=$($Drive)/.cargo" `
"UV_WORKSPACE=$($Drive)/uv" `
>> $env:GITHUB_ENV
83 changes: 49 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1cbfcde

Please sign in to comment.