mirror of
https://github.com/Mozilla-Actions/sccache-action.git
synced 2026-04-08 17:42:13 +08:00
Merge pull request #212 from wetheredge/tweak-notice
Add job id to annotation title
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {context} from '@actions/github';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import {SummaryTableRow} from '@actions/core/lib/summary';
|
import {SummaryTableRow} from '@actions/core/lib/summary';
|
||||||
|
|
||||||
@@ -50,8 +51,9 @@ async function show_stats() {
|
|||||||
const formatted_stats = format_json_stats(stats);
|
const formatted_stats = format_json_stats(stats);
|
||||||
|
|
||||||
core.notice(formatted_stats.notice, {
|
core.notice(formatted_stats.notice, {
|
||||||
title: 'sccache stats'
|
title: `sccache stats - ${context.job}`
|
||||||
});
|
});
|
||||||
|
|
||||||
core.info('\nFull human-readable stats:');
|
core.info('\nFull human-readable stats:');
|
||||||
core.info(human_stats);
|
core.info(human_stats);
|
||||||
|
|
||||||
@@ -131,7 +133,10 @@ function format_json_stats(stats: Stats): {
|
|||||||
stats.stats.compiler_write_duration
|
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 = [
|
const table = [
|
||||||
[{data: 'Cache hit %', header: true}, {data: `${ratio}%`}],
|
[{data: 'Cache hit %', header: true}, {data: `${ratio}%`}],
|
||||||
@@ -167,3 +172,7 @@ function format_json_stats(stats: Stats): {
|
|||||||
function percentage(x: number, y: number): number {
|
function percentage(x: number, y: number): number {
|
||||||
return Math.round((x / y) * 100 || 0);
|
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