Add BuildJet Option (#154)
This commit is contained in:
parent
9de8f90afb
commit
b00faf5858
|
@ -29,3 +29,33 @@ jobs:
|
|||
cargo test
|
||||
cargo build --release
|
||||
working-directory: tests
|
||||
simple-buildjet:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
name: Test `cargo check/test` on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# When rustup is updated, it tries to replace its binary, which on Windows is somehow locked.
|
||||
# This can result in the CI failure, see: https://github.com/rust-lang/rustup/issues/3029
|
||||
- run: |
|
||||
rustup set auto-self-update disable
|
||||
rustup toolchain install stable --profile minimal
|
||||
|
||||
- uses: ./
|
||||
with:
|
||||
workspaces: tests
|
||||
cache-provider: buildjet
|
||||
|
||||
- run: |
|
||||
cargo check
|
||||
cargo test
|
||||
working-directory: tests
|
||||
|
|
|
@ -65,6 +65,11 @@ sensible defaults.
|
|||
# Useful for jobs where the matrix is additive e.g. additional Cargo features.
|
||||
# default: "true"
|
||||
save-if: ""
|
||||
|
||||
# Specifies what to use as the backend providing cache
|
||||
# Can be set to either "github" or "buildjet"
|
||||
# default: "github"
|
||||
cache-provider: ""
|
||||
```
|
||||
|
||||
Further examples are available in the [.github/workflows](./.github/workflows/) directory.
|
||||
|
|
|
@ -36,6 +36,10 @@ inputs:
|
|||
description: "Determiners whether the cache should be saved. If `false`, the cache is only restored."
|
||||
required: false
|
||||
default: "true"
|
||||
cache-provider:
|
||||
description: "Determines which provider to use for caching. Options are github or buildjet, defaults to github."
|
||||
required: false
|
||||
default: "github"
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: "A boolean value that indicates an exact match was found."
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -9,6 +9,7 @@
|
|||
"version": "2.5.1",
|
||||
"license": "LGPL-3.0",
|
||||
"dependencies": {
|
||||
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.1.2",
|
||||
"@actions/cache": "^3.2.1",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
|
@ -25,6 +26,30 @@
|
|||
"url": "https://github.com/sponsors/Swatinem"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/buildjet-cache": {
|
||||
"name": "github-actions.cache-buildjet",
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/github-actions.cache-buildjet/-/github-actions.cache-buildjet-0.1.2.tgz",
|
||||
"integrity": "sha512-mBgIxCYgDDSzkCCK1/DbVF36K0k2uaSx+Dk4LANat8KMzq7XtYK96ZnS7/fOosqzjtK7AlZtXsBkOoY5NKlcHw==",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/glob": "^0.1.0",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/buildjet-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/cache": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.1.tgz",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/Swatinem/rust-cache#readme",
|
||||
"dependencies": {
|
||||
"@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.1.2",
|
||||
"@actions/cache": "^3.2.1",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { cleanTargetDir } from "./cleanup";
|
||||
import { CacheConfig } from "./config";
|
||||
import { getCacheHandler } from "./utils";
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
core.error(e.message);
|
||||
|
@ -12,6 +12,8 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cache = getCacheHandler();
|
||||
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
setCacheHitOutput(false);
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
import { cleanBin, cleanGit, cleanRegistry, cleanTargetDir } from "./cleanup";
|
||||
import { CacheConfig, isCacheUpToDate } from "./config";
|
||||
import { getCacheHandler } from "./utils";
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
core.error(e.message);
|
||||
|
@ -13,6 +13,8 @@ process.on("uncaughtException", (e) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
const cache = getCacheHandler();
|
||||
|
||||
const save = core.getInput("save-if").toLowerCase() || "true";
|
||||
|
||||
if (!(cache.isFeatureAvailable() && save === "true")) {
|
||||
|
|
16
src/utils.ts
16
src/utils.ts
|
@ -1,3 +1,5 @@
|
|||
import * as buildjetCache from "@actions/buildjet-cache";
|
||||
import * as ghCache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
import * as exec from "@actions/exec";
|
||||
|
||||
|
@ -28,3 +30,17 @@ export async function getCmdOutput(
|
|||
}
|
||||
return stdout;
|
||||
}
|
||||
|
||||
export function getCacheHandler() {
|
||||
const cacheProvider = core.getInput("cache-provider");
|
||||
switch (cacheProvider) {
|
||||
case 'github':
|
||||
core.info ("Using Github Cache.");
|
||||
return ghCache;
|
||||
case 'buildjet':
|
||||
core.info ("Using Buildjet Cache.");
|
||||
return buildjetCache;
|
||||
default:
|
||||
throw new Error("Only currently support github and buildjet caches");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue