mirror of
https://github.com/Swatinem/rust-cache
synced 2026-11-02 21:13:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8037a86dd |
@@ -147,7 +147,7 @@ This cache is automatically keyed by:
|
|||||||
available),
|
available),
|
||||||
- the following values, if `add-rust-environment-hash-key` is `"true"`:
|
- the following values, if `add-rust-environment-hash-key` is `"true"`:
|
||||||
- the value of some compiler-specific environment variables (eg. RUSTFLAGS, etc), and
|
- the value of some compiler-specific environment variables (eg. RUSTFLAGS, etc), and
|
||||||
- a hash of all `Cargo.lock` / `Cargo.toml` files found anywhere in the repository (if present).
|
- a hash of the workspace's `Cargo.lock` and of the `Cargo.toml` of the workspace root and every workspace member (if present).
|
||||||
- a hash of all `rust-toolchain` / `rust-toolchain.toml` files in the root of the repository (if present).
|
- a hash of all `rust-toolchain` / `rust-toolchain.toml` files in the root of the repository (if present).
|
||||||
- a hash of all `.cargo/config.toml` files in the root of the repository (if present).
|
- a hash of all `.cargo/config.toml` files in the root of the repository (if present).
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { x as commonjsGlobal, y as requireTunnel, z as getDefaultExportFromCjs, A as getAugmentedNamespace } from './cleanup-e3M0pm4f.js';
|
import { x as commonjsGlobal, y as requireTunnel, z as getDefaultExportFromCjs, A as getAugmentedNamespace } from './cleanup-DYJDrBaf.js';
|
||||||
import os__default from 'os';
|
import os__default from 'os';
|
||||||
import crypto__default from 'crypto';
|
import crypto__default from 'crypto';
|
||||||
import fs__default from 'fs';
|
import fs__default from 'fs';
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { f as debug, m as mkdirP, n as create, l as exec, w as which, o as warning, i as info, H as HttpCodes, p as HttpClientError, q as HttpClient, t as isDebug, u as setSecret, B as BearerCredentialHandler, v as rmRF, e as error } from './cleanup-e3M0pm4f.js';
|
import { f as debug, m as mkdirP, n as create, l as exec, w as which, o as warning, i as info, H as HttpCodes, p as HttpClientError, q as HttpClient, t as isDebug, u as setSecret, B as BearerCredentialHandler, v as rmRF, e as error } from './cleanup-DYJDrBaf.js';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
+28
-13
@@ -34972,10 +34972,10 @@ async function getCacheProvider() {
|
|||||||
let cache;
|
let cache;
|
||||||
switch (cacheProvider) {
|
switch (cacheProvider) {
|
||||||
case "github":
|
case "github":
|
||||||
cache = await import('./cache-Dl81DHPs.js');
|
cache = await import('./cache-DoD2J4WY.js');
|
||||||
break;
|
break;
|
||||||
case "warpbuild":
|
case "warpbuild":
|
||||||
cache = await import('./cache-BzPKClMA.js').then(function (n) { return n.c; });
|
cache = await import('./cache-BaeW9gVW.js').then(function (n) { return n.c; });
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
|
throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
|
||||||
@@ -35006,6 +35006,7 @@ class Workspace {
|
|||||||
async getPackages(cmdFormat, filter, extraArgs) {
|
async getPackages(cmdFormat, filter, extraArgs) {
|
||||||
const cmd = "cargo metadata --all-features --format-version 1" + (extraArgs ? ` ${extraArgs}` : "");
|
const cmd = "cargo metadata --all-features --format-version 1" + (extraArgs ? ` ${extraArgs}` : "");
|
||||||
let packages = [];
|
let packages = [];
|
||||||
|
let workspaceRoot = this.root;
|
||||||
try {
|
try {
|
||||||
debug(`collecting metadata for "${this.root}"`);
|
debug(`collecting metadata for "${this.root}"`);
|
||||||
const meta = JSON.parse(await getCmdOutput(cmdFormat, cmd, {
|
const meta = JSON.parse(await getCmdOutput(cmdFormat, cmd, {
|
||||||
@@ -35013,6 +35014,7 @@ class Workspace {
|
|||||||
env: { ...process.env, CARGO_ENCODED_RUSTFLAGS: "" },
|
env: { ...process.env, CARGO_ENCODED_RUSTFLAGS: "" },
|
||||||
}));
|
}));
|
||||||
debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
|
debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
|
||||||
|
workspaceRoot = meta.workspace_root;
|
||||||
for (const pkg of meta.packages.filter(filter)) {
|
for (const pkg of meta.packages.filter(filter)) {
|
||||||
const targets = pkg.targets.filter((t) => t.kind.some((kind) => SAVE_TARGETS.has(kind))).map((t) => t.name);
|
const targets = pkg.targets.filter((t) => t.kind.some((kind) => SAVE_TARGETS.has(kind))).map((t) => t.name);
|
||||||
packages.push({ name: pkg.name, version: pkg.version, targets, path: path__default.dirname(pkg.manifest_path) });
|
packages.push({ name: pkg.name, version: pkg.version, targets, path: path__default.dirname(pkg.manifest_path) });
|
||||||
@@ -35021,13 +35023,16 @@ class Workspace {
|
|||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
return packages;
|
return { packages, workspaceRoot };
|
||||||
}
|
}
|
||||||
async getPackagesOutsideWorkspaceRoot(cmdFormat) {
|
async getPackagesOutsideWorkspaceRoot(cmdFormat) {
|
||||||
return await this.getPackages(cmdFormat, (pkg) => !pkg.manifest_path.startsWith(this.root));
|
const filter = (pkg) => !pkg.manifest_path.startsWith(this.root);
|
||||||
|
return (await this.getPackages(cmdFormat, filter)).packages;
|
||||||
}
|
}
|
||||||
|
/** The workspace's members, and the root directory of the cargo workspace they belong to. */
|
||||||
async getWorkspaceMembers(cmdFormat) {
|
async getWorkspaceMembers(cmdFormat) {
|
||||||
return await this.getPackages(cmdFormat, (_) => true, "--no-deps");
|
const { packages, workspaceRoot } = await this.getPackages(cmdFormat, (_) => true, "--no-deps");
|
||||||
|
return { members: packages, workspaceRoot };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35155,9 +35160,15 @@ class CacheConfig {
|
|||||||
for (const workspace of workspaces) {
|
for (const workspace of workspaces) {
|
||||||
const root = workspace.root;
|
const root = workspace.root;
|
||||||
keyFiles.push(...(await globFiles(`${root}/**/.cargo/config.toml\n${root}/**/rust-toolchain\n${root}/**/rust-toolchain.toml`)));
|
keyFiles.push(...(await globFiles(`${root}/**/.cargo/config.toml\n${root}/**/rust-toolchain\n${root}/**/rust-toolchain.toml`)));
|
||||||
const workspaceMembers = await workspace.getWorkspaceMembers(cmdFormat);
|
const { members, workspaceRoot } = await workspace.getWorkspaceMembers(cmdFormat);
|
||||||
const cargo_manifests = sort_and_uniq(workspaceMembers.map((member) => path__default.join(member.path, "Cargo.toml")));
|
const cargo_manifests = members.map((member) => path__default.join(member.path, "Cargo.toml"));
|
||||||
for (const cargo_manifest of cargo_manifests) {
|
// A virtual workspace's root manifest belongs to no member, yet its `[profile]` and `[patch]`
|
||||||
|
// sections apply to every member.
|
||||||
|
const root_manifest = path__default.join(workspaceRoot, "Cargo.toml");
|
||||||
|
if (await exists(root_manifest)) {
|
||||||
|
cargo_manifests.push(root_manifest);
|
||||||
|
}
|
||||||
|
for (const cargo_manifest of sort_and_uniq(cargo_manifests)) {
|
||||||
try {
|
try {
|
||||||
const content = await fs$1.readFile(cargo_manifest, { encoding: "utf8" });
|
const content = await fs$1.readFile(cargo_manifest, { encoding: "utf8" });
|
||||||
// Use any since TomlPrimitive is not exposed
|
// Use any since TomlPrimitive is not exposed
|
||||||
@@ -35168,12 +35179,16 @@ class CacheConfig {
|
|||||||
pack["version"] = "0.0.0";
|
pack["version"] = "0.0.0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const prefix of ["", "build-", "dev-"]) {
|
const workspace_table = parsed.workspace ?? {};
|
||||||
const section_name = `${prefix}dependencies`;
|
if ("package" in workspace_table && "version" in workspace_table.package) {
|
||||||
if (!(section_name in parsed)) {
|
workspace_table.package["version"] = "0.0.0";
|
||||||
|
}
|
||||||
|
const dependency_tables = ["", "build-", "dev-"].map((prefix) => parsed[`${prefix}dependencies`]);
|
||||||
|
dependency_tables.push(workspace_table.dependencies);
|
||||||
|
for (const deps of dependency_tables) {
|
||||||
|
if (deps === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const deps = parsed[section_name];
|
|
||||||
for (const key of Object.keys(deps)) {
|
for (const key of Object.keys(deps)) {
|
||||||
const dep = deps[key];
|
const dep = deps[key];
|
||||||
try {
|
try {
|
||||||
@@ -35198,7 +35213,7 @@ class CacheConfig {
|
|||||||
keyFiles.push(cargo_manifest);
|
keyFiles.push(cargo_manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const cargo_lock = path__default.join(workspace.root, "Cargo.lock");
|
const cargo_lock = path__default.join(workspaceRoot, "Cargo.lock");
|
||||||
if (await exists(cargo_lock)) {
|
if (await exists(cargo_lock)) {
|
||||||
try {
|
try {
|
||||||
const content = await fs$1.readFile(cargo_lock, { encoding: "utf8" });
|
const content = await fs$1.readFile(cargo_lock, { encoding: "utf8" });
|
||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { e as error, g as getCacheProvider, a as getInput, b as exportVariable, C as CacheConfig, i as info, c as cleanTargetDir, r as reportError, s as setOutput } from './cleanup-e3M0pm4f.js';
|
import { e as error, g as getCacheProvider, a as getInput, b as exportVariable, C as CacheConfig, i as info, c as cleanTargetDir, r as reportError, s as setOutput } from './cleanup-DYJDrBaf.js';
|
||||||
import 'os';
|
import 'os';
|
||||||
import 'crypto';
|
import 'crypto';
|
||||||
import 'fs';
|
import 'fs';
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
import { e as error, g as getCacheProvider, a as getInput, d as isCacheUpToDate, i as info, C as CacheConfig, c as cleanTargetDir, f as debug, h as cleanRegistry, j as cleanBin, k as cleanGit, r as reportError, l as exec } from './cleanup-e3M0pm4f.js';
|
import { e as error, g as getCacheProvider, a as getInput, d as isCacheUpToDate, i as info, C as CacheConfig, c as cleanTargetDir, f as debug, h as cleanRegistry, j as cleanBin, k as cleanGit, r as reportError, l as exec } from './cleanup-DYJDrBaf.js';
|
||||||
import 'os';
|
import 'os';
|
||||||
import 'crypto';
|
import 'crypto';
|
||||||
import 'fs';
|
import 'fs';
|
||||||
@@ -63,8 +63,8 @@ async function run() {
|
|||||||
for (const workspace of config.workspaces) {
|
for (const workspace of config.workspaces) {
|
||||||
const packages = await workspace.getPackagesOutsideWorkspaceRoot(config.cmdFormat);
|
const packages = await workspace.getPackagesOutsideWorkspaceRoot(config.cmdFormat);
|
||||||
if (workspaceCrates === "true") {
|
if (workspaceCrates === "true") {
|
||||||
const wsMembers = await workspace.getWorkspaceMembers(config.cmdFormat);
|
const { members } = await workspace.getWorkspaceMembers(config.cmdFormat);
|
||||||
packages.push(...wsMembers);
|
packages.push(...members);
|
||||||
}
|
}
|
||||||
allPackages.push(...packages);
|
allPackages.push(...packages);
|
||||||
try {
|
try {
|
||||||
|
|||||||
+19
-8
@@ -167,11 +167,17 @@ export class CacheConfig {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const workspaceMembers = await workspace.getWorkspaceMembers(cmdFormat);
|
const { members, workspaceRoot } = await workspace.getWorkspaceMembers(cmdFormat);
|
||||||
|
|
||||||
const cargo_manifests = sort_and_uniq(workspaceMembers.map((member) => path.join(member.path, "Cargo.toml")));
|
const cargo_manifests = members.map((member) => path.join(member.path, "Cargo.toml"));
|
||||||
|
// A virtual workspace's root manifest belongs to no member, yet its `[profile]` and `[patch]`
|
||||||
|
// sections apply to every member.
|
||||||
|
const root_manifest = path.join(workspaceRoot, "Cargo.toml");
|
||||||
|
if (await exists(root_manifest)) {
|
||||||
|
cargo_manifests.push(root_manifest);
|
||||||
|
}
|
||||||
|
|
||||||
for (const cargo_manifest of cargo_manifests) {
|
for (const cargo_manifest of sort_and_uniq(cargo_manifests)) {
|
||||||
try {
|
try {
|
||||||
const content = await fs.readFile(cargo_manifest, { encoding: "utf8" });
|
const content = await fs.readFile(cargo_manifest, { encoding: "utf8" });
|
||||||
// Use any since TomlPrimitive is not exposed
|
// Use any since TomlPrimitive is not exposed
|
||||||
@@ -184,12 +190,17 @@ export class CacheConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const prefix of ["", "build-", "dev-"]) {
|
const workspace_table = parsed.workspace ?? {};
|
||||||
const section_name = `${prefix}dependencies`;
|
if ("package" in workspace_table && "version" in workspace_table.package) {
|
||||||
if (!(section_name in parsed)) {
|
workspace_table.package["version"] = "0.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
const dependency_tables = ["", "build-", "dev-"].map((prefix) => parsed[`${prefix}dependencies`]);
|
||||||
|
dependency_tables.push(workspace_table.dependencies);
|
||||||
|
for (const deps of dependency_tables) {
|
||||||
|
if (deps === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const deps = parsed[section_name];
|
|
||||||
|
|
||||||
for (const key of Object.keys(deps)) {
|
for (const key of Object.keys(deps)) {
|
||||||
const dep = deps[key];
|
const dep = deps[key];
|
||||||
@@ -217,7 +228,7 @@ export class CacheConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cargo_lock = path.join(workspace.root, "Cargo.lock");
|
const cargo_lock = path.join(workspaceRoot, "Cargo.lock");
|
||||||
if (await exists(cargo_lock)) {
|
if (await exists(cargo_lock)) {
|
||||||
try {
|
try {
|
||||||
const content = await fs.readFile(cargo_lock, { encoding: "utf8" });
|
const content = await fs.readFile(cargo_lock, { encoding: "utf8" });
|
||||||
|
|||||||
+2
-2
@@ -41,8 +41,8 @@ async function run() {
|
|||||||
for (const workspace of config.workspaces) {
|
for (const workspace of config.workspaces) {
|
||||||
const packages = await workspace.getPackagesOutsideWorkspaceRoot(config.cmdFormat);
|
const packages = await workspace.getPackagesOutsideWorkspaceRoot(config.cmdFormat);
|
||||||
if (workspaceCrates === "true") {
|
if (workspaceCrates === "true") {
|
||||||
const wsMembers = await workspace.getWorkspaceMembers(config.cmdFormat);
|
const { members } = await workspace.getWorkspaceMembers(config.cmdFormat);
|
||||||
packages.push(...wsMembers);
|
packages.push(...members);
|
||||||
}
|
}
|
||||||
allPackages.push(...packages);
|
allPackages.push(...packages);
|
||||||
try {
|
try {
|
||||||
|
|||||||
+11
-5
@@ -15,9 +15,10 @@ export class Workspace {
|
|||||||
cmdFormat: string,
|
cmdFormat: string,
|
||||||
filter: (p: Meta["packages"][0]) => boolean,
|
filter: (p: Meta["packages"][0]) => boolean,
|
||||||
extraArgs?: string,
|
extraArgs?: string,
|
||||||
): Promise<Packages> {
|
): Promise<{ packages: Packages; workspaceRoot: string }> {
|
||||||
const cmd = "cargo metadata --all-features --format-version 1" + (extraArgs ? ` ${extraArgs}` : "");
|
const cmd = "cargo metadata --all-features --format-version 1" + (extraArgs ? ` ${extraArgs}` : "");
|
||||||
let packages: Packages = [];
|
let packages: Packages = [];
|
||||||
|
let workspaceRoot = this.root;
|
||||||
try {
|
try {
|
||||||
core.debug(`collecting metadata for "${this.root}"`);
|
core.debug(`collecting metadata for "${this.root}"`);
|
||||||
const meta: Meta = JSON.parse(
|
const meta: Meta = JSON.parse(
|
||||||
@@ -27,6 +28,7 @@ export class Workspace {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
core.debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
|
core.debug(`workspace "${this.root}" has ${meta.packages.length} packages`);
|
||||||
|
workspaceRoot = meta.workspace_root;
|
||||||
for (const pkg of meta.packages.filter(filter)) {
|
for (const pkg of meta.packages.filter(filter)) {
|
||||||
const targets = pkg.targets.filter((t) => t.kind.some((kind) => SAVE_TARGETS.has(kind))).map((t) => t.name);
|
const targets = pkg.targets.filter((t) => t.kind.some((kind) => SAVE_TARGETS.has(kind))).map((t) => t.name);
|
||||||
packages.push({ name: pkg.name, version: pkg.version, targets, path: path.dirname(pkg.manifest_path) });
|
packages.push({ name: pkg.name, version: pkg.version, targets, path: path.dirname(pkg.manifest_path) });
|
||||||
@@ -34,15 +36,18 @@ export class Workspace {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
return packages;
|
return { packages, workspaceRoot };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getPackagesOutsideWorkspaceRoot(cmdFormat: string): Promise<Packages> {
|
public async getPackagesOutsideWorkspaceRoot(cmdFormat: string): Promise<Packages> {
|
||||||
return await this.getPackages(cmdFormat, (pkg) => !pkg.manifest_path.startsWith(this.root));
|
const filter = (pkg: Meta["packages"][0]) => !pkg.manifest_path.startsWith(this.root);
|
||||||
|
return (await this.getPackages(cmdFormat, filter)).packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getWorkspaceMembers(cmdFormat: string): Promise<Packages> {
|
/** The workspace's members, and the root directory of the cargo workspace they belong to. */
|
||||||
return await this.getPackages(cmdFormat, (_) => true, "--no-deps");
|
public async getWorkspaceMembers(cmdFormat: string): Promise<{ members: Packages; workspaceRoot: string }> {
|
||||||
|
const { packages, workspaceRoot } = await this.getPackages(cmdFormat, (_) => true, "--no-deps");
|
||||||
|
return { members: packages, workspaceRoot };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +61,7 @@ export interface PackageDefinition {
|
|||||||
export type Packages = Array<PackageDefinition>;
|
export type Packages = Array<PackageDefinition>;
|
||||||
|
|
||||||
interface Meta {
|
interface Meta {
|
||||||
|
workspace_root: string;
|
||||||
packages: Array<{
|
packages: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user