diff --git a/.github/workflows/binstall.yml b/.github/workflows/binstall.yml new file mode 100644 index 0000000..ceba95c --- /dev/null +++ b/.github/workflows/binstall.yml @@ -0,0 +1,34 @@ +name: binstall + +on: [push, pull_request] + +permissions: {} + +jobs: + binstall: + if: github.repository == 'Swatinem/rust-cache' + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + name: Test `cargo binstall` on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + env: + CARGO_TERM_COLOR: always + + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + persist-credentials: false + + - run: rustup toolchain install stable --profile minimal --no-self-update + + - uses: cargo-bins/cargo-binstall@v1.19.1 + + - uses: ./ + + - run: cargo binstall -y cargo-deny + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index b69def8..4b0b850 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -18,12 +18,12 @@ jobs: if: github.repository == 'Swatinem/rust-cache' runs-on: ubuntu-latest steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false - name: Setup Node.js 24.x - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24.x cache: npm @@ -43,7 +43,7 @@ jobs: fi id: diff - - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: name: dist diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dfae6cc..42e5c00 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -19,13 +19,13 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false - run: rustup toolchain install stable --profile minimal --component llvm-tools-preview --no-self-update - - uses: taiki-e/install-action@64c5c20c872907b6f7cd50994ac189e7274160f2 # v2.68.26 + - uses: taiki-e/install-action@25435dc8dd3baed7417e0c96d3fe89013a5b2e09 # v2.81.3 with: tool: cargo-llvm-cov diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 2d40521..56a4f19 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -15,10 +15,10 @@ jobs: steps: - name: Fetch metadata id: metadata - uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0 + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: fetch-depth: 2 persist-credentials: false @@ -37,7 +37,7 @@ jobs: fi - name: Setup node if necessary if: steps.npm.outputs.changed != '' - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24.x cache: npm diff --git a/.github/workflows/git-registry.yml b/.github/workflows/git-registry.yml index dd3ca9c..5085e89 100644 --- a/.github/workflows/git-registry.yml +++ b/.github/workflows/git-registry.yml @@ -20,7 +20,7 @@ jobs: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 10c7e78..3c0991c 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -19,7 +19,7 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/multi-job-cache.yml b/.github/workflows/multi-job-cache.yml index 278e354..2e086ba 100644 --- a/.github/workflows/multi-job-cache.yml +++ b/.github/workflows/multi-job-cache.yml @@ -20,7 +20,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false @@ -54,7 +54,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 00897ec..e13b7a4 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -16,11 +16,11 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false - - uses: cachix/install-nix-action@1ca7d21a94afc7c957383a2d217460d980de4934 # v31.10.1 + - uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6 - uses: ./ with: diff --git a/.github/workflows/simple.yml b/.github/workflows/simple.yml index 927be30..d968497 100644 --- a/.github/workflows/simple.yml +++ b/.github/workflows/simple.yml @@ -19,7 +19,7 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/target-dir.yml b/.github/workflows/target-dir.yml index 1252f02..69da9af 100644 --- a/.github/workflows/target-dir.yml +++ b/.github/workflows/target-dir.yml @@ -19,7 +19,7 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/warpbuild.yml b/.github/workflows/warpbuild.yml index 8c2e5ba..4d1e230 100644 --- a/.github/workflows/warpbuild.yml +++ b/.github/workflows/warpbuild.yml @@ -19,7 +19,7 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/workspaces.yml b/.github/workflows/workspaces.yml index e246c69..2b1b6aa 100644 --- a/.github/workflows/workspaces.yml +++ b/.github/workflows/workspaces.yml @@ -19,7 +19,7 @@ jobs: CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index c4b2eea..bbd4044 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -16,9 +16,9 @@ jobs: security-events: write # for uploading results to the Security tab steps: - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2 + uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6 diff --git a/README.md b/README.md index 07281f1..9ece287 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ sensible defaults. ## Example usage ```yaml -- uses: actions/checkout@v5 +- uses: actions/checkout@v6 # selecting a toolchain either by action or manual `rustup` calls should happen # before the plugin, as the cache uses the current rustc version as its cache key @@ -32,7 +32,7 @@ sensible defaults. # default: "true" add-job-id-key: "" - # Weather the a hash of the rust environment should be included in the cache key. + # Whether the a hash of the rust environment should be included in the cache key. # This includes a hash of all Cargo.toml/Cargo.lock files, rust-toolchain files, # and .cargo/config.toml files (if present), as well as the specified 'env-vars'. # default: "true" diff --git a/dist/restore.js b/dist/restore.js index ff67344..d44bdcd 100644 --- a/dist/restore.js +++ b/dist/restore.js @@ -332343,7 +332343,7 @@ async function exists(path) { } } -const SAVE_TARGETS = new Set(["lib", "proc-macro"]); +const SAVE_TARGETS = new Set(["lib", "cdylib", "dylib", "rlib", "staticlib", "proc-macro"]); class Workspace { root; target; @@ -332682,10 +332682,10 @@ function digest(hasher) { async function getCargoBins() { const bins = new Set(); try { - const { installs } = JSON.parse(await fs$2.readFile(path__default.join(CARGO_HOME, ".crates2.json"), "utf8")); - for (const pkg of Object.values(installs)) { - for (const bin of pkg.bins) { - bins.add(bin); + const dir = await fs$2.opendir(path__default.join(CARGO_HOME, "bin")); + for await (const dirent of dir) { + if (dirent.isFile()) { + bins.add(dirent.name); } } } @@ -332803,7 +332803,7 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp = false) } let keepProfile = new Set(["build", ".fingerprint", "deps"]); await rmExcept(profileDir, keepProfile); - const keepPkg = new Set(packages.map((p) => p.name)); + const keepPkg = new Set(packages.flatMap((p) => [p.name, ...p.targets.map((t) => t.replace(/-/g, "_"))])); await rmExcept(path__default.join(profileDir, "build"), keepPkg, checkTimestamp); await rmExcept(path__default.join(profileDir, ".fingerprint"), keepPkg, checkTimestamp); const keepDeps = new Set(packages.flatMap((p) => { diff --git a/dist/save.js b/dist/save.js index 29934a0..0e9b6de 100644 --- a/dist/save.js +++ b/dist/save.js @@ -332310,7 +332310,7 @@ async function exists(path) { } } -const SAVE_TARGETS = new Set(["lib", "proc-macro"]); +const SAVE_TARGETS = new Set(["lib", "cdylib", "dylib", "rlib", "staticlib", "proc-macro"]); class Workspace { root; target; @@ -332657,10 +332657,10 @@ function digest(hasher) { async function getCargoBins() { const bins = new Set(); try { - const { installs } = JSON.parse(await fs$2.readFile(path__default.join(CARGO_HOME, ".crates2.json"), "utf8")); - for (const pkg of Object.values(installs)) { - for (const bin of pkg.bins) { - bins.add(bin); + const dir = await fs$2.opendir(path__default.join(CARGO_HOME, "bin")); + for await (const dirent of dir) { + if (dirent.isFile()) { + bins.add(dirent.name); } } } @@ -332778,7 +332778,7 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp = false) } let keepProfile = new Set(["build", ".fingerprint", "deps"]); await rmExcept(profileDir, keepProfile); - const keepPkg = new Set(packages.map((p) => p.name)); + const keepPkg = new Set(packages.flatMap((p) => [p.name, ...p.targets.map((t) => t.replace(/-/g, "_"))])); await rmExcept(path__default.join(profileDir, "build"), keepPkg, checkTimestamp); await rmExcept(path__default.join(profileDir, ".fingerprint"), keepPkg, checkTimestamp); const keepDeps = new Set(packages.flatMap((p) => { @@ -332798,13 +332798,10 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp = false) * @param oldBins The binaries that existed when the action started. */ async function cleanBin(oldBins) { - const bins = await getCargoBins(); - for (const bin of oldBins) { - bins.delete(bin); - } + const binsToRemove = new Set(oldBins); const dir = await fs__default.promises.opendir(path__default.join(CARGO_HOME, "bin")); for await (const dirent of dir) { - if (dirent.isFile() && !bins.has(dirent.name)) { + if (dirent.isFile() && binsToRemove.has(dirent.name)) { await rm(dir.path, dirent); } } diff --git a/src/cleanup.ts b/src/cleanup.ts index 6375cf9..c40367c 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -3,7 +3,7 @@ import * as io from "@actions/io"; import fs from "fs"; import path from "path"; -import { CARGO_HOME, getCargoBins } from "./config"; +import { CARGO_HOME } from "./config"; import { exists } from "./utils"; import { Packages } from "./workspace"; @@ -58,7 +58,7 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT let keepProfile = new Set(["build", ".fingerprint", "deps"]); await rmExcept(profileDir, keepProfile); - const keepPkg = new Set(packages.map((p) => p.name)); + const keepPkg = new Set(packages.flatMap((p) => [p.name, ...p.targets.map((t) => t.replace(/-/g, "_"))])); await rmExcept(path.join(profileDir, "build"), keepPkg, checkTimestamp); await rmExcept(path.join(profileDir, ".fingerprint"), keepPkg, checkTimestamp); @@ -82,15 +82,11 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT * @param oldBins The binaries that existed when the action started. */ export async function cleanBin(oldBins: Array) { - const bins = await getCargoBins(); - - for (const bin of oldBins) { - bins.delete(bin); - } + const binsToRemove = new Set(oldBins); const dir = await fs.promises.opendir(path.join(CARGO_HOME, "bin")); for await (const dirent of dir) { - if (dirent.isFile() && !bins.has(dirent.name)) { + if (dirent.isFile() && binsToRemove.has(dirent.name)) { await rm(dir.path, dirent); } } diff --git a/src/config.ts b/src/config.ts index 1619a74..4545dba 100644 --- a/src/config.ts +++ b/src/config.ts @@ -380,19 +380,18 @@ function digest(hasher: crypto.Hash): string { export async function getCargoBins(): Promise> { const bins = new Set(); + try { - const { installs }: { installs: { [key: string]: { bins: Array } } } = JSON.parse( - await fs.readFile(path.join(CARGO_HOME, ".crates2.json"), "utf8"), - ); - for (const pkg of Object.values(installs)) { - for (const bin of pkg.bins) { - bins.add(bin); + const dir = await fs.opendir(path.join(CARGO_HOME, "bin")); + for await (const dirent of dir) { + if (dirent.isFile()) { + bins.add(dirent.name); } } } catch {} + return bins; } - interface RustVersion { host: string; release: string; diff --git a/src/workspace.ts b/src/workspace.ts index d7734f5..2d9eca8 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -3,7 +3,7 @@ import path from "path"; import { getCmdOutput } from "./utils"; -const SAVE_TARGETS = new Set(["lib", "proc-macro"]); +const SAVE_TARGETS = new Set(["lib", "cdylib", "dylib", "rlib", "staticlib", "proc-macro"]); export class Workspace { constructor(public root: string, public target: string) {}