From ebaca480a129343cd1a26b647a52d28d8bd7bc62 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 28 Oct 2024 11:25:31 -0700 Subject: [PATCH] Better caching in CI (#3127) * merge nix, better caching * use faster runner for playwright --- .github/workflows/main.yml | 122 ++++++++++++++++++++----------------- .github/workflows/nix.yml | 43 ------------- Cargo.toml | 1 + Makefile.toml | 27 -------- 4 files changed, 66 insertions(+), 127 deletions(-) delete mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a347b1f18..908258063 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ concurrency: env: CARGO_TERM_COLOR: always - CARGO_INCREMENTAL: "0" + CARGO_INCREMENTAL: "1" RUST_BACKTRACE: 1 rust_nightly: nightly-2024-10-20 @@ -52,7 +52,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + 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 @@ -82,7 +82,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - uses: davidB/rust-cargo-make@v1 - uses: browser-actions/setup-firefox@latest - uses: jetli/wasm-pack-action@v0.4.0 @@ -94,22 +94,22 @@ jobs: runs-on: ubuntu-latest 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 - 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" - save-if: ${{ github.ref == 'refs/heads/main' }} + 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 fmt: @@ -124,7 +124,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - run: cargo fmt --all -- --check typos: @@ -151,7 +151,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - name: "doc --lib --all-features" run: | cargo doc --workspace --no-deps --all-features --document-private-items @@ -193,7 +193,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - run: cargo check --workspace --all-features --all-targets clippy: @@ -210,40 +210,29 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings - # 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 - # likely make future backporting difficult - # - # todo: fix this so even if breaking changes have been merged, the fix can be backported - # - # This will stop working once the first breaking change has been merged, so we should really try to just backport the fix - # and *then* run the semver checks. Basically "would backporting this PR cause a breaking change on stable?" - # - # semver: - # if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'breaking') - # name: Semver Check - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: dtolnay/rust-toolchain@stable - # - uses: Swatinem/rust-cache@v2 - # with: - # cache-all-crates: "true" - # save-if: ${{ github.ref == 'refs/heads/main' }} - # - name: Check semver - # uses: obi1kenobi/cargo-semver-checks-action@v2 - # with: - # manifest-path: ./Cargo.toml - # exclude: "dioxus-cli, dioxus-ext" + nix: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Install omnix + run: nix --accept-flake-config profile install "github:juspay/omnix" + - name: Build all flake outputs + run: om ci + - name: Ensure devShell has all build deps + run: nix develop -c cargo build -p dioxus-cli playwright: if: github.event.pull_request.draft == false name: Playwright Tests - runs-on: ubuntu-latest + runs-on: macos-latest steps: # Do our best to cache the toolchain and node install steps - uses: actions/checkout@v4 @@ -264,23 +253,15 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - - name: Install dependencies - run: npm ci - working-directory: ./packages/playwright-tests - - - name: Install Playwright - run: npm install -D @playwright/test - working-directory: ./packages/playwright-tests - - - name: Install Playwright Browsers - run: npx playwright install --with-deps - working-directory: ./packages/playwright-tests - - - name: Run Playwright tests - run: npx playwright test + - name: Playwright working-directory: ./packages/playwright-tests + run: | + npm ci + npm install -D @playwright/test + npx playwright install --with-deps + npx playwright test - uses: actions/upload-artifact@v4 if: always() @@ -367,8 +348,35 @@ jobs: with: key: "${{ matrix.platform.target }}" cache-all-crates: "true" - save-if: ${{ github.ref == 'refs/heads/main' }} + cache-on-failure: "true" - name: test run: | ${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }} + + # 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 + # likely make future backporting difficult + # + # todo: fix this so even if breaking changes have been merged, the fix can be backported + # + # This will stop working once the first breaking change has been merged, so we should really try to just backport the fix + # and *then* run the semver checks. Basically "would backporting this PR cause a breaking change on stable?" + # + # semver: + # if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'breaking') + # name: Semver Check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: dtolnay/rust-toolchain@stable + # - uses: Swatinem/rust-cache@v2 + # with: + # cache-all-crates: "true" + # cache-on-failure: "true" + # - name: Check semver + # uses: obi1kenobi/cargo-semver-checks-action@v2 + # with: + # manifest-path: ./Cargo.toml + # exclude: "dioxus-cli, dioxus-ext" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml deleted file mode 100644 index 13ae7de10..000000000 --- a/.github/workflows/nix.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: "Nix CI" - -on: - push: - branches: - - main - paths: - - packages/** - - examples/** - - docs/guide/** - - src/** - - .github/** - - lib.rs - - Cargo.toml - - Makefile.toml - - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: - - main - paths: - - packages/** - - examples/** - - src/** - - .github/** - - lib.rs - - Cargo.toml -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Install omnix - run: nix --accept-flake-config profile install "github:juspay/omnix" - - name: Build all flake outputs - run: om ci - - name: Ensure devShell has all build deps - run: nix develop -c cargo build -p dioxus-cli diff --git a/Cargo.toml b/Cargo.toml index 6618fe6b8..15ce27981 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -245,6 +245,7 @@ debug = 0 [profile.release-unoptimized] inherits = "dev" debug-assertions = false +incremental = true # This is a "virtual package" # It is not meant to be published, but is used so "cargo run --example XYZ" works properly diff --git a/Makefile.toml b/Makefile.toml index 8f175d760..64f26bd2f 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -49,33 +49,6 @@ category = "Formatting" dependencies = ["format", "check", "clippy"] description = "Format and Check workspace" -[tasks.install-miri] -toolchain = "nightly" -install_crate = { rustup_component_name = "miri", binary = "cargo +nightly miri", test_arg = "--help" } -private = true - -[tasks.miri-native] -command = "cargo" -toolchain = "nightly" -dependencies = ["install-miri"] -args = [ - "miri", - "test", - "--package", - "dioxus-native-core", - "--test", - "miri_native", -] - -[tasks.miri-stress] -command = "cargo" -toolchain = "nightly" -dependencies = ["install-miri"] -args = ["miri", "test", "--package", "dioxus-core", "--test", "miri_stress"] - -[tasks.miri] -dependencies = ["miri-native", "miri-stress"] - [tasks.tests] category = "Testing" dependencies = ["tests-setup"]