3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2026-06-10 10:37:14 +00:00

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 13:55:47 +02:00
parent e18b497796
commit be9aa033ee
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
15 changed files with 667122 additions and 501283 deletions

View file

@ -1,18 +1,18 @@
name: buildjet name: warpbuild
on: [push, pull_request] on: [push, pull_request]
permissions: {} permissions: {}
jobs: jobs:
buildjet: warpbuild:
if: github.repository == 'Swatinem/rust-cache' if: github.repository == 'Swatinem/rust-cache'
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] 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 }} runs-on: ${{ matrix.os }}
env: env:
@ -28,7 +28,7 @@ jobs:
- uses: ./ - uses: ./
with: with:
workspaces: tests workspaces: tests
cache-provider: buildjet cache-provider: warpbuild
- run: | - run: |
cargo check cargo check

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
node_modules/ node_modules/
target/ target/
src/*.js src/*.js
.build
# Editors # Editors
.idea/ .idea/

View file

@ -92,7 +92,7 @@ sensible defaults.
lookup-only: "" lookup-only: ""
# Specifies what to use as the backend providing cache # 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" # default: "github"
cache-provider: "" cache-provider: ""
@ -142,7 +142,7 @@ This action currently caches the following files/directories:
This cache is automatically keyed by: 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) - 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 - the rustc release / host / hash (for all installed toolchains when
available), available),
- the following values, if `add-rust-environment-hash-key` is `"true"`: - the following values, if `add-rust-environment-hash-key` is `"true"`:

View file

@ -49,7 +49,7 @@ inputs:
required: false required: false
default: "true" default: "true"
cache-provider: 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 required: false
default: "github" default: "github"
cache-bin: cache-bin:
@ -69,8 +69,8 @@ outputs:
description: "A boolean value that indicates an exact match was found." description: "A boolean value that indicates an exact match was found."
runs: runs:
using: "node24" using: "node24"
main: "dist/restore/index.js" main: "dist/restore.js"
post: "dist/save/index.js" post: "dist/save.js"
post-if: "success() || env.CACHE_ON_FAILURE == 'true'" post-if: "success() || env.CACHE_ON_FAILURE == 'true'"
branding: branding:
icon: "archive" icon: "archive"

332931
dist/restore.js vendored Normal file

File diff suppressed because one or more lines are too long

250488
dist/restore/index.js vendored

File diff suppressed because one or more lines are too long

333087
dist/save.js vendored Normal file

File diff suppressed because one or more lines are too long

250509
dist/save/index.js vendored

File diff suppressed because one or more lines are too long

1261
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -21,23 +21,30 @@
"url": "https://github.com/sponsors/Swatinem" "url": "https://github.com/sponsors/Swatinem"
}, },
"homepage": "https://github.com/Swatinem/rust-cache#readme", "homepage": "https://github.com/Swatinem/rust-cache#readme",
"type": "module",
"dependencies": { "dependencies": {
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0", "@actions/cache": "^6.0.1",
"@actions/warpbuild-cache": "npm:github-actions.warp-cache@1.4.7", "@actions/core": "^3.0.1",
"@actions/cache": "^6.0.0",
"@actions/core": "^3.0.0",
"@actions/exec": "^3.0.0", "@actions/exec": "^3.0.0",
"@actions/glob": "^0.6.1", "@actions/glob": "^0.7.0",
"@actions/io": "^3.0.2", "@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": { "devDependencies": {
"@types/node": "^25.4.0", "@rollup/plugin-commonjs": "^29.0.3",
"@vercel/ncc": "^0.38.4", "@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@types/node": "^25.9.2",
"linefix": "^0.1.1", "linefix": "^0.1.1",
"typescript": "5.9.3" "rollup": "^4.61.1",
"typescript": "6.0.3"
}, },
"scripts": { "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
rollup.config.ts Normal file
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;

View file

@ -3,7 +3,7 @@ import * as io from "@actions/io";
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import { CARGO_HOME } from "./config"; import { CARGO_HOME, getCargoBins } from "./config";
import { exists } from "./utils"; import { exists } from "./utils";
import { Packages } from "./workspace"; import { Packages } from "./workspace";
@ -75,21 +75,6 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
await rmExcept(path.join(profileDir, "deps"), keepDeps, checkTimestamp); 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 * Clean the cargo bin directory, removing the binaries that existed
* when the action started, as they were not created by the build. * when the action started, as they were not created by the build.

View file

@ -7,7 +7,6 @@ import os from "os";
import path from "path"; import path from "path";
import * as toml from "smol-toml"; import * as toml from "smol-toml";
import { getCargoBins } from "./cleanup";
import { CacheProvider, exists, getCmdOutput } from "./utils"; import { CacheProvider, exists, getCmdOutput } from "./utils";
import { Workspace } from "./workspace"; import { Workspace } from "./workspace";
@ -379,6 +378,21 @@ function digest(hasher: crypto.Hash): string {
return hasher.digest("hex").substring(0, HASH_LENGTH); 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 { interface RustVersion {
host: string; host: string;
release: string; release: string;

View file

@ -1,6 +1,5 @@
import * as core from "@actions/core"; import * as core from "@actions/core";
import * as exec from "@actions/exec"; import * as exec from "@actions/exec";
import * as buildjetCache from "@actions/buildjet-cache";
import * as warpbuildCache from "@actions/warpbuild-cache"; import * as warpbuildCache from "@actions/warpbuild-cache";
import * as ghCache from "@actions/cache"; import * as ghCache from "@actions/cache";
import fs from "fs"; import fs from "fs";
@ -15,11 +14,7 @@ export function reportError(e: any) {
} }
} }
export async function getCmdOutput( export async function getCmdOutput(cmdFormat: string, cmd: string, options: exec.ExecOptions = {}): Promise<string> {
cmdFormat: string,
cmd: string,
options: exec.ExecOptions = {},
): Promise<string> {
cmd = cmdFormat.replace("{0}", cmd); cmd = cmdFormat.replace("{0}", cmd);
let stdout = ""; let stdout = "";
let stderr = ""; let stderr = "";
@ -64,9 +59,6 @@ export function getCacheProvider(): CacheProvider {
case "github": case "github":
cache = ghCache; cache = ghCache;
break; break;
case "buildjet":
cache = buildjetCache;
break;
case "warpbuild": case "warpbuild":
cache = warpbuildCache; cache = warpbuildCache;
break; break;

View file

@ -2,20 +2,28 @@
"compilerOptions": { "compilerOptions": {
"noEmitOnError": false, "noEmitOnError": false,
"diagnostics": true, "diagnostics": true,
"lib": ["esnext"], "lib": ["es2024"],
"types": ["node"],
"target": "es2020", "target": "es2024",
"resolveJsonModule": true, "resolveJsonModule": true,
"ignoreDeprecations": "6.0",
"moduleResolution": "node", "moduleResolution": "node",
"module": "esnext", "module": "esnext",
"esModuleInterop": true, "esModuleInterop": true,
"incremental": true,
"tsBuildInfoFile": ".build/tsconfig.build.tsbuildinfo",
"strict": true, "strict": true,
"skipLibCheck": true, "skipLibCheck": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noImplicitReturns": true "noImplicitReturns": true,
"outDir": ".build"
}, },
"include": ["src", "rollup.config.ts"],
"exclude": ["dist"] "exclude": ["dist"]
} }