Restore simpler Bencher setup - run on `main` only (#6220)

This commit is contained in:
Eddy Ashton 2024-06-03 11:21:01 +01:00 коммит произвёл GitHub
Родитель 5eddfe7a85
Коммит 6251861329
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 12 добавлений и 117 удалений

Просмотреть файл

@ -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

104
.github/workflows/bencher_process.yml поставляемый
Просмотреть файл

@ -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