From 6251861329dac9e9e392e74d1f587756d5980dc0 Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Mon, 3 Jun 2024 11:21:01 +0100 Subject: [PATCH] Restore simpler Bencher setup - run on `main` only (#6220) --- .../{bencher_run.yml => bencher.yml} | 25 ++--- .github/workflows/bencher_process.yml | 104 ------------------ 2 files changed, 12 insertions(+), 117 deletions(-) rename .github/workflows/{bencher_run.yml => bencher.yml} (67%) delete mode 100644 .github/workflows/bencher_process.yml diff --git a/.github/workflows/bencher_run.yml b/.github/workflows/bencher.yml similarity index 67% rename from .github/workflows/bencher_run.yml rename to .github/workflows/bencher.yml index 3976517d085..35cc43a8671 100644 --- a/.github/workflows/bencher_run.yml +++ b/.github/workflows/bencher.yml @@ -3,8 +3,7 @@ name: "Bencher: Run Benchmarks" on: push: branches: main - pull_request: - types: [opened, reopened, edited, synchronize] + workflow_dispatch: jobs: run_benchmarks: @@ -30,14 +29,14 @@ jobs: ./tests.sh -VV -R historical_query ./tests.sh -VV -R commit_latency - - name: Upload Benchmark Results - uses: actions/upload-artifact@v4 - with: - name: BenchmarkResults - path: ./build/bencher.json - - - name: Upload GitHub Pull Request Event - uses: actions/upload-artifact@v4 - with: - name: event.json - path: ${{ github.event_path }} + - uses: bencherdev/bencher@main + - name: Track base branch benchmarks with Bencher + run: | + bencher run \ + --project ccf \ + --token '${{ secrets.BENCHER_API_TOKEN }}' \ + --branch main \ + --testbed gha-virtual-ccf-sub \ + --adapter json \ + --err \ + --file build/bencher.json diff --git a/.github/workflows/bencher_process.yml b/.github/workflows/bencher_process.yml deleted file mode 100644 index 89112b27c7e..00000000000 --- a/.github/workflows/bencher_process.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: "Bencher: Process Benchmarks" - -on: - workflow_run: - workflows: ["Bencher: Run Benchmarks"] - types: [completed] - -jobs: - process_benchmarks: - name: Process benchmarks - permissions: - pull-requests: write - if: github.event.workflow_run.conclusion == 'success' - runs-on: ubuntu-latest - env: - BENCHMARK_RESULTS_ARTIFACT: BenchmarkResults - BENCHMARK_RESULTS_FILE: bencher.json - PR_EVENT: event.json - - steps: - - name: Download Benchmark Results - uses: actions/github-script@v7 - with: - script: | - async function downloadArtifact(artifactName) { - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == artifactName - })[0]; - if (!matchArtifact) { - core.setFailed(`Failed to find artifact: ${artifactName}`); - } - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data)); - } - await downloadArtifact(process.env.BENCHMARK_RESULTS_ARTIFACT); - await downloadArtifact(process.env.PR_EVENT); - - - name: Unzip Benchmark Results - run: | - unzip $BENCHMARK_RESULTS_ARTIFACT.zip - unzip $PR_EVENT.zip - - - name: Export PR Event Data - id: export - uses: actions/github-script@v7 - with: - script: | - let fs = require('fs'); - let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'})); - if (prEvent.pull_request === undefined) { - core.setOutput("is_pr", false); - core.exportVariable("MAIN_HEAD_SHA", prEvent.after); - } else { - core.setOutput("is_pr", true); - core.exportVariable("PR_HEAD", `${prEvent.number}/merge`); - core.exportVariable("PR_BASE", prEvent.pull_request.base.ref); - core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha); - core.exportVariable("PR_HEAD_SHA", prEvent.pull_request.head.sha); - core.exportVariable("PR_NUMBER", prEvent.number); - } - - - uses: bencherdev/bencher@main - - - name: Track Benchmarks with Bencher - run: | - if [[ ${{ steps.export.outputs.is_pr }} == "true" ]]; - then - echo "Uploading PR benchmark results"; - bencher run \ - --project ccf \ - --token '${{ secrets.BENCHER_API_TOKEN }}' \ - --branch '${{ env.PR_HEAD }}' \ - --branch-start-point '${{ env.PR_BASE }}' \ - --branch-start-point-hash '${{ env.PR_BASE_SHA }}' \ - --testbed gha-virtual-ccf-sub \ - --adapter json \ - --err \ - --github-actions '${{ secrets.GITHUB_TOKEN }}' \ - --ci-number '${{ env.PR_NUMBER }}' \ - --hash '${{ env.PR_HEAD_SHA }}' \ - --file "$BENCHMARK_RESULTS_FILE"; - else - echo "Uploading main benchmark results"; - bencher run \ - --project ccf \ - --token '${{ secrets.BENCHER_API_TOKEN }}' \ - --branch main \ - --testbed gha-virtual-ccf-sub \ - --adapter json \ - --err \ - --hash '${{ env.MAIN_HEAD_SHA }}' \ - --file "$BENCHMARK_RESULTS_FILE"; - fi