mirror of
https://github.com/Swatinem/rust-cache
synced 2026-07-26 08:12:36 +00:00
fix: preserve target-triple build artifacts
This commit is contained in:
parent
a31add9f17
commit
92bdd21660
7 changed files with 110 additions and 17 deletions
85
.github/workflows/target-triple.yml
vendored
Normal file
85
.github/workflows/target-triple.yml
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
name: target-triple
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
save:
|
||||||
|
if: github.repository == 'Swatinem/rust-cache'
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
|
||||||
|
name: Save target-triple cache on ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- run: rustup toolchain install stable --profile minimal --no-self-update
|
||||||
|
|
||||||
|
- name: Set host target
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "RUST_TARGET=$(rustc -vV | sed -n 's/^host: //p')" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
workspaces: tests
|
||||||
|
shared-key: target-triple-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||||
|
add-job-id-key: "false"
|
||||||
|
add-rust-environment-hash-key: "false"
|
||||||
|
|
||||||
|
- run: cargo check --target "$RUST_TARGET"
|
||||||
|
working-directory: tests
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
restore:
|
||||||
|
if: github.repository == 'Swatinem/rust-cache'
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
|
||||||
|
name: Restore target-triple cache on ${{ matrix.os }}
|
||||||
|
needs: save
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- run: rustup toolchain install stable --profile minimal --no-self-update
|
||||||
|
|
||||||
|
- name: Set host target
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "RUST_TARGET=$(rustc -vV | sed -n 's/^host: //p')" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- id: cache
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
workspaces: tests
|
||||||
|
shared-key: target-triple-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||||
|
add-job-id-key: "false"
|
||||||
|
add-rust-environment-hash-key: "false"
|
||||||
|
save-if: "false"
|
||||||
|
|
||||||
|
- name: Verify target-triple artifacts
|
||||||
|
env:
|
||||||
|
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [[ "$CACHE_HIT" != "true" ]]; then
|
||||||
|
echo "The target-triple cache was not restored exactly." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! compgen -G "tests/target/$RUST_TARGET/debug/deps/librust_cache-*" > /dev/null; then
|
||||||
|
echo "The target-triple artifacts were not restored." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { v as commonjsGlobal, x as requireTunnel, y as getDefaultExportFromCjs, z as getAugmentedNamespace } from './cleanup-BnmJoqJp.js';
|
import { v as commonjsGlobal, x as requireTunnel, y as getDefaultExportFromCjs, z as getAugmentedNamespace } from './cleanup-By9HBZSo.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,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, e as error } from './cleanup-BnmJoqJp.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, e as error } from './cleanup-By9HBZSo.js';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as crypto$1 from 'crypto';
|
import * as crypto$1 from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
@ -34145,10 +34145,10 @@ async function getCacheProvider() {
|
||||||
let cache;
|
let cache;
|
||||||
switch (cacheProvider) {
|
switch (cacheProvider) {
|
||||||
case "github":
|
case "github":
|
||||||
cache = await import('./cache-oK5XC6-w.js');
|
cache = await import('./cache-XOpvQMVD.js');
|
||||||
break;
|
break;
|
||||||
case "warpbuild":
|
case "warpbuild":
|
||||||
cache = await import('./cache-COXGx-w3.js').then(function (n) { return n.c; });
|
cache = await import('./cache-BnuDdkC4.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.`);
|
||||||
|
|
@ -34596,14 +34596,18 @@ async function cleanTargetDir(targetDir, packages, checkTimestamp = false) {
|
||||||
for await (const dirent of dir) {
|
for await (const dirent of dir) {
|
||||||
if (dirent.isDirectory()) {
|
if (dirent.isDirectory()) {
|
||||||
let dirName = path__default.join(dir.path, dirent.name);
|
let dirName = path__default.join(dir.path, dirent.name);
|
||||||
// is it a profile dir, or a nested target dir?
|
// Target-triple directories do not contain Cargo's target directory
|
||||||
let isNestedTarget = (await exists(path__default.join(dirName, "CACHEDIR.TAG"))) || (await exists(path__default.join(dirName, ".rustc_info.json")));
|
// markers, so identify profiles by their artifact directories as well.
|
||||||
|
const isProfile = dirent.name === "tests" ||
|
||||||
|
(await exists(path__default.join(dirName, "build"))) ||
|
||||||
|
(await exists(path__default.join(dirName, ".fingerprint"))) ||
|
||||||
|
(await exists(path__default.join(dirName, "deps")));
|
||||||
try {
|
try {
|
||||||
if (isNestedTarget) {
|
if (isProfile) {
|
||||||
await cleanTargetDir(dirName, packages, checkTimestamp);
|
await cleanProfileTarget(dirName, packages, checkTimestamp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await cleanProfileTarget(dirName, packages, checkTimestamp);
|
await cleanTargetDir(dirName, packages, checkTimestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
2
dist/restore.js
vendored
2
dist/restore.js
vendored
|
|
@ -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-BnmJoqJp.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-By9HBZSo.js';
|
||||||
import 'os';
|
import 'os';
|
||||||
import 'crypto';
|
import 'crypto';
|
||||||
import 'fs';
|
import 'fs';
|
||||||
|
|
|
||||||
2
dist/save.js
vendored
2
dist/save.js
vendored
|
|
@ -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-BnmJoqJp.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-By9HBZSo.js';
|
||||||
import 'os';
|
import 'os';
|
||||||
import 'crypto';
|
import 'crypto';
|
||||||
import 'fs';
|
import 'fs';
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,19 @@ export async function cleanTargetDir(targetDir: string, packages: Packages, chec
|
||||||
for await (const dirent of dir) {
|
for await (const dirent of dir) {
|
||||||
if (dirent.isDirectory()) {
|
if (dirent.isDirectory()) {
|
||||||
let dirName = path.join(dir.path, dirent.name);
|
let dirName = path.join(dir.path, dirent.name);
|
||||||
// is it a profile dir, or a nested target dir?
|
// Target-triple directories do not contain Cargo's target directory
|
||||||
let isNestedTarget =
|
// markers, so identify profiles by their artifact directories as well.
|
||||||
(await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json")));
|
const isProfile =
|
||||||
|
dirent.name === "tests" ||
|
||||||
|
(await exists(path.join(dirName, "build"))) ||
|
||||||
|
(await exists(path.join(dirName, ".fingerprint"))) ||
|
||||||
|
(await exists(path.join(dirName, "deps")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isNestedTarget) {
|
if (isProfile) {
|
||||||
await cleanTargetDir(dirName, packages, checkTimestamp);
|
|
||||||
} else {
|
|
||||||
await cleanProfileTarget(dirName, packages, checkTimestamp);
|
await cleanProfileTarget(dirName, packages, checkTimestamp);
|
||||||
|
} else {
|
||||||
|
await cleanTargetDir(dirName, packages, checkTimestamp);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
} else if (dirent.name !== "CACHEDIR.TAG") {
|
} else if (dirent.name !== "CACHEDIR.TAG") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue