From 9d22f4645336e1a3cb4475ad2eca93c23f46377a Mon Sep 17 00:00:00 2001 From: "Tom D." <15268361+anastygnome@users.noreply.github.com> Date: Mon, 9 Nov 2026 22:30:57 +0100 Subject: [PATCH] ci: optimize workflow caching --- .github/actions/rust-cache/action.yml | 52 +++++++ .github/workflows/CICD.yml | 169 ++++++++-------------- .github/workflows/CheckScripts.yml | 2 +- .github/workflows/FixPR.yml | 15 +- .github/workflows/GnuTests.yml | 21 ++- .github/workflows/android.yml | 10 +- .github/workflows/benchmarks.yml | 25 ++-- .github/workflows/check-toml.yml | 2 +- .github/workflows/code-quality.yml | 54 +++---- .github/workflows/copilot-code-review.yml | 7 +- .github/workflows/devcontainer.yml | 2 +- .github/workflows/documentation.yml | 8 +- .github/workflows/freebsd.yml | 3 +- .github/workflows/fuzzing.yml | 18 ++- .github/workflows/l10n.yml | 121 ++++------------ .github/workflows/make.yml | 85 +++-------- .github/workflows/manpage-lint.yml | 2 +- .github/workflows/openbsd.yml | 3 +- .github/workflows/wasi.yml | 7 +- .github/workflows/wsl2.yml | 2 +- 20 files changed, 267 insertions(+), 341 deletions(-) create mode 100644 .github/actions/rust-cache/action.yml diff --git a/.github/actions/rust-cache/action.yml b/.github/actions/rust-cache/action.yml new file mode 100644 index 00000000000..a7f0fd1b993 --- /dev/null +++ b/.github/actions/rust-cache/action.yml @@ -0,0 +1,52 @@ +# spell-checker:ignore Swatinem sccache +name: Rust cache +description: Cache Rust dependencies and enable sccache. + +inputs: + key: + description: Cache namespace for compatible jobs and target layouts. + required: false + default: "" + workspaces: + description: Cargo workspaces. + required: false + default: ". -> target" + cache-targets: + description: Cache target directories. + required: false + default: "true" + save-if: + description: Save the cache. + required: false + default: "true" + sccache: + description: Enable sccache. + required: false + default: "true" + +runs: + using: composite + steps: + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + # The workflow supplies an explicit namespace so compatible jobs can + # share a cache without accidentally mixing target directory layouts. + shared-key: ${{ inputs.key }} + workspaces: ${{ inputs.workspaces }} + cache-targets: ${{ inputs.cache-targets }} + save-if: ${{ inputs.save-if == 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + + - name: Setup sccache + id: sccache-setup + if: inputs.sccache == 'true' + uses: mozilla-actions/sccache-action@v0.0.11 + continue-on-error: true + + - name: Export sccache + if: inputs.sccache == 'true' && steps.sccache-setup.outcome == 'success' + shell: bash + run: | + echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" + echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV" + echo "SCCACHE_GHA_RW_MODE=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && 'READ_WRITE' || 'READ_ONLY' }}" >> "$GITHUB_ENV" diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 49b6ea177a4..df058ae89c0 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -30,7 +30,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: cargo-deny: @@ -48,6 +48,7 @@ jobs: runs-on: ${{ matrix.job.os }} strategy: fail-fast: false + max-parallel: 2 matrix: job: # note: `cargo-udeps` panics when processing stdbuf/libstdbuf ("uu_stdbuf_libstdbuf"); either b/c of the 'cpp' crate or 'libstdbuf' itself @@ -59,10 +60,11 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@cargo-udeps + - uses: ./.github/actions/rust-cache with: - tool: cargo-udeps - - uses: Swatinem/rust-cache@v2 + key: deps-${{ matrix.job.os }}-${{ matrix.job.features }} + sccache: false - name: Initialize workflow variables id: vars shell: bash @@ -110,16 +112,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: docs-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Install/setup prerequisites shell: bash run: | @@ -157,6 +152,7 @@ jobs: name: MinRustV # Minimum supported rust version (aka, MinSRV or MSRV) runs-on: ${{ matrix.job.os }} strategy: + max-parallel: 2 matrix: job: - { os: ubuntu-latest , features: feat_os_unix } @@ -170,19 +166,10 @@ jobs: with: toolchain: ${{ env.RUST_MIN_SRV }} components: rustfmt - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: msrv-${{ matrix.job.features }} - name: Initialize workflow variables id: vars shell: bash @@ -254,12 +241,7 @@ jobs: deps: name: Dependencies - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } + runs-on: ubuntu-latest steps: - uses: actions/checkout@v7.0.1 with: @@ -282,6 +264,7 @@ jobs: timeout-minutes: 90 strategy: fail-fast: false + max-parallel: 2 matrix: job: - { os: ubuntu-latest , name: feat_os_unix , features: feat_os_unix } @@ -294,19 +277,10 @@ jobs: with: persist-credentials: false - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: stable-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Test run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }} env: @@ -329,6 +303,7 @@ jobs: timeout-minutes: 90 strategy: fail-fast: false + max-parallel: 2 matrix: job: - { os: ubuntu-latest , features: feat_os_unix } @@ -339,19 +314,10 @@ jobs: with: persist-credentials: false - uses: dtolnay/rust-toolchain@nightly - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: nightly-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Test run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }} env: @@ -427,18 +393,11 @@ jobs: with: toolchain: ${{ env.RUST_MIN_SRV }} targets: ${{ matrix.job.target }} - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: - key: "${{ matrix.job.os }}_${{ matrix.job.target }}" - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + # These jobs pass --target explicitly, so keep their target/ + # cache separate from the implicit-host target/debug caches above. + key: build-${{ matrix.job.os }}-${{ matrix.job.target }}-${{ matrix.job.features }}-${{ matrix.job.default-features }}-${{ matrix.job.use-cross }} - name: Initialize workflow variables id: vars shell: bash @@ -744,16 +703,9 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: nextest,grcov@0.8.24 - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: coverage-${{ matrix.job.os }}-${{ matrix.job.features }} # - name: Reattach HEAD ## may be needed for accurate code coverage info # run: git checkout ${{ github.head_ref }} @@ -866,19 +818,10 @@ jobs: - uses: actions/checkout@v7 with: persist-credentials: false - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: openssl-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Test checksum utilities with OpenSSL (system / dynamic) shell: bash env: @@ -897,19 +840,10 @@ jobs: - uses: actions/checkout@v7 with: persist-credentials: false - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: no-diagnostics # The caret diagnostics (`feat_diagnostics`) are on by default; packagers # who want the smaller dependency tree build with them off, so that build # must stay green. The caret snapshot tests are gated on the feature and @@ -944,8 +878,9 @@ jobs: - name: Setup Lima uses: lima-vm/lima-actions/setup@v1 id: lima-actions-setup - - name: Cache ~/.cache/lima - uses: actions/cache@v6 + - name: Restore Lima cache + id: lima-cache + uses: actions/cache/restore@v6 with: path: ~/.cache/lima key: lima-${{ steps.lima-actions-setup.outputs.version }} @@ -963,6 +898,14 @@ jobs: run: | lima ls lima bash -c "cd work && cargo test --features 'feat_selinux' --no-default-features" + - name: Lint with SELinux + run: lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' --no-default-features -- -D warnings" + - name: Save Lima cache + if: steps.lima-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + uses: actions/cache/save@v6 + with: + path: ~/.cache/lima + key: lima-${{ steps.lima-actions-setup.outputs.version }} test_safe_traversal: name: Safe Traversal Security Check @@ -973,7 +916,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: safe-traversal + sccache: false - name: Install strace and libselinux headers (needed to build chcon) run: sudo apt-get update && sudo apt-get install -y strace libselinux1-dev - name: Build utilities with safe traversal @@ -990,7 +936,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: libc-interposition + sccache: false - name: Install fakeroot run: sudo apt-get update && sudo apt-get install -y fakeroot - name: Build utilities that must stay interposable @@ -1007,7 +956,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: open-once + sccache: false - name: Install strace run: sudo apt-get update && sudo apt-get install -y strace - name: Build utilities for redundant open checks @@ -1024,7 +976,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: toctou + sccache: false - name: Install strace run: sudo apt-get update && sudo apt-get install -y strace - name: Build utilities for TOCTOU checks diff --git a/.github/workflows/CheckScripts.yml b/.github/workflows/CheckScripts.yml index da5cf71f393..6803f2d753f 100644 --- a/.github/workflows/CheckScripts.yml +++ b/.github/workflows/CheckScripts.yml @@ -20,7 +20,7 @@ on: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: shell_check: diff --git a/.github/workflows/FixPR.yml b/.github/workflows/FixPR.yml index f767c75b061..7e7b89ab741 100644 --- a/.github/workflows/FixPR.yml +++ b/.github/workflows/FixPR.yml @@ -13,7 +13,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} on: # * only trigger on pull request closed to specific branches @@ -28,11 +28,7 @@ jobs: # Refresh dependencies (ie, 'Cargo.lock') and show updated dependency tree if: github.event.pull_request.merged == true ## only for PR merges name: Update/dependencies - runs-on: ${{ matrix.job.os }} - strategy: - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } + runs-on: ubuntu-latest steps: - uses: actions/checkout@v7.0.1 with: @@ -47,7 +43,10 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ steps.vars.outputs.RUST_MIN_SRV }} - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: fix-pr-msrv + sccache: false - name: Ensure updated 'Cargo.lock' shell: bash run: | @@ -75,7 +74,7 @@ jobs: echo "## dependency list" cargo fetch --locked --quiet --target $(rustc --print host-tuple) ## * using the 'stable' toolchain is necessary to avoid "unexpected '--filter-platform'" errors - cargo +stable tree --locked --no-dedupe -e=no-dev --prefix=none --features ${{ matrix.job.features }} | grep -vE "$PWD" | sort --unique + cargo +stable tree --locked --no-dedupe -e=no-dev --prefix=none --features feat_os_unix | grep -vE "$PWD" | sort --unique - name: Commit any changes (to '${{ env.BRANCH_TARGET }}') uses: EndBug/add-and-commit@v11 with: diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index 0c037688f5b..54695af2ce7 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -23,7 +23,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} env: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} @@ -48,9 +48,11 @@ jobs: with: path: 'uutils' persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./uutils/.github/actions/rust-cache with: workspaces: "./uutils -> target" + key: gnu-native + sccache: false - name: Checkout code (GNU coreutils) run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh) #### Build environment setup @@ -203,8 +205,9 @@ jobs: - name: Setup Lima uses: lima-vm/lima-actions/setup@v1 id: lima-actions-setup - - name: Cache ~/.cache/lima - uses: actions/cache@v6 + - name: Restore Lima cache + id: lima-cache + uses: actions/cache/restore@v6 with: path: ~/.cache/lima key: lima-${{ steps.lima-actions-setup.outputs.version }} @@ -296,6 +299,12 @@ jobs: path: | gnu/tests-selinux/*.log gnu/tests-selinux/*/*.log.gz + - name: Save Lima cache + if: steps.lima-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + uses: actions/cache/save@v6 + with: + path: ~/.cache/lima + key: lima-${{ steps.lima-actions-setup.outputs.version }} qemu: name: Run GNU tests (SMACK/ROOTFS) @@ -306,9 +315,11 @@ jobs: with: path: 'uutils' persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./uutils/.github/actions/rust-cache with: workspaces: "./uutils -> target" + key: gnu-qemu + sccache: false - name: Checkout code (GNU coreutils) run: (mkdir -p gnu && cd gnu && bash ../uutils/util/fetch-gnu.sh) - name: Install dependencies diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 49f8c724649..a4c9ecc92f2 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -17,7 +17,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} env: TERMUX: v0.118.0 @@ -141,7 +141,7 @@ jobs: script: | util/android-commands.sh init "${{ matrix.arch }}" "${{ matrix.api-level }}" "${{ env.TERMUX }}" - name: Save AVD cache - if: steps.avd-cache.outputs.cache-hit != 'true' + if: steps.avd-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) uses: actions/cache/save@v6 with: path: | @@ -161,9 +161,9 @@ jobs: uses: actions/cache/restore@v6 with: path: ~/__rust_cache__ - # The version vX at the end of the key is just a development version to avoid conflicts in - # the github cache during the development of this workflow key: ${{ matrix.arch }}_${{ matrix.target}}_${{ steps.read_rustc_hash.outputs.content }}_${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}_v3 + restore-keys: | + ${{ matrix.arch }}_${{ matrix.target}}_${{ steps.read_rustc_hash.outputs.content }}_ - name: Collect information about runner resources if: always() continue-on-error: true @@ -199,7 +199,7 @@ jobs: free -mh df -Th - name: Save rust cache - if: steps.rust-cache.outputs.cache-hit != 'true' + if: steps.rust-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) uses: actions/cache/save@v6 with: path: ~/__rust_cache__ diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 4a7b3a213a0..36e80ef87f7 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -11,6 +11,7 @@ on: - 'src/uucore_procs/**' - 'Cargo.toml' - 'Cargo.lock' + - '.github/actions/rust-cache/action.yml' push: branches: - main @@ -22,7 +23,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: detects-benchmarks: @@ -66,15 +67,15 @@ jobs: benchmarks: needs: detects-benchmarks if: needs.detects-benchmarks.outputs.package != '[]' - name: Run ${{ matrix.type }} benchmarks for ${{ matrix.package }} (CodSpeed) + # GitHub appends matrix values to expanded jobs but leaves skipped job + # names unevaluated, so keep the base name free of matrix expressions. + name: Run CodSpeed benchmarks runs-on: ubuntu-latest timeout-minutes: 90 env: CARGO_INCREMENTAL: 0 strategy: - # Stagger the jobs: 70 concurrent runners hitting the GitHub cache API - # (rust-cache + sccache + CodSpeed) at once triggers HTTP 429s. - max-parallel: 12 + max-parallel: 8 matrix: type: [simulation, memory] package: ${{ fromJson(needs.detects-benchmarks.outputs.package) }} @@ -83,17 +84,9 @@ jobs: with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: bench-${{ matrix.package }}-${{ matrix.type }} - name: Install locales shell: bash diff --git a/.github/workflows/check-toml.yml b/.github/workflows/check-toml.yml index 3f0d532c62c..01e99736607 100644 --- a/.github/workflows/check-toml.yml +++ b/.github/workflows/check-toml.yml @@ -17,7 +17,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: check: diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 344dd80dcc3..5c697b083f0 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -20,18 +20,13 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: style_format: name: Style/format - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } + runs-on: ubuntu-latest steps: - uses: actions/checkout@v7.0.1 with: @@ -72,6 +67,7 @@ jobs: WORKSPACE_ARG: ${{ matrix.job.workspace && '--workspace' || '' }} strategy: fail-fast: false + max-parallel: 4 matrix: job: - { os: ubuntu-latest , features: all , workspace: true , arg: "--all-targets -p uucore" } @@ -92,16 +88,21 @@ jobs: toolchain: stable components: clippy targets: ${{ matrix.job.target || '' }} - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' + - uses: ./.github/actions/rust-cache + with: + key: clippy-${{ matrix.job.os }}-${{ matrix.job.target || 'host' }}-${{ matrix.job.features }} + - name: Initialize workflow variables + id: vars + shell: bash run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + ## VARs setup + outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } + # failure mode + unset FAIL_ON_FAULT ; case "$STYLE_FAIL_ON_FAULT" in + ''|0|f|false|n|no|off) FAULT_TYPE=warning ;; + *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;; + esac; + outputs FAIL_ON_FAULT FAULT_TYPE - uses: mlugg/setup-zig@v2.2.1 if: matrix.job.cargo == 'cargo-zigbuild' - uses: taiki-e/install-action@cargo-zigbuild @@ -133,16 +134,12 @@ jobs: style_spellcheck: name: Style/spelling - runs-on: ${{ matrix.job.os }} + runs-on: ubuntu-latest env: # Spelling is enforced locally by the cspell pre-commit hook, where it is # cheap to fix. Here it is advisory: unknown words show up as annotations # on the diff instead of blocking the merge. STYLE_FAIL_ON_FAULT: false - strategy: - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } steps: - uses: actions/checkout@v7.0.1 with: @@ -226,14 +223,12 @@ jobs: with: persist-credentials: false - - name: Cache Rust dependencies - uses: Swatinem/rust-cache@v2 - - name: Install prek run: pip install prek - - name: Cache prek environments - uses: actions/cache@v6 + - name: Restore prek environments + id: prek-cache + uses: actions/cache/restore@v6 with: path: ~/.cache/prek key: prek-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} @@ -246,3 +241,10 @@ jobs: # hooks are already covered by the Style/format and Style/lint jobs. SKIP: cspell,rust-linting,rust-clippy,cargo-lock-check run: prek run --all-files --show-diff-on-failure + + - name: Save prek environments + if: steps.prek-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + uses: actions/cache/save@v6 + with: + path: ~/.cache/prek + key: prek-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} diff --git a/.github/workflows/copilot-code-review.yml b/.github/workflows/copilot-code-review.yml index f6c5fdb4966..251a744404d 100644 --- a/.github/workflows/copilot-code-review.yml +++ b/.github/workflows/copilot-code-review.yml @@ -1,4 +1,3 @@ -# spell-checker:ignore Swatinem name: Copilot Code Review # Declares the runner used by Copilot code review. Without this file, the @@ -8,6 +7,7 @@ on: pull_request: paths: - .github/workflows/copilot-code-review.yml + - .github/actions/rust-cache/action.yml permissions: contents: read @@ -20,4 +20,7 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache + with: + key: copilot + sccache: false diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 4c95a7f4389..fac3ad69491 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -14,7 +14,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: test: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 10f1c98aff3..fdba5d43ae0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -8,6 +8,7 @@ on: - 'src/bin/uudoc.rs' - 'src/uu/*/locales/en-US.ftl' - 'Cargo.toml' + - '.github/actions/rust-cache/action.yml' - '.github/workflows/documentation.yml' push: branches: @@ -16,6 +17,7 @@ on: - 'src/bin/uudoc.rs' - 'src/uu/*/locales/en-US.ftl' - 'Cargo.toml' + - '.github/actions/rust-cache/action.yml' permissions: contents: read @@ -23,7 +25,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: check-doc: @@ -36,6 +38,10 @@ jobs: with: persist-credentials: false + - uses: ./.github/actions/rust-cache + with: + key: documentation + - name: Install/setup prerequisites shell: bash run: sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml index bb0e906a736..c6958bb8622 100644 --- a/.github/workflows/freebsd.yml +++ b/.github/workflows/freebsd.yml @@ -18,7 +18,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: style: @@ -43,6 +43,7 @@ jobs: run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "SCCACHE_GHA_RW_MODE=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && 'READ_WRITE' || 'READ_ONLY' }}" >> $GITHUB_ENV - uses: mlugg/setup-zig@v2.2.1 - uses: taiki-e/install-action@v2 with: diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index 3d9f1b4c854..7e871ae7a58 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -16,6 +16,7 @@ on: - 'src/uucore_procs/**' - 'Cargo.toml' - 'Cargo.lock' + - '.github/actions/rust-cache/action.yml' - '.github/workflows/fuzzing.yml' push: branches: @@ -28,7 +29,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: detect: @@ -119,9 +120,11 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: workspaces: "fuzz -> target" + key: fuzz-examples + sccache: false - name: fetch gnu-coreutils .deb run: | curl -fsSL --retry 2 -o coreutils.deb ${GNU_COREUTILS_DEB_URL} @@ -166,9 +169,11 @@ jobs: uses: taiki-e/install-action@v2 with: tool: cargo-fuzz - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: workspaces: "fuzz -> target" + key: fuzz-build + sccache: false - name: Emulate a nightly toolchain run: | echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" @@ -188,7 +193,7 @@ jobs: strategy: fail-fast: false # Stagger the jobs: all the targets at once hammer the GitHub cache API. - max-parallel: 10 + max-parallel: 6 matrix: target: ${{ fromJson(needs.detect.outputs.targets) }} @@ -209,9 +214,12 @@ jobs: uses: taiki-e/install-action@v2 with: tool: cargo-fuzz - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: workspaces: "fuzz -> target" + key: fuzz-build + save-if: false + sccache: false - name: Emulate a nightly toolchain run: | echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}" diff --git a/.github/workflows/l10n.yml b/.github/workflows/l10n.yml index 9b5a7f40b1a..5d400c3b7ea 100644 --- a/.github/workflows/l10n.yml +++ b/.github/workflows/l10n.yml @@ -19,7 +19,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: @@ -28,6 +28,7 @@ jobs: runs-on: ${{ matrix.job.os }} strategy: fail-fast: false + max-parallel: 2 matrix: job: - { os: ubuntu-latest , features: "feat_os_unix" } @@ -37,19 +38,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + key: l10n-${{ github.job }}-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Install/setup prerequisites shell: bash run: | @@ -136,16 +128,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }} - name: Install/setup prerequisites shell: bash run: | @@ -299,16 +284,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }} - name: Install/setup prerequisites shell: bash run: | @@ -402,6 +380,7 @@ jobs: runs-on: ${{ matrix.job.os }} strategy: fail-fast: false + max-parallel: 2 matrix: job: - { os: ubuntu-latest , features: "cat,ls,touch" } @@ -410,16 +389,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }}-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Install/setup prerequisites shell: bash run: | @@ -556,6 +528,7 @@ jobs: runs-on: ${{ matrix.job.os }} strategy: fail-fast: false + max-parallel: 2 matrix: job: - { os: ubuntu-latest , features: "cat,ls,touch" } @@ -564,16 +537,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }}-${{ matrix.job.os }}-${{ matrix.job.features }} - name: Install/setup prerequisites shell: bash run: | @@ -895,16 +861,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }} - name: Install/setup prerequisites shell: bash run: | @@ -1127,16 +1086,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: l10n-${{ github.job }} - name: Install/setup prerequisites shell: bash run: | @@ -1153,10 +1105,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: - # Use different cache key for each build to avoid conflicts key: cat-locale-embedding + sccache: false - name: Install prerequisites run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev - name: Build cat with targeted locale embedding @@ -1184,10 +1136,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: - # Use different cache key for each build to avoid conflicts key: ls-locale-embedding + sccache: false - name: Install prerequisites run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev - name: Build ls with targeted locale embedding @@ -1215,10 +1167,10 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: - # Use different cache key for each build to avoid conflicts key: multicall-locale-embedding + sccache: false - name: Install prerequisites run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev - name: Build multicall binary with all locales @@ -1248,18 +1200,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: key: cargo-install-locale-embedding - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - name: Install prerequisites run: | sudo apt-get -y update diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index a63522b3e63..72e0faad221 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -28,7 +28,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: build_makefile: @@ -38,30 +38,16 @@ jobs: RUSTFLAGS: "-C force-unwind-tables=no -C strip=symbols -Clink-arg=-z -Clink-arg=pack-relative-relocs" permissions: contents: write # Publish individual binaries - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest , features: feat_os_unix } + runs-on: ubuntu-latest steps: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: taiki-e/install-action@v2 + - uses: taiki-e/install-action@nextest + - uses: ./.github/actions/rust-cache with: - tool: nextest - - uses: Swatinem/rust-cache@v2 + key: make-linux # Test build on the system missing libselinux (don't install libselinux1-dev at here) - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - name: "`make build`" # Also check that target/CACHEDIR.TAG is created on a fresh checkout shell: bash @@ -270,29 +256,18 @@ jobs: name: Build MSYS permissions: contents: write # Publish cygwin binary - runs-on: ${{ matrix.job.os }} + runs-on: windows-latest env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-C link-arg=-Wl,--dynamicbase -C link-arg=-Wl,--enable-auto-image-base" - strategy: - fail-fast: false - matrix: - job: - - { os: windows-latest , features: feat_os_windows } steps: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: make-msys + sccache: false - name: Disable Mandatory ASLR (required for Cygwin/MSYS2 bash on GitHub runners) shell: powershell run: | @@ -379,12 +354,7 @@ jobs: test_busybox: name: Tests/BusyBox test suite - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest } + runs-on: ubuntu-latest steps: - name: Initialize workflow variables id: vars @@ -395,16 +365,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: busybox - name: Install/setup prerequisites shell: bash run: | @@ -463,12 +426,7 @@ jobs: test_toybox: name: Tests/Toybox test suite - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - job: - - { os: ubuntu-latest } + runs-on: ubuntu-latest steps: - name: Initialize workflow variables id: vars @@ -481,16 +439,9 @@ jobs: - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: Swatinem/rust-cache@v2 - - name: Run sccache-cache - id: sccache-setup - uses: mozilla-actions/sccache-action@v0.0.11 - continue-on-error: true - - name: Export sccache - if: steps.sccache-setup.outcome == 'success' - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - uses: ./.github/actions/rust-cache + with: + key: toybox - name: Install/setup prerequisites shell: bash run: | diff --git a/.github/workflows/manpage-lint.yml b/.github/workflows/manpage-lint.yml index 7825ca32038..c34095ca69d 100644 --- a/.github/workflows/manpage-lint.yml +++ b/.github/workflows/manpage-lint.yml @@ -28,7 +28,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: manpage-lint: diff --git a/.github/workflows/openbsd.yml b/.github/workflows/openbsd.yml index 40d9e96614a..b562eb0c782 100644 --- a/.github/workflows/openbsd.yml +++ b/.github/workflows/openbsd.yml @@ -21,7 +21,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: clippy_test_zig: @@ -48,6 +48,7 @@ jobs: run: | echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + echo "SCCACHE_GHA_RW_MODE=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && 'READ_WRITE' || 'READ_ONLY' }}" >> $GITHUB_ENV - uses: mlugg/setup-zig@v2.2.1 - uses: taiki-e/install-action@v2 with: diff --git a/.github/workflows/wasi.yml b/.github/workflows/wasi.yml index bbafa7178d9..8f4de592f8f 100644 --- a/.github/workflows/wasi.yml +++ b/.github/workflows/wasi.yml @@ -14,7 +14,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: test_wasi: @@ -33,9 +33,10 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.job.target }} - - uses: Swatinem/rust-cache@v2 + - uses: ./.github/actions/rust-cache with: - key: "${{ matrix.job.target }}" + key: wasi-${{ matrix.job.target }} + sccache: false - name: Install wasmtime uses: taiki-e/install-action@v2 with: diff --git a/.github/workflows/wsl2.yml b/.github/workflows/wsl2.yml index 10b3db822f2..972fa13c34f 100644 --- a/.github/workflows/wsl2.yml +++ b/.github/workflows/wsl2.yml @@ -14,7 +14,7 @@ permissions: # End the current execution if there is a new changeset in the PR. concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} jobs: test: