3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-04-11 07:03:37 +00:00

Merge pull request #1 from useblacksmith/add-blacksmith-support

*: add support for blacksmith cache to rust cache
This commit is contained in:
Aayush Shah 2024-02-05 17:13:01 -08:00 committed by GitHub
commit 90d9268c8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 5711 additions and 8 deletions

32
.github/workflows/blacksmith.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: blacksmith
on: [push, pull_request]
jobs:
blacksmith:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Test blacksmith provider on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v3
- run: rustup toolchain install stable --profile minimal --no-self-update
- uses: ./
with:
workspaces: tests
cache-provider: blacksmith
- run: |
cargo check
cargo test
cargo build --release
working-directory: tests

View file

@ -70,8 +70,8 @@ sensible defaults.
save-if: ${{ github.ref == 'refs/heads/master' }}
# Specifies what to use as the backend providing cache
# Can be set to either "github" or "buildjet"
# default: "github"
# Can be set to either "github" or "blacksmith"
# default: "blacksmith"
cache-provider: ""
```

View file

@ -37,9 +37,9 @@ inputs:
required: false
default: "true"
cache-provider:
description: "Determines which provider to use for caching. Options are github or buildjet, defaults to github."
description: "Determines which provider to use for caching. Options are github or blacksmith, defaults to blacksmith."
required: false
default: "github"
default: "blacksmith"
outputs:
cache-hit:
description: "A boolean value that indicates an exact match was found."

2819
dist/restore/index.js vendored

File diff suppressed because it is too large Load diff

2819
dist/save/index.js vendored

File diff suppressed because it is too large Load diff

28
package-lock.json generated
View file

@ -9,6 +9,7 @@
"version": "2.7.2",
"license": "LGPL-3.0",
"dependencies": {
"@actions/blacksmith-cache": "npm:@useblacksmith/cache@3.2.41",
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0",
"@actions/cache": "^3.2.3",
"@actions/core": "^1.10.1",
@ -26,6 +27,33 @@
"url": "https://github.com/sponsors/Swatinem"
}
},
"node_modules/@actions/blacksmith-cache": {
"name": "@useblacksmith/cache",
"version": "3.2.41",
"resolved": "https://registry.npmjs.org/@useblacksmith/cache/-/cache-3.2.41.tgz",
"integrity": "sha512-uGMhrp+3wnRN67i96mCsf3OswU4UREuQxwujQE1Ti15ESJBdhuDp6mt5L57RbUhNEfLqIRxZMqQCDCj/OLqKXQ==",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.0.1",
"@actions/glob": "^0.1.0",
"@actions/http-client": "^2.1.1",
"@actions/io": "^1.0.1",
"@azure/abort-controller": "^1.1.0",
"@azure/ms-rest-js": "^2.6.0",
"@azure/storage-blob": "^12.13.0",
"semver": "^6.1.0",
"uuid": "^3.3.3"
}
},
"node_modules/@actions/blacksmith-cache/node_modules/@actions/glob": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.1.2.tgz",
"integrity": "sha512-SclLR7Ia5sEqjkJTPs7Sd86maMDw43p769YxBOxvPvEWuPEhpAnBsQfENOpXjFYMmhCqd127bmf+YdvJqVqR4A==",
"dependencies": {
"@actions/core": "^1.2.6",
"minimatch": "^3.0.4"
}
},
"node_modules/@actions/buildjet-cache": {
"name": "github-actions.cache-buildjet",
"version": "0.2.0",

View file

@ -22,6 +22,7 @@
},
"homepage": "https://github.com/Swatinem/rust-cache#readme",
"dependencies": {
"@actions/blacksmith-cache": "npm:@useblacksmith/cache@3.2.41",
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0",
"@actions/cache": "^3.2.3",
"@actions/core": "^1.10.1",

View file

@ -2,6 +2,7 @@ import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as buildjetCache from "@actions/buildjet-cache";
import * as ghCache from "@actions/cache";
import * as bsCache from "@actions/blacksmith-cache";
import fs from "fs";
export function reportError(e: any) {
@ -17,7 +18,7 @@ export function reportError(e: any) {
export async function getCmdOutput(
cmd: string,
args: Array<string> = [],
options: exec.ExecOptions = {},
options: exec.ExecOptions = {}
): Promise<string> {
let stdout = "";
let stderr = "";
@ -51,7 +52,14 @@ export interface CacheProvider {
export function getCacheProvider(): CacheProvider {
const cacheProvider = core.getInput("cache-provider");
const cache = cacheProvider === "github" ? ghCache : cacheProvider === "buildjet" ? buildjetCache : undefined;
const cache =
cacheProvider === "github"
? ghCache
: cacheProvider === "buildjet"
? buildjetCache
: cacheProvider === "blacksmith"
? bsCache
: undefined;
if (!cache) {
throw new Error(`The \`cache-provider\` \`{cacheProvider}\` is not valid.`);