Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/target-triple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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"
cache-workspace-crates: "true"

- 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"
cache-workspace-crates: "true"
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/rust_cache-*" > /dev/null; then
echo "The target-triple artifacts were not restored." >&2
exit 1
fi
2 changes: 1 addition & 1 deletion dist/cache-COXGx-w3.js → dist/cache-BnuDdkC4.js
Original file line number Diff line number Diff line change
@@ -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 crypto__default from 'crypto';
import fs__default from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion dist/cache-oK5XC6-w.js → dist/cache-XOpvQMVD.js
Original file line number Diff line number Diff line change
@@ -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 crypto$1 from 'crypto';
import * as fs from 'fs';
Expand Down
18 changes: 11 additions & 7 deletions dist/cleanup-BnmJoqJp.js → dist/cleanup-By9HBZSo.js
Original file line number Diff line number Diff line change
Expand Up @@ -34145,10 +34145,10 @@ async function getCacheProvider() {
let cache;
switch (cacheProvider) {
case "github":
cache = await import('./cache-oK5XC6-w.js');
cache = await import('./cache-XOpvQMVD.js');
break;
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;
default:
throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
Expand Down Expand Up @@ -34596,14 +34596,18 @@ async function cleanTargetDir(targetDir, packages, checkTimestamp = false) {
for await (const dirent of dir) {
if (dirent.isDirectory()) {
let dirName = path__default.join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget = (await exists(path__default.join(dirName, "CACHEDIR.TAG"))) || (await exists(path__default.join(dirName, ".rustc_info.json")));
// Target-triple directories do not contain Cargo's target directory
// 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 {
if (isNestedTarget) {
await cleanTargetDir(dirName, packages, checkTimestamp);
if (isProfile) {
await cleanProfileTarget(dirName, packages, checkTimestamp);
}
else {
await cleanProfileTarget(dirName, packages, checkTimestamp);
await cleanTargetDir(dirName, packages, checkTimestamp);
}
}
catch { }
Expand Down
2 changes: 1 addition & 1 deletion dist/restore.js
Original file line number Diff line number Diff line change
@@ -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 'crypto';
import 'fs';
Expand Down
2 changes: 1 addition & 1 deletion dist/save.js
Original file line number Diff line number Diff line change
@@ -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 'crypto';
import 'fs';
Expand Down
16 changes: 10 additions & 6 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ export async function cleanTargetDir(targetDir: string, packages: Packages, chec
for await (const dirent of dir) {
if (dirent.isDirectory()) {
let dirName = path.join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget =
(await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json")));
// Target-triple directories do not contain Cargo's target directory
// markers, so identify profiles by their artifact directories as well.
const isProfile =
dirent.name === "tests" ||
(await exists(path.join(dirName, "build"))) ||
(await exists(path.join(dirName, ".fingerprint"))) ||
(await exists(path.join(dirName, "deps")));

try {
if (isNestedTarget) {
await cleanTargetDir(dirName, packages, checkTimestamp);
} else {
if (isProfile) {
await cleanProfileTarget(dirName, packages, checkTimestamp);
} else {
await cleanTargetDir(dirName, packages, checkTimestamp);
}
} catch {}
} else if (dirent.name !== "CACHEDIR.TAG") {
Expand Down
Loading