-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abf06fd
commit a83c88f
Showing
9 changed files
with
111,410 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,6 @@ typings/ | |
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: "C-Cache for gh actions" | ||
description: "A GitHub Action that speeds up compiling for C/C++ projects." | ||
author: "Hendrik Muhs<[email protected]>" | ||
inputs: | ||
key: | ||
description: "An additional key for the cache" | ||
required: false | ||
runs: | ||
using: "node12" | ||
main: "dist/restore/index.js" | ||
post: "dist/save/index.js" | ||
post-if: "success()" | ||
branding: | ||
icon: "archive" | ||
color: "gray-dark" |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "ccache-action", | ||
"version": "1.0.0", | ||
"description": "github action to speedup building using ccache", | ||
"main": "dist/restore/index.js", | ||
"scripts": { | ||
"prepare": "ncc build --target es2020 -o dist/restore src/restore.ts && ncc build --target es2020 -o dist/save src/save.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hendrikmuhs/ccache-action.git" | ||
}, | ||
"keywords": [ | ||
"actions", | ||
"ccache", | ||
"cache", | ||
"c++", | ||
"cpp", | ||
"c" | ||
], | ||
"author": "Hendrik Muhs", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@actions/cache": "^1.0.4", | ||
"@actions/core": "^1.2.6", | ||
"@actions/exec": "^1.0.4", | ||
"@actions/io": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@vercel/ncc": "^0.25.1", | ||
"typescript": "^4.1.2" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hendrikmuhs/ccache-action/issues" | ||
}, | ||
"homepage": "https://github.com/hendrikmuhs/ccache-action#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as core from "@actions/core"; | ||
import * as io from "@actions/io"; | ||
import * as exec from "@actions/exec"; | ||
import * as process from "process"; | ||
import * as cache from "@actions/cache"; | ||
|
||
// based on https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/ | ||
|
||
async function install() { | ||
if (process.platform === "darwin") { | ||
await exec.exec("brew install ccache"); | ||
} else { | ||
await exec.exec("apt-get update"); | ||
await exec.exec("apt-get install -y ccache"); | ||
} | ||
} | ||
|
||
async function restore() { | ||
let restoreKey = `ccache-`; | ||
|
||
let inputKey = core.getInput("key"); | ||
if (inputKey) { | ||
restoreKey += `${inputKey}-`; | ||
} | ||
|
||
const restoreKeys = [ | ||
restoreKey | ||
] | ||
|
||
const key = restoreKey + "-" + new Date().toUTCString(); | ||
const paths = [ | ||
'.ccache' | ||
] | ||
|
||
await cache.restoreCache(paths, key, restoreKeys) | ||
} | ||
|
||
async function configure() { | ||
const ghWorkSpace = process.env.GITHUB_WORKSPACE; | ||
|
||
core.info("Configure ccache"); | ||
await exec.exec("ccache --set-config=cache_dir=" + ghWorkSpace + "/.ccache"); | ||
await exec.exec("ccache --set-config=max_size=500M"); | ||
await exec.exec("ccache --set-config=compression=true"); | ||
|
||
core.info("Ccache config:") | ||
await exec.exec("ccache -p"); | ||
} | ||
|
||
async function run() { | ||
let ccachePath = await io.which("ccache"); | ||
if (!ccachePath) { | ||
core.info(`Install ccache`); | ||
await install(); | ||
ccachePath = await io.which("ccache", true); | ||
} | ||
|
||
await restore(); | ||
await configure(); | ||
|
||
await exec.exec("ccache -z"); | ||
} | ||
|
||
try { | ||
run(); | ||
} catch (err) { | ||
core.setFailed(`Action failed with error ${err}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as core from "@actions/core"; | ||
import * as cache from "@actions/cache"; | ||
|
||
async function run() { | ||
let restoreKey = `ccache-`; | ||
let inputKey = core.getInput("key"); | ||
|
||
if (inputKey) { | ||
restoreKey += `${inputKey}-`; | ||
} | ||
|
||
const key = restoreKey + "-" + new Date().toUTCString(); | ||
const paths = [ | ||
'.ccache' | ||
] | ||
|
||
await cache.saveCache(paths, key) | ||
} | ||
|
||
try { | ||
run(); | ||
} catch (err) { | ||
core.setFailed(`Action failed with error ${err}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"noEmitOnError": false, | ||
"diagnostics": true, | ||
"lib": ["esnext"], | ||
|
||
"target": "es2020", | ||
|
||
"resolveJsonModule": true, | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"esModuleInterop": true, | ||
|
||
"strict": true, | ||
"skipLibCheck": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true | ||
}, | ||
"exclude": ["dist"] | ||
} |