Skip to content

Compare Artifacts

Compare Artifacts #1

name: Compare Artifacts
on:
workflow_run:
workflows:
- Integration Tests
types:
- completed
permissions: read-all
jobs:
Compare-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download PR number artifact
uses: actions/github-script@v6
with:
script: |
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 == "pr_number"
})[0];
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}/pr_number.zip`, Buffer.from(download.data));
- name: Download comparison result artifact
uses: actions/github-script@v6
with:
script: |
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 == "comparison_result"
})[0];
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}/comparison_result.zip`, Buffer.from(download.data));
- name: Unzip artifacts
run: |
unzip pr_number.zip
unzip comparison_result.zip
- name: Print artifacts
uses: actions/github-script@v6
with:
script: |
let fs = require('fs');
let pr_number = Number(fs.readFileSync('./pr_number'));
let comparison_result = fs.readFileSync('./comparison_result', 'utf8');
console.log("PR number = ", pr_number);
console.log("Comparison result = ", comparison_result);
# TODO: uncomment this once we have a way to avoid false positives
# False positives usually happen because the reference artifacts are
# based on a CI run that does not reflect a state of the main branch.
# We might possibly have to run the relevant tests twice within each PR
# - name: Comment on PR
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# let fs = require('fs');
# let run_id = context.payload.workflow_run.id;
# let issue_number = Number(fs.readFileSync('./pr_number'));
# let comparison_result = fs.readFileSync('./comparison_result', 'utf8');
# const message = `:warning: **This PR does not produce bitwise identical kernels as the branch it's merged against.** Please check artifacts for details. [Download the output file here](https://github.com/${{ github.repository }}/actions/runs/${run_id}).`;
# if (comparison_result.trim() !== 'SUCCESS') {
# await github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number,
# body: message
# });
# }