Skip to content

Report on physmon

Report on physmon #58

Workflow file for this run

name: Report on physmon
on:
workflow_run:
workflows: [Builds]
types:
- completed
jobs:
post_comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v6
id: dl-af
with:
script: |
console.log(`Getting artifacts for workflow run id: ${context.payload.workflow_run.id}`);
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == 'physmon'
});
if(matchArtifacts.length == 0) {
console.log("Could not find artifact");
return false;
}
let matchArtifact = matchArtifacts[0];
console.log(`Artifact id is: ${matchArtifact.id}`);
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}/physmon.zip`, Buffer.from(download.data));
let = url = `https://herald.dokku.paulgessinger.com/view/${process.env.GITHUB_REPOSITORY}/${matchArtifact.id}`;
core.exportVariable('ARTIFACT_URL', url)
return true;
- name: 'Unzip artifact'
if: steps.dl-af.outputs.result != 'false'
run: unzip -d $GITHUB_WORKSPACE/physmon $GITHUB_WORKSPACE/physmon.zip
- name: 'Determine PR number'
uses: actions/github-script@v6
id: get-pr-number
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
if(!${{ steps.dl-af.outputs.result }}) {
console.log("No artifact => no PR numner");
return false;
}
let fs = require('fs');
let file = 'physmon/pr_number';
if(!fs.existsSync(file)) {
console.log('No file at ' + file);
return false;
}
let number = Number(fs.readFileSync(file, {encoding: 'utf8'}).trim());
console.log('PR number is '+number);
core.exportVariable('PR_NUMBER', number)
let sha = fs.readFileSync('physmon/sha', {encoding: 'utf8'}).trim();
console.log('SHA is '+sha);
core.exportVariable('PR_SHA', sha)
return number;
# ping the url, triggers caching of the artifact
- name: Prime cache
if: steps.get-pr-number.outputs.result != 'false'
run: curl -sL $ARTIFACT_URL
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Render comment
if: steps.get-pr-number.outputs.result != 'false'
run: |
ls -al $GITHUB_WORKSPACE/physmon
echo "# 📊: Physics performance monitoring for ${PR_SHA}" >> comment.md
echo "[Full contents](${ARTIFACT_URL})" >> comment.md
if [ -f "$GITHUB_WORKSPACE/physmon/summary.md" ]; then
cat $GITHUB_WORKSPACE/physmon/summary.md >> comment.md
else
echo "🟥 summary not found!" >> comment.md
fi
cat comment.md
- name: Find Comment
if: steps.get-pr-number.outputs.result != 'false'
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ steps.get-pr-number.outputs.result }}
comment-author: 'github-actions[bot]'
body-includes: Physics performance monitoring
- name: Create or update comment
if: steps.get-pr-number.outputs.result != 'false'
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.get-pr-number.outputs.result }}
body-file: comment.md
edit-mode: replace