mirror of
https://github.com/Mozilla-Actions/sccache-action.git
synced 2026-04-14 18:51:47 +08:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbf689686c | ||
|
|
b08827a805 | ||
|
|
c41c02b356 | ||
|
|
1b907c38b9 | ||
|
|
17f1652a56 | ||
|
|
9d29337feb | ||
|
|
91401894d5 | ||
|
|
09ad278de7 | ||
|
|
bafd42bd91 | ||
|
|
031a5729cc | ||
|
|
944c5dd5a3 | ||
|
|
0ee70161fd | ||
|
|
f3c286174b | ||
|
|
9b4b4271a2 | ||
|
|
362fd1f28a | ||
|
|
306a86b3f6 | ||
|
|
afdb6b9946 | ||
|
|
f136be3826 | ||
|
|
8690384f78 | ||
|
|
bb39a37bf6 | ||
|
|
4097539ece | ||
|
|
e54ef79281 | ||
|
|
b15a83f9da | ||
|
|
21fd90ad71 | ||
|
|
5418419c3e | ||
|
|
80b4af770d | ||
|
|
407a484056 | ||
|
|
7d986dd989 | ||
|
|
c3f03b40d2 | ||
|
|
213d335d8b | ||
|
|
65101d47ea | ||
|
|
784917c172 | ||
|
|
1220c18210 | ||
|
|
33f5b948b5 | ||
|
|
8bd7e91bd3 | ||
|
|
a2b43af3c6 | ||
|
|
a675e5f637 | ||
|
|
7017114a0a | ||
|
|
71e3ab63ec | ||
|
|
e5565ffc35 | ||
|
|
07cfce30d5 | ||
|
|
8762d1df13 | ||
|
|
7c8e5e8b71 | ||
|
|
f87751abbf | ||
|
|
2ed8afefeb | ||
|
|
20fc08460b | ||
|
|
3e928dd227 | ||
|
|
dacc35634d | ||
|
|
4b84fe43b3 | ||
|
|
c46e041092 | ||
|
|
678555f65b | ||
|
|
3e3251da34 | ||
|
|
dd3d4cb902 | ||
|
|
f4fe0d59ea | ||
|
|
c040d89fcb | ||
|
|
1998e5d367 | ||
|
|
135e550fd0 | ||
|
|
054db53350 | ||
|
|
0f3ae50cf4 | ||
|
|
3d1446595f | ||
|
|
42761b0ed4 | ||
|
|
e21e59b7e7 | ||
|
|
2e63a0d136 | ||
|
|
4cdf591d8d | ||
|
|
39c9c60c3e | ||
|
|
178695770d | ||
|
|
843e5625f6 | ||
|
|
909297fe93 | ||
|
|
e30706368a | ||
|
|
34bf681ca2 | ||
|
|
8d2a651e78 | ||
|
|
fd63487abf | ||
|
|
68f7f867ba | ||
|
|
c67e42e27c | ||
|
|
86570eb559 | ||
|
|
25839b6484 | ||
|
|
c83ccfeb86 | ||
|
|
859e32b514 | ||
|
|
cd37596050 | ||
|
|
1f3e7143d9 |
33
.github/workflows/CI.yml
vendored
33
.github/workflows/CI.yml
vendored
@@ -21,9 +21,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: npm
|
||||
@@ -52,10 +52,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: npm
|
||||
@@ -71,3 +71,28 @@ jobs:
|
||||
- name: Run sccache for check
|
||||
shell: bash
|
||||
run: ${SCCACHE_PATH} --start-server
|
||||
|
||||
test_disable_annotations:
|
||||
name: Test disable_annotations version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: npm
|
||||
|
||||
- name: npm install
|
||||
run: npm install
|
||||
|
||||
- name: Run sccache-cache
|
||||
uses: ./
|
||||
with:
|
||||
disable_annotations: true
|
||||
|
||||
- name: Run sccache for check
|
||||
shell: bash
|
||||
run: ${SCCACHE_PATH} --start-server
|
||||
|
||||
26
README.md
26
README.md
@@ -16,7 +16,7 @@ Just copy and paste the following in your GitHub action:
|
||||
|
||||
```
|
||||
- name: Run sccache-cache
|
||||
uses: mozilla-actions/sccache-action@v0.0.6
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
```
|
||||
|
||||
### Conditionally run cache and enable it
|
||||
@@ -24,7 +24,7 @@ Just copy and paste the following in your GitHub action:
|
||||
```
|
||||
- name: Run sccache-cache only on non-release runs
|
||||
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
|
||||
uses: mozilla-actions/sccache-action@v0.0.6
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
- name: Set Rust caching env vars only on non-release runs
|
||||
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
|
||||
run: |
|
||||
@@ -34,11 +34,13 @@ Just copy and paste the following in your GitHub action:
|
||||
|
||||
### Specify a given version of sccache
|
||||
|
||||
Versions prior to sccache v0.10.0 probably will not work.
|
||||
|
||||
```
|
||||
- name: Run sccache-cache
|
||||
uses: mozilla-actions/sccache-action@v0.0.6
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
with:
|
||||
version: "v0.7.4"
|
||||
version: "v0.10.0"
|
||||
```
|
||||
|
||||
### To get the execution stats
|
||||
@@ -52,6 +54,15 @@ Note that using the previous declaration will automatically create a
|
||||
run: ${SCCACHE_PATH} --show-stats
|
||||
```
|
||||
|
||||
### disable stats report
|
||||
|
||||
```
|
||||
- name: Run sccache-cache
|
||||
uses: mozilla-actions/sccache-action
|
||||
with:
|
||||
disable_annotations: true
|
||||
```
|
||||
|
||||
### Rust code
|
||||
|
||||
For Rust code, the following environment variables should be set:
|
||||
@@ -92,7 +103,7 @@ When using the action on GitHub Enterprise Server installations a valid GitHub.c
|
||||
|
||||
```
|
||||
- name: Run sccache-cache
|
||||
uses: mozilla-actions/sccache-action@v0.0.6
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
with:
|
||||
token: ${{ secrets.MY_GITHUB_TOKEN }}
|
||||
```
|
||||
@@ -104,7 +115,10 @@ Note that using https://github.com/actions/create-github-app-token is a better o
|
||||
1. Update the example in README.md
|
||||
1. Update version in `package.json`
|
||||
1. Run `npm i --package-lock-only`
|
||||
1. Tag a new release
|
||||
1. Run `npm run build`
|
||||
1. Commit and push the local changes
|
||||
1. Tag a new release (vX.X.X)
|
||||
1. Create a new release in github
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ inputs:
|
||||
token:
|
||||
description: "Used to pull the latest release from sccache. When running this action outside of github.com, you have to pass a personal access token for github.com."
|
||||
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||
disable_annotations:
|
||||
description: "Disable annotation generation in post-run."
|
||||
default: 'false'
|
||||
runs:
|
||||
using: "node20"
|
||||
main: "dist/setup/index.js"
|
||||
|
||||
6
dist/setup/index.js
vendored
6
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
6
dist/show_stats/index.js
vendored
6
dist/show_stats/index.js
vendored
File diff suppressed because one or more lines are too long
1666
package-lock.json
generated
1666
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sccache-action",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.9",
|
||||
"description": "Github Action for Sccache",
|
||||
"main": "dist/setup/index.js",
|
||||
"engines": {
|
||||
@@ -28,25 +28,25 @@
|
||||
},
|
||||
"homepage": "https://github.com/mozilla-actions/sccache-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/io": "^1.1.3",
|
||||
"@actions/tool-cache": "^2.0.1"
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@actions/io": "^2.0.0",
|
||||
"@actions/tool-cache": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.14.11",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.13.17",
|
||||
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
||||
"@typescript-eslint/parser": "^7.11.0",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jest": "^28.6.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-jest": "^29.2.5",
|
||||
"typescript": "^5.6.2"
|
||||
"prettier": "^3.5.3",
|
||||
"ts-jest": "^29.4.6",
|
||||
"typescript": "^5.8.2"
|
||||
}
|
||||
}
|
||||
|
||||
23
src/setup.ts
23
src/setup.ts
@@ -66,9 +66,15 @@ async function setup() {
|
||||
// Expose the sccache path as env.
|
||||
core.exportVariable('SCCACHE_PATH', `${sccacheHome}/sccache`);
|
||||
|
||||
// Force the github action v2
|
||||
core.exportVariable('ACTIONS_CACHE_SERVICE_V2', `on`);
|
||||
|
||||
// Expose the gha cache related variable to make it easier for users to
|
||||
// integrate with gha support.
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable(
|
||||
'ACTIONS_RESULTS_URL',
|
||||
process.env.ACTIONS_RESULTS_URL || ''
|
||||
);
|
||||
core.exportVariable(
|
||||
'ACTIONS_RUNTIME_TOKEN',
|
||||
process.env.ACTIONS_RUNTIME_TOKEN || ''
|
||||
@@ -129,6 +135,8 @@ function getArch(): Error | string {
|
||||
return 'x86_64';
|
||||
case 'arm64':
|
||||
return 'aarch64';
|
||||
case 'arm':
|
||||
return 'armv7';
|
||||
default:
|
||||
return Error(`Unsupported arch "${process.arch}"`);
|
||||
}
|
||||
@@ -141,19 +149,18 @@ function getPlatform(): Error | string {
|
||||
case 'win32':
|
||||
return 'pc-windows-msvc';
|
||||
case 'linux':
|
||||
return 'unknown-linux-musl';
|
||||
if (process.arch == 'arm') {
|
||||
return 'unknown-linux-musleabi';
|
||||
} else {
|
||||
return 'unknown-linux-musl';
|
||||
}
|
||||
default:
|
||||
return Error(`Unsupported platform "${process.platform}"`);
|
||||
}
|
||||
}
|
||||
|
||||
function getExtension(): string {
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
return 'zip';
|
||||
default:
|
||||
return 'tar.gz';
|
||||
}
|
||||
return 'tar.gz';
|
||||
}
|
||||
|
||||
setup().catch(err => {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import {context} from '@actions/github';
|
||||
import * as exec from '@actions/exec';
|
||||
import {SummaryTableRow} from '@actions/core/lib/summary';
|
||||
|
||||
@@ -29,6 +30,12 @@ async function get_output(command: string, args: string[]): Promise<string> {
|
||||
}
|
||||
|
||||
async function show_stats() {
|
||||
const disable_annotations = core.getBooleanInput('disable_annotations');
|
||||
if (disable_annotations) {
|
||||
core.debug('annotations generation disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
core.debug('start sccache show starts');
|
||||
const human_stats = await core.group('Get human-readable stats', async () => {
|
||||
return get_output(`${process.env.SCCACHE_PATH}`, ['--show-stats']);
|
||||
@@ -44,8 +51,9 @@ async function show_stats() {
|
||||
const formatted_stats = format_json_stats(stats);
|
||||
|
||||
core.notice(formatted_stats.notice, {
|
||||
title: 'sccache stats'
|
||||
title: `sccache stats - ${context.job}`
|
||||
});
|
||||
|
||||
core.info('\nFull human-readable stats:');
|
||||
core.info(human_stats);
|
||||
|
||||
@@ -125,7 +133,10 @@ function format_json_stats(stats: Stats): {
|
||||
stats.stats.compiler_write_duration
|
||||
);
|
||||
|
||||
const notice = `${ratio}% - ${cache_hit_count} hits, ${cache_miss_count} misses, ${cache_error_count} errors`;
|
||||
const notice_hit = plural(cache_hit_count, 'hit');
|
||||
const notice_miss = plural(cache_miss_count, 'miss', 'misses');
|
||||
const notice_error = plural(cache_error_count, 'error');
|
||||
const notice = `${ratio}% - ${notice_hit}, ${notice_miss}, ${notice_error}`;
|
||||
|
||||
const table = [
|
||||
[{data: 'Cache hit %', header: true}, {data: `${ratio}%`}],
|
||||
@@ -161,3 +172,7 @@ function format_json_stats(stats: Stats): {
|
||||
function percentage(x: number, y: number): number {
|
||||
return Math.round((x / y) * 100 || 0);
|
||||
}
|
||||
|
||||
function plural(count: number, base: string, plural = base + 's'): string {
|
||||
return `${count} ${count === 1 ? base : plural}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user