package maintenance

- update to TS6
- replace ncc by rollup, which seems to now be the recommended workflow according to <https://github.com/actions/typescript-action>
- remove buildjet provider, as they are shutting down, see <https://buildjet.com/for-github-actions/blog/we-are-shutting-down>
This commit is contained in:
Arpad Borsos
2026-06-06 14:02:52 +02:00
parent e18b497796
commit be9aa033ee
15 changed files with 667122 additions and 501283 deletions
@@ -1,18 +1,18 @@
name: buildjet
name: warpbuild
on: [push, pull_request]
permissions: {}
jobs:
buildjet:
warpbuild:
if: github.repository == 'Swatinem/rust-cache'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Test buildjet provider on ${{ matrix.os }}
name: Test warpbuild provider on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
@@ -28,7 +28,7 @@ jobs:
- uses: ./
with:
workspaces: tests
cache-provider: buildjet
cache-provider: warpbuild
- run: |
cargo check
+1
View File
@@ -1,6 +1,7 @@
node_modules/
target/
src/*.js
.build
# Editors
.idea/
+3 -3
View File
@@ -92,7 +92,7 @@ sensible defaults.
lookup-only: ""
# Specifies what to use as the backend providing cache
# Can be set to "github", "buildjet", or "warpbuild"
# Can be set to "github", or "warpbuild"
# default: "github"
cache-provider: ""
@@ -142,7 +142,7 @@ This action currently caches the following files/directories:
This cache is automatically keyed by:
- the github [`job_id`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_id)
(if `add-job-id-key` is `"true"`),
(if `add-job-id-key` is `"true"`),
- the rustc release / host / hash (for all installed toolchains when
available),
- the following values, if `add-rust-environment-hash-key` is `"true"`:
@@ -210,5 +210,5 @@ to see those details as well as further details related to caching operations.
- The cache cleaning process currently removes all the files from `~/.cargo/bin`
that were present before the action ran (for example `rustc`), by default.
This can be an issue on long-running self-hosted runners, where such state
is expected to be preserved across runs. You can work around this by setting
is expected to be preserved across runs. You can work around this by setting
`cache-bin: "false"`.
+3 -3
View File
@@ -49,7 +49,7 @@ inputs:
required: false
default: "true"
cache-provider:
description: "Determines which provider to use for caching. Options are github, buildjet, or warpbuild. Defaults to github."
description: "Determines which provider to use for caching. Options are github, or warpbuild. Defaults to github."
required: false
default: "github"
cache-bin:
@@ -69,8 +69,8 @@ outputs:
description: "A boolean value that indicates an exact match was found."
runs:
using: "node24"
main: "dist/restore/index.js"
post: "dist/save/index.js"
main: "dist/restore.js"
post: "dist/save.js"
post-if: "success() || env.CACHE_ON_FAILURE == 'true'"
branding:
icon: "archive"
+332931
View File
File diff suppressed because one or more lines are too long
-250488
View File
File diff suppressed because one or more lines are too long
+333087
View File
File diff suppressed because one or more lines are too long
-250509
View File
File diff suppressed because one or more lines are too long
+1024 -237
View File
File diff suppressed because it is too large Load Diff
+17 -10
View File
@@ -21,23 +21,30 @@
"url": "https://github.com/sponsors/Swatinem"
},
"homepage": "https://github.com/Swatinem/rust-cache#readme",
"type": "module",
"dependencies": {
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0",
"@actions/warpbuild-cache": "npm:github-actions.warp-cache@1.4.7",
"@actions/cache": "^6.0.0",
"@actions/core": "^3.0.0",
"@actions/cache": "^6.0.1",
"@actions/core": "^3.0.1",
"@actions/exec": "^3.0.0",
"@actions/glob": "^0.6.1",
"@actions/glob": "^0.7.0",
"@actions/io": "^3.0.2",
"smol-toml": "^1.6.0"
"@actions/warpbuild-cache": "npm:github-actions.warp-cache@1.4.7",
"smol-toml": "^1.6.1"
},
"devDependencies": {
"@types/node": "^25.4.0",
"@vercel/ncc": "^0.38.4",
"@rollup/plugin-commonjs": "^29.0.3",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@types/node": "^25.9.2",
"linefix": "^0.1.1",
"typescript": "5.9.3"
"rollup": "^4.61.1",
"typescript": "6.0.3"
},
"scripts": {
"prepare": "ncc build --target es2020 -o dist/restore src/restore.ts && ncc build --target es2020 -o dist/save src/save.ts && linefix dist"
"clean": "node -e \"(async () => { try { await require('fs/promises').rm('dist', { recursive: true }); } catch {} })()\"",
"prebuild": "npm run clean",
"build": "tsc && rollup --config .build/rollup.config.js",
"prepublishOnly": "npm run test",
"prepare": "npm run build && linefix dist"
}
}
+24
View File
@@ -0,0 +1,24 @@
// import * as fs from "node:fs";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import type { RollupWatchOptions } from "rollup";
// const pkg = JSON.parse(fs.readFileSync("./package.json", { encoding: "utf-8" }));
// const external = ["node:module", "node:path", "node:fs", "node:fs/promises", "typescript", "rollup", "@babel/code-frame", "magic-string", "@jridgewell/remapping", "@jridgewell/sourcemap-codec", "convert-source-map"];
const config: Array<RollupWatchOptions> = [
{
input: "./.build/src/restore.js",
output: { file: "./dist/restore.js", format: "es" },
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()],
},
{
input: "./.build/src/save.js",
output: { file: "./dist/save.js", format: "es" },
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()],
},
];
export default config;
+1 -16
View File
@@ -3,7 +3,7 @@ import * as io from "@actions/io";
import fs from "fs";
import path from "path";
import { CARGO_HOME } from "./config";
import { CARGO_HOME, getCargoBins } from "./config";
import { exists } from "./utils";
import { Packages } from "./workspace";
@@ -75,21 +75,6 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
await rmExcept(path.join(profileDir, "deps"), keepDeps, checkTimestamp);
}
export async function getCargoBins(): Promise<Set<string>> {
const bins = new Set<string>();
try {
const { installs }: { installs: { [key: string]: { bins: Array<string> } } } = JSON.parse(
await fs.promises.readFile(path.join(CARGO_HOME, ".crates2.json"), "utf8"),
);
for (const pkg of Object.values(installs)) {
for (const bin of pkg.bins) {
bins.add(bin);
}
}
} catch {}
return bins;
}
/**
* Clean the cargo bin directory, removing the binaries that existed
* when the action started, as they were not created by the build.
+15 -1
View File
@@ -7,7 +7,6 @@ import os from "os";
import path from "path";
import * as toml from "smol-toml";
import { getCargoBins } from "./cleanup";
import { CacheProvider, exists, getCmdOutput } from "./utils";
import { Workspace } from "./workspace";
@@ -379,6 +378,21 @@ function digest(hasher: crypto.Hash): string {
return hasher.digest("hex").substring(0, HASH_LENGTH);
}
export async function getCargoBins(): Promise<Set<string>> {
const bins = new Set<string>();
try {
const { installs }: { installs: { [key: string]: { bins: Array<string> } } } = 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);
}
}
} catch {}
return bins;
}
interface RustVersion {
host: string;
release: string;
+1 -9
View File
@@ -1,6 +1,5 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as buildjetCache from "@actions/buildjet-cache";
import * as warpbuildCache from "@actions/warpbuild-cache";
import * as ghCache from "@actions/cache";
import fs from "fs";
@@ -15,11 +14,7 @@ export function reportError(e: any) {
}
}
export async function getCmdOutput(
cmdFormat: string,
cmd: string,
options: exec.ExecOptions = {},
): Promise<string> {
export async function getCmdOutput(cmdFormat: string, cmd: string, options: exec.ExecOptions = {}): Promise<string> {
cmd = cmdFormat.replace("{0}", cmd);
let stdout = "";
let stderr = "";
@@ -64,9 +59,6 @@ export function getCacheProvider(): CacheProvider {
case "github":
cache = ghCache;
break;
case "buildjet":
cache = buildjetCache;
break;
case "warpbuild":
cache = warpbuildCache;
break;
+11 -3
View File
@@ -2,20 +2,28 @@
"compilerOptions": {
"noEmitOnError": false,
"diagnostics": true,
"lib": ["esnext"],
"lib": ["es2024"],
"types": ["node"],
"target": "es2020",
"target": "es2024",
"resolveJsonModule": true,
"ignoreDeprecations": "6.0",
"moduleResolution": "node",
"module": "esnext",
"esModuleInterop": true,
"incremental": true,
"tsBuildInfoFile": ".build/tsconfig.build.tsbuildinfo",
"strict": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true
"noImplicitReturns": true,
"outDir": ".build"
},
"include": ["src", "rollup.config.ts"],
"exclude": ["dist"]
}