Skip to content

Publish benchmark results #732

Publish benchmark results

Publish benchmark results #732

name: Publish benchmark results
on:
workflow_run:
workflows: ["CI build"]
types:
- completed
jobs:
push-to-data-repo:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download benchmark results from workflow artifacts
uses: actions/[email protected]
id: download-results
with:
result-encoding: string
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
if (artifacts.data.artifacts.length === 0) {
return 'stop';
}
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "benchmark-results"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/benchmark-results.zip', Buffer.from(download.data));
return 'continue';
- run: unzip benchmark-results.zip
if: ${{ steps.download-results.outputs.result == 'continue' }}
- name: Set VERSION/B_SHA/B_EVENT env variable
run: |
VERSION=$(cat version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
B_SHA=$(cat sha)
echo "B_SHA=$B_SHA" >> $GITHUB_ENV
B_EVENT=$(cat event)
echo "B_EVENT=$B_EVENT" >> $GITHUB_ENV
if: ${{ steps.download-results.outputs.result == 'continue' }}
- name: Push benchmark file
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.RESULTS_REPO_RW_TOKEN }}
with:
source_file: '${{ env.B_EVENT }}/${{ env.B_SHA }}/${{ env.VERSION }}.json'
destination_folder: '${{ env.B_EVENT }}/${{ env.B_SHA }}'
destination_repo: 'scalalandio/chimney-benchmark-results'
user_email: '[email protected]'
user_name: 'Mateusz Kubuszok'
commit_message: 'Benchmarks for ${{ env.VERSION }} added.'
if: ${{ steps.download-results.outputs.result == 'continue' }}
- name: Push meta file
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.RESULTS_REPO_RW_TOKEN }}
with:
source_file: 'meta.json'
destination_repo: 'scalalandio/chimney-benchmark-results'
user_email: '[email protected]'
user_name: 'Mateusz Kubuszok'
commit_message: 'Meta update for ${{ env.VERSION }}'
if: ${{ steps.download-results.outputs.result == 'continue' }}