Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ NEW: add metadata user option key #3

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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