Skip to content

Commit

Permalink
✨ NEW: add metadata user option key (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Sep 9, 2020
1 parent 4a3689d commit 31c3889
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ inputs:
description: 'Whether to overwrite existing HTML/JS/CSS files on GitHub Pages'
required: false
default: 'true'
metadata:
description: 'Additional metadata to store about the run'
required: false
default: ''

runs:
using: 'node12'
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Config {
chartXAxis: 'id' | 'date';
oneChartGroups: string[];
overwriteAssets: boolean;
metadata: string;
}

const RE_UINT = /^\d+$/;
Expand Down Expand Up @@ -228,6 +229,7 @@ export async function configFromJobInput(): Promise<Config> {
const oneChartGroups = core.getInput('one-chart-groups').split(',');
let failThreshold = getPercentageInput('fail-threshold');
const overwriteAssets = getBoolInput('overwrite-assets');
const metadata = core.getInput('metadata');

outputFilePath = await validateOutputFilePath(outputFilePath);
validateGhPagesBranch(ghPagesBranch);
Expand Down Expand Up @@ -272,5 +274,6 @@ export async function configFromJobInput(): Promise<Config> {
chartXAxis,
oneChartGroups,
overwriteAssets,
metadata,
};
}
3 changes: 3 additions & 0 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export async function extractResult(config: Config): Promise<Benchmark> {
const output = await fs.readFile(config.outputFilePath, 'utf8');

const benches = extractPytestResult(output);
if (config.metadata !== '') {
benches.extra['gh-metadata'] = config.metadata;
}

if (benches.results.length === 0) {
throw new Error(`No benchmark result was found in ${config.outputFilePath}. Benchmark output was '${output}'`);
Expand Down
2 changes: 2 additions & 0 deletions test/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe('writeBenchmark()', function() {
chartXAxis: 'id',
oneChartGroups: [],
overwriteAssets: false,
metadata: '',
};

const savedRepository = gitHubContext.payload.repository;
Expand Down Expand Up @@ -834,6 +835,7 @@ describe('writeBenchmark()', function() {
chartXAxis: 'id',
oneChartGroups: [],
overwriteAssets: false,
metadata: '',
};

function gitHistory(
Expand Down

0 comments on commit 31c3889

Please sign in to comment.