Skip to content

Commit

Permalink
prepare release of 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikmuhs committed Mar 24, 2022
1 parent 435eb33 commit 6552c3c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Works on Linux, macOS, and Windows.
```yaml
- run: apt update # Only for Docker jobs
- name: ccache
uses: hendrikmuhs/ccache-action@v1.1
uses: hendrikmuhs/ccache-action@v1.2
```
NB! This should always come after the `actions/checkout` step.
Expand All @@ -18,7 +18,7 @@ For sccache, use:

```yaml
- name: ccache
uses: hendrikmuhs/ccache-action@v1.1
uses: hendrikmuhs/ccache-action@v1.2
with:
variant: sccache
```
Expand Down Expand Up @@ -57,7 +57,7 @@ You can also specify the maximum cache size - default `500M` (500 MB).

```yaml
- name: ccache
uses: hendrikmuhs/ccache-action@v1.1
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ matrix.os }}-${{ matrix.type }}
max-size: 100M
Expand Down
63 changes: 37 additions & 26 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58323,7 +58323,6 @@ async function restore(ccacheVariant) {
async function configure(ccacheVariant) {
const ghWorkSpace = external_process_namespaceObject.env.GITHUB_WORKSPACE || "unreachable, make ncc happy";
const maxSize = core.getInput('max-size');
core.info(`Configure ${ccacheVariant}`);
if (ccacheVariant === "ccache") {
await execBash(`ccache --set-config=cache_dir='${external_path_default().join(ghWorkSpace, '.ccache')}'`);
await execBash(`ccache --set-config=max_size='${maxSize}'`);
Expand All @@ -58332,15 +58331,15 @@ async function configure(ccacheVariant) {
await execBash("ccache -p");
}
else {
const options = `SCCACHE_IDLE_TIMEOUT=999999 SCCACHE_DIR='${ghWorkSpace}'/.sccache SCCACHE_CACHE_SIZE='${maxSize}'`;
const options = `SCCACHE_IDLE_TIMEOUT=0 SCCACHE_DIR='${ghWorkSpace}'/.sccache SCCACHE_CACHE_SIZE='${maxSize}'`;
await execBash(`env ${options} sccache --start-server`);
}
}
async function installCcacheMac() {
await execBash("brew install ccache");
}
async function installCcacheLinux() {
await execBash("sudo apt-get install -y ccache");
await execBashSudo("apt-get install -y ccache");
}
async function installCcacheWindows() {
await installCcacheFromGitHub("4.6", "windows-64", "e721aac12692e35fb644c801f3ad1af66d88c3ac5ba10fbe6bdacc347e2a0e3f",
Expand All @@ -58361,6 +58360,9 @@ async function installSccacheWindows() {
async function execBash(cmd) {
await exec.exec("bash", ["-xc", cmd]);
}
async function execBashSudo(cmd) {
await execBash("$(which sudo) " + cmd);
}
async function installCcacheFromGitHub(version, artifactName, binSha256, binDir, binName) {
const archiveName = `ccache-${version}-${artifactName}`;
const url = `https://github.com/ccache/ccache/releases/download/v${version}/${archiveName}.zip`;
Expand Down Expand Up @@ -58397,31 +58399,40 @@ function checkSha256Sum(path, expectedSha256) {
throw Error(`SHA256 of ${path} is ${actualSha256}, expected ${expectedSha256}`);
}
}
async function runInner() {
const ccacheVariant = core.getInput("variant");
core.saveState("ccacheVariant", ccacheVariant);
core.saveState("shouldSave", core.getBooleanInput("save"));
let ccachePath = await io.which(ccacheVariant);
if (!ccachePath) {
core.startGroup(`Install ${ccacheVariant}`);
const installer = {
["ccache,linux"]: installCcacheLinux,
["ccache,darwin"]: installCcacheMac,
["ccache,win32"]: installCcacheWindows,
["sccache,linux"]: installSccacheLinux,
["sccache,darwin"]: installSccacheMac,
["sccache,win32"]: installSccacheWindows,
}[[ccacheVariant, external_process_namespaceObject.platform].join()];
if (!installer) {
throw Error(`Unsupported platform: ${external_process_namespaceObject.platform}`);
}
await installer();
core.info(await io.which(ccacheVariant + ".exe"));
ccachePath = await io.which(ccacheVariant, true);
core.endGroup();
}
core.startGroup("Restore cache");
await restore(ccacheVariant);
core.endGroup();
core.startGroup(`Configure ${ccacheVariant}`);
await configure(ccacheVariant);
await execBash(`${ccacheVariant} -z`);
core.endGroup();
}
async function run() {
try {
const ccacheVariant = core.getInput("variant");
core.saveState("ccacheVariant", ccacheVariant);
let ccachePath = await io.which(ccacheVariant);
if (!ccachePath) {
core.info(`Install ${ccacheVariant}`);
const installer = {
["ccache,linux"]: installCcacheLinux,
["ccache,darwin"]: installCcacheMac,
["ccache,win32"]: installCcacheWindows,
["sccache,linux"]: installSccacheLinux,
["sccache,darwin"]: installSccacheMac,
["sccache,win32"]: installSccacheWindows,
}[[ccacheVariant, external_process_namespaceObject.platform].join()];
if (!installer) {
throw Error(`Unsupported platform: ${external_process_namespaceObject.platform}`);
}
await installer();
core.info(await io.which(ccacheVariant + ".exe"));
ccachePath = await io.which(ccacheVariant, true);
}
await restore(ccacheVariant);
await configure(ccacheVariant);
await execBash(`${ccacheVariant} -z`);
await runInner();
}
catch (error) {
core.setFailed(`Restoring cache failed: ${error}`);
Expand Down
13 changes: 9 additions & 4 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58269,14 +58269,14 @@ __nccwpck_require__.r(__webpack_exports__);
async function ccacheIsEmpty(ccacheVariant, ccacheKnowsVerbosityFlag) {
if (ccacheVariant === "ccache") {
if (ccacheKnowsVerbosityFlag) {
return !!(await getExecBashOutput("ccache -s -v")).stdout.match(/Files:.+0/);
return !!(await getExecBashOutput("ccache -s -v")).stdout.match(/Files:.+\b0\b/);
}
else {
return !!(await getExecBashOutput("ccache -s")).stdout.match(/files in cache.+0/);
return !!(await getExecBashOutput("ccache -s")).stdout.match(/files in cache.+\b0\b/);
}
}
else {
return !!(await getExecBashOutput("sccache -s")).stdout.match(/Cache size.+0 bytes/);
return !!(await getExecBashOutput("sccache -s")).stdout.match(/Cache size.+\b0 bytes/);
}
}
async function getVerbosity(verbositySetting) {
Expand All @@ -58297,6 +58297,10 @@ function getExecBashOutput(cmd) {
}
async function run() {
try {
if (_actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("shouldSave") !== "true") {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info("Not saving cache because 'save' is set to 'false'.");
return;
}
const ccacheVariant = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("ccacheVariant");
const primaryKey = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("primaryKey");
if (!ccacheVariant || !primaryKey) {
Expand All @@ -58305,9 +58309,10 @@ async function run() {
}
// Some versions of ccache do not support --verbose
const ccacheKnowsVerbosityFlag = !!(await getExecBashOutput(`${ccacheVariant} --help`)).stdout.includes("--verbose");
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`${ccacheVariant} stats:`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.startGroup(`${ccacheVariant} stats`);
const verbosity = ccacheKnowsVerbosityFlag ? await getVerbosity(_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("verbose")) : '';
await _actions_exec__WEBPACK_IMPORTED_MODULE_2__.exec(`${ccacheVariant} -s${verbosity}`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.endGroup();
if (await ccacheIsEmpty(ccacheVariant, ccacheKnowsVerbosityFlag)) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info("Not saving cache because no objects are cached.");
}
Expand Down

0 comments on commit 6552c3c

Please sign in to comment.