Skip to content

Commit

Permalink
update upload job
Browse files Browse the repository at this point in the history
  • Loading branch information
assignUser committed Dec 6, 2024
1 parent 6efa508 commit a28b80b
Showing 1 changed file with 17 additions and 43 deletions.
60 changes: 17 additions & 43 deletions .github/workflows/conbench_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,27 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: 'Download artifacts'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id || inputs.run_id }}
merge-multiple: true
path: /tmp/artifacts/
github-token: ${{ github.token }}

- name: Set meta data outputs
id: 'download'
uses: actions/github-script@v7
with:
# Have to get the run data explicitly instead of using the payload
# for workflow_dispatch to work.
script: |
const run_id = "${{ github.event.workflow_run.id || inputs.run_id }}";
let benchmark_run = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id,
});
let artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id,
});
let result_artifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "benchmark-results"
})[0];
let pr_artifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_number"
})[0];
let result_download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: result_artifact.id,
archive_format: 'zip',
run_id: "${{ github.event.workflow_run.id || inputs.run_id }}",
});
let pr_download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: pr_artifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/benchmark-results.zip', Buffer.from(result_download.data));
fs.writeFileSync('${{github.workspace}}/pr_number.zip', Buffer.from(pr_download.data));
core.setOutput('contender_sha', benchmark_run.data.head_sha);
if (benchmark_run.data.event == 'push') {
Expand All @@ -86,13 +63,10 @@ jobs:
core.setOutput('merge_commit_message', '');
}
- name: Extract artifact
- name: Extract PR Number
id: extract
run: |
unzip benchmark-results.zip -d benchmark-results
unzip pr_number.zip
pr_number=$(grep -ox '[[:digit:]]*' pr_number.txt | head -1)
pr_number=$(grep -ox '[[:digit:]]*' /tmp/artifacts/pr_number.txt | head -1)
if [ "$pr_number" -ge 0 ]; then
echo "Found PR number: $pr_number"
Expand All @@ -115,7 +89,7 @@ jobs:
cache-dependency-path: "velox/scripts/*"

- name: "Install dependencies"
run: python -m pip install -r velox/scripts/benchmark-requirements.txt
run: pip install -r velox/scripts/benchmark-requirements.txt

- name: "Upload results"
env:
Expand All @@ -126,15 +100,15 @@ jobs:
CONBENCH_PROJECT_REPOSITORY: "${{ github.repository }}"
CONBENCH_PROJECT_COMMIT: "${{ steps.download.outputs.contender_sha }}"
run: |
if [ "${{ steps.extract.outputs.pr_number }}" -gt 0]; then
if [ "${{ steps.extract.outputs.pr_number }}" -gt 0 ]; then
export CONBENCH_PROJECT_PR_NUMBER="${{ steps.extract.outputs.pr_number }}"
fi
./velox/scripts/benchmark-runner.py upload \
--run_id "GHA-${{ github.run_id }}-${{ github.run_attempt }}" \
--pr_number "${{ steps.extract.outputs.pr_number }}" \
--sha "${{ steps.download.outputs.contender_sha }}" \
--output_dir "${{ github.workspace }}/benchmark-results/contender/"
--output_dir "/tmp/artifacts/benchmark-results/contender/"
- name: "Check the status of the upload"
# Status functions like failure() only work in `if:`
Expand Down

0 comments on commit a28b80b

Please sign in to comment.