diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38052e1d3..1a758fe9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/action.yml b/action.yml index 3fe474bb9..278036fb3 100644 --- a/action.yml +++ b/action.yml @@ -2,8 +2,8 @@ name: 'Continuous Benchmark' author: 'rhysd ' 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: @@ -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' diff --git a/config.ts b/config.ts index 70ab786ba..086da14dd 100644 --- a/config.ts +++ b/config.ts @@ -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']; @@ -107,6 +108,7 @@ export async function configFromJobInput(): Promise { 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); @@ -115,5 +117,14 @@ export async function configFromJobInput(): Promise { validateName(name); validateAutoPush(autoPush, githubToken); - return { name, tool, outputFilePath, ghPagesBranch, benchmarkDataDirPath, githubToken, autoPush }; + return { + name, + tool, + outputFilePath, + ghPagesBranch, + benchmarkDataDirPath, + githubToken, + autoPush, + skipFetchGhPages, + }; } diff --git a/test/config.ts b/test/config.ts index cce4d022c..cc669ee09 100644 --- a/test/config.ts +++ b/test/config.ts @@ -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); } diff --git a/write.ts b/write.ts index fed75e44e..0ba293d95 100644 --- a/write.ts +++ b/write.ts @@ -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 */ @@ -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(