Skip to content

Commit

Permalink
test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
assignUser committed Dec 6, 2024
1 parent 03f0894 commit 8f756f6
Showing 1 changed file with 20 additions and 47 deletions.
67 changes: 20 additions & 47 deletions .github/workflows/conbench_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,28 @@ permissions:
jobs:
upload:
runs-on: ubuntu-latest
# Disabling workflow due to potential security sev
if: false
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/

- name: Set meta data outputs
id: 'download'
uses: actions/github-script@v6
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,
run_id: "${{ github.event.workflow_run.id || inputs.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',
});
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 @@ -88,13 +62,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 @@ -105,17 +76,19 @@ jobs:
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: velox
persist-credentials: false

- uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: 'pip'
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 @@ -134,7 +107,7 @@ jobs:
--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 All @@ -143,7 +116,7 @@ jobs:
run: echo "failed=true" >> $GITHUB_OUTPUT

- name: "Create a GitHub Status on the contender commit (whether the upload was successful)"
uses: actions/github-script@v6
uses: actions/github-script@v7
if: ${{ !cancelled() && steps.extract.conclusion != 'failure' }}
with:
script: |
Expand Down

0 comments on commit 8f756f6

Please sign in to comment.