Skip to content

Commit

Permalink
add skip-fetch-gh-pages input and use it in CI check
Browse files Browse the repository at this point in the history
for ensuring to remove the effect from other jobs
  • Loading branch information
rhysd committed Nov 17, 2019
1 parent 616a5ef commit 1ac7aa0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
name: Rust Benchmark
tool: 'cargo'
output-file-path: examples/rust/output.txt
skip-fetch-gh-pages: true
- run: node ./scripts/ci_validate_modification.js before_data.js 'Rust Benchmark'
go:
name: Run Go benchmark example
Expand Down Expand Up @@ -59,6 +60,7 @@ jobs:
name: Go Benchmark
tool: 'go'
output-file-path: examples/go/output.txt
skip-fetch-gh-pages: true
- run: node ./scripts/ci_validate_modification.js before_data.js 'Go Benchmark'
benchmarkjs:
name: Run JavaScript benchmark example
Expand Down Expand Up @@ -87,6 +89,7 @@ jobs:
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: examples/benchmarkjs/output.txt
skip-fetch-gh-pages: true
- run: node ./scripts/ci_validate_modification.js before_data.js 'Benchmark.js Benchmark'
pytest-benchmark:
name: Run Pytest benchmark example
Expand Down Expand Up @@ -119,6 +122,7 @@ jobs:
name: Python Benchmark with pytest-benchmark
tool: 'pytest'
output-file-path: examples/pytest/output.json
skip-fetch-gh-pages: true
- run: node ./scripts/ci_validate_modification.js before_data.js 'Python Benchmark with pytest-benchmark'
unit-tests:
name: Run unit tests
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: 'Continuous Benchmark'
author: 'rhysd <https://rhysd.github.io>'
description: 'Continuous Benchmark using GitHub pages as dash board for keeping performance'
branding:
icon: 'fast-forward'
color: 'blue'
icon: 'fast-forward'
color: 'blue'

inputs:
name:
Expand Down Expand Up @@ -31,6 +31,10 @@ inputs:
description: 'Push GitHub Pages branch to remote automatically. This option requires github-token input'
required: false
default: false
skip-fetch-gh-pages:
description: 'Skip pulling GitHub Pages branch before generating an auto commit'
required: false
default: false

runs:
using: 'node12'
Expand Down
13 changes: 12 additions & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Config {
benchmarkDataDirPath: string;
githubToken: string | undefined;
autoPush: boolean;
skipFetchGhPages: boolean;
}

export const VALID_TOOLS: ToolType[] = ['cargo', 'go', 'benchmarkjs', 'pytest'];
Expand Down Expand Up @@ -107,6 +108,7 @@ export async function configFromJobInput(): Promise<Config> {
const name: string = core.getInput('name');
const githubToken: string | undefined = core.getInput('github-token') || undefined;
const autoPush = getBoolInput('auto-push');
const skipFetchGhPages = getBoolInput('skip-fetch-gh-pages');

validateToolType(tool);
outputFilePath = await validateOutputFilePath(outputFilePath);
Expand All @@ -115,5 +117,14 @@ export async function configFromJobInput(): Promise<Config> {
validateName(name);
validateAutoPush(autoPush, githubToken);

return { name, tool, outputFilePath, ghPagesBranch, benchmarkDataDirPath, githubToken, autoPush };
return {
name,
tool,
outputFilePath,
ghPagesBranch,
benchmarkDataDirPath,
githubToken,
autoPush,
skipFetchGhPages,
};
}
1 change: 1 addition & 0 deletions test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function mockInputs(newInputs: Inputs) {
delete inputs['benchmark-data-dir-path'];
delete inputs['github-token'];
delete inputs['auto-push'];
delete inputs['skip-fetch-gh-pages'];
Object.assign(inputs, newInputs);
}

Expand Down
4 changes: 2 additions & 2 deletions write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function pushGitHubPages(token: string, branch: string) {
}

export async function writeBenchmark(bench: Benchmark, config: Config) {
const { name, tool, ghPagesBranch, benchmarkDataDirPath, githubToken, autoPush } = config;
const { name, tool, ghPagesBranch, benchmarkDataDirPath, githubToken, autoPush, skipFetchGhPages } = config;
const dataPath = path.join(benchmarkDataDirPath, 'data.js');

/* eslint-disable @typescript-eslint/camelcase */
Expand All @@ -95,7 +95,7 @@ export async function writeBenchmark(bench: Benchmark, config: Config) {
await git.cmd('switch', ghPagesBranch);

try {
if (!isPrivateRepo || githubToken) {
if (!skipFetchGhPages && (!isPrivateRepo || githubToken)) {
await git.pull(githubToken, ghPagesBranch);
} else if (isPrivateRepo) {
core.warning(
Expand Down

0 comments on commit 1ac7aa0

Please sign in to comment.