-
Notifications
You must be signed in to change notification settings - Fork 81
97 lines (80 loc) · 2.99 KB
/
comment-evolution-plot.yml
File metadata and controls
97 lines (80 loc) · 2.99 KB
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
name: Comment PR with Evolution Plot
on:
workflow_run:
workflows:
- COMPAS compile test
types:
- completed
permissions:
actions: read
contents: read
issues: write
pull-requests: write
jobs:
comment-with-plot:
name: Post evolution plot comment
runs-on: ubuntu-22.04
if: >
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.pull_requests[0].number
env:
ARTIFACT_NAME: detailedEvolutionPlot.png
steps:
- name: Download evolution plot artifact from triggering run
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const runId = context.payload.workflow_run.id;
const runNumber = context.payload.workflow_run.run_number;
const artifactName = `evolution-plot-${runNumber}`;
const { owner, repo } = context.repo;
const artifacts = await github.paginate(
github.rest.actions.listWorkflowRunArtifacts,
{ owner, repo, run_id: runId, per_page: 100 }
);
const artifact = artifacts.find((entry) => entry.name === artifactName);
if (!artifact) {
core.setFailed(`Artifact '${artifactName}' not found for workflow run ${runId}`);
return;
}
const download = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
fs.writeFileSync(
path.join(process.env.GITHUB_WORKSPACE, 'evolution-plot.zip'),
Buffer.from(download.data)
);
- name: Unpack evolution plot artifact
run: |
set -e
mkdir -p evolution-plot
unzip -o evolution-plot.zip -d evolution-plot
test -f "evolution-plot/${ARTIFACT_NAME}"
- name: Post PR comment
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
set -e
cat <<EOF > report.md
## ✅ COMPAS Build Successful!
| Item | Value |
|------|-------|
| **Commit** | [\`$(echo "$HEAD_SHA" | cut -c1-7)\`]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$HEAD_SHA) |
| **Logs** | [View workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$RUN_ID) |
### Detailed Evolution Plot
<details><summary>Click to view evolution plot</summary>

</details>
---
<sub>Generated by COMPAS CI</sub>
EOF
npx -y @dvcorg/cml@0.20.6 comment create --target=pr/"$PR_NUMBER" report.md