[CI] Adding workflow_run (#2120)

This commit is contained in:
Zahi Moudallal
2023-08-18 23:58:41 -07:00
committed by GitHub
parent d5188fa230
commit 3c8f959f91
2 changed files with 68 additions and 46 deletions

View File

@@ -12,7 +12,7 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Download artifact'
- name: Download PR number artifact
uses: actions/github-script@v6
with:
script: |
@@ -32,20 +32,54 @@ jobs:
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip pr_number.zip
- name: 'Comment on PR'
- 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);
- 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'));
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: `Ignore this message. This is to test another workflow posting comment on PR number ${issue_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
});
}

View File

@@ -153,16 +153,6 @@ jobs:
sudo nvidia-smi -i 0 --lock-gpu-clocks=1280,1280
python3 -m pytest -vs . --reruns 10
sudo nvidia-smi -i 0 -rgc
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
- uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr/
Integration-Tests-Third-Party:
needs: Runner-Preparation
@@ -266,6 +256,17 @@ jobs:
sudo apt update
sudo apt install gh
- name: Save PR number to a file
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number
- name: Upload PR number to artifacts
uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr_number
- name: Download latest main artifacts
env:
ARTIFACT_NAME: artifacts A100
@@ -361,33 +362,20 @@ jobs:
echo "Error while comparing artifacts"
echo "COMPARISON_RESULT=error" >> $GITHUB_ENV
fi
- name: Check exit code and handle failure
if: ${{ env.COMPARISON_RESULT == 'error' }}
- name: Check comparison result and write to file
run: |
echo "Error while comparing artifacts"
exit 1
- name: Fetch Run ID
id: get_run_id
run: echo "RUN_ID=${{ github.run_id }}" >> $GITHUB_ENV
if [ "${{ env.COMPARISON_RESULT }}" = "true" ]; then
echo "SUCCESS" > comparison_result
else
echo "FAILED" > comparison_result
fi
- name: Upload comparison result to artifacts
uses: actions/upload-artifact@v3
with:
name: comparison_result
path: comparison_result
- name: Upload results as artifact
uses: actions/upload-artifact@v2
with:
name: kernels-reference-check
path: kernels_reference_check.txt
- name: Check output and comment on PR
if: ${{ env.COMPARISON_RESULT == 'false' }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.CI_ACCESS_TOKEN }}
script: |
const run_id = ${{ env.RUN_ID }};
const issue_number = context.payload.pull_request.number;
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}).`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});