Better caching in CI (#3127)

* merge nix, better caching

* use faster runner  for playwright
This commit is contained in:
Jonathan Kelley 2024-10-28 11:25:31 -07:00 committed by GitHub
parent 8a0eca1c8a
commit ebaca480a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 127 deletions

View file

@ -37,7 +37,7 @@ concurrency:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0" CARGO_INCREMENTAL: "1"
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
rust_nightly: nightly-2024-10-20 rust_nightly: nightly-2024-10-20
@ -52,7 +52,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" 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 # https://github.com/foresterre/cargo-msrv/blob/4345edfe3f4fc91cc8ae6c7d6804c0748fae92ae/.github/workflows/msrv.yml
- name: install_cargo_msrv - name: install_cargo_msrv
run: cargo install cargo-msrv --all-features run: cargo install cargo-msrv --all-features
@ -82,7 +82,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- uses: davidB/rust-cargo-make@v1 - uses: davidB/rust-cargo-make@v1
- uses: browser-actions/setup-firefox@latest - uses: browser-actions/setup-firefox@latest
- uses: jetli/wasm-pack-action@v0.4.0 - uses: jetli/wasm-pack-action@v0.4.0
@ -94,22 +94,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - 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-get update
- run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev - 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@stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- uses: davidB/rust-cargo-make@v1 - uses: davidB/rust-cargo-make@v1
- uses: browser-actions/setup-firefox@latest - uses: browser-actions/setup-firefox@latest
- uses: jetli/wasm-pack-action@v0.4.0 - 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: cargo test --profile release-unoptimized --lib --bins --tests --examples --workspace --exclude dioxus-desktop --exclude dioxus-mobile
fmt: fmt:
@ -124,7 +124,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- run: cargo fmt --all -- --check - run: cargo fmt --all -- --check
typos: typos:
@ -151,7 +151,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- name: "doc --lib --all-features" - name: "doc --lib --all-features"
run: | run: |
cargo doc --workspace --no-deps --all-features --document-private-items cargo doc --workspace --no-deps --all-features --document-private-items
@ -193,7 +193,7 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- run: cargo check --workspace --all-features --all-targets - run: cargo check --workspace --all-features --all-targets
clippy: clippy:
@ -210,40 +210,29 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" 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 - 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 nix:
# Breaking PRs don't need to follow semver since they are breaking changes runs-on: ${{ matrix.os }}
# However, this means we won't attempt to backport them, so you should be careful about using this label, as it will strategy:
# likely make future backporting difficult matrix:
# os: [ubuntu-latest, macos-latest]
# todo: fix this so even if breaking changes have been merged, the fix can be backported steps:
# - uses: actions/checkout@v4
# This will stop working once the first breaking change has been merged, so we should really try to just backport the fix - uses: DeterminateSystems/nix-installer-action@main
# and *then* run the semver checks. Basically "would backporting this PR cause a breaking change on stable?" - uses: DeterminateSystems/magic-nix-cache-action@main
# - name: Install omnix
# semver: run: nix --accept-flake-config profile install "github:juspay/omnix"
# if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'breaking') - name: Build all flake outputs
# name: Semver Check run: om ci
# runs-on: ubuntu-latest - name: Ensure devShell has all build deps
# steps: run: nix develop -c cargo build -p dioxus-cli
# - 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"
playwright: playwright:
if: github.event.pull_request.draft == false if: github.event.pull_request.draft == false
name: Playwright Tests name: Playwright Tests
runs-on: ubuntu-latest runs-on: macos-latest
steps: steps:
# Do our best to cache the toolchain and node install steps # Do our best to cache the toolchain and node install steps
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -264,23 +253,15 @@ jobs:
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- name: Install dependencies - name: Playwright
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
working-directory: ./packages/playwright-tests 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 - uses: actions/upload-artifact@v4
if: always() if: always()
@ -367,8 +348,35 @@ jobs:
with: with:
key: "${{ matrix.platform.target }}" key: "${{ matrix.platform.target }}"
cache-all-crates: "true" cache-all-crates: "true"
save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: "true"
- name: test - name: test
run: | run: |
${{ env.RUST_CARGO_COMMAND }} ${{ matrix.platform.command }} ${{ matrix.platform.args }} --target ${{ matrix.platform.target }} ${{ 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"

View file

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

View file

@ -245,6 +245,7 @@ debug = 0
[profile.release-unoptimized] [profile.release-unoptimized]
inherits = "dev" inherits = "dev"
debug-assertions = false debug-assertions = false
incremental = true
# This is a "virtual package" # This is a "virtual package"
# It is not meant to be published, but is used so "cargo run --example XYZ" works properly # It is not meant to be published, but is used so "cargo run --example XYZ" works properly

View file

@ -49,33 +49,6 @@ category = "Formatting"
dependencies = ["format", "check", "clippy"] dependencies = ["format", "check", "clippy"]
description = "Format and Check workspace" 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] [tasks.tests]
category = "Testing" category = "Testing"
dependencies = ["tests-setup"] dependencies = ["tests-setup"]