forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (98 loc) · 3.89 KB
/
report.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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: |
pip install Jinja2
ls -al $GITHUB_WORKSPACE/physmon
CI/physmon/generate_comment.py $GITHUB_WORKSPACE/physmon comment.md
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