浏览代码

Better caching in CI (#3127)

* merge nix, better caching

* use faster runner  for playwright
Jonathan Kelley 8 月之前
父节点
当前提交
ebaca480a1
共有 4 个文件被更改,包括 66 次插入127 次删除
  1. 65 57
      .github/workflows/main.yml
  2. 0 43
      .github/workflows/nix.yml
  3. 1 0
      Cargo.toml
  4. 0 27
      Makefile.toml

+ 65 - 57
.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' }}
-
-      - 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
+          cache-on-failure: "true"
 
-      - 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"

+ 0 - 43
.github/workflows/nix.yml

@@ -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

+ 1 - 0
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

+ 0 - 27
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"]