-
Notifications
You must be signed in to change notification settings - Fork 115
84 lines (79 loc) · 3.09 KB
/
prt_result.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
### The prt result workflow triggered through dispatch request from CI
name: post-prt-result
# Run on workflow dispatch from CI
on:
workflow_dispatch:
inputs:
pr_number:
type: string
description: pr number for PRT run
build_number:
type: string
description: build number for PRT run
pytest_result:
type: string
description: pytest summary result line
build_status:
type: string
description: status of jenkins build e.g. success, unstable or error
prt_comment:
type: string
description: prt pytest comment triggered the PRT checks
jobs:
post-the-prt-result:
runs-on: ubuntu-latest
steps:
- name: Add last PRT result into the github comment
id: add-prt-comment
if: ${{ always() && github.event.inputs.pytest_result != '' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
**PRT Result**
```
Build Number: ${{ github.event.inputs.build_number }}
Build Status: ${{ github.event.inputs.build_status }}
PRT Comment: ${{ github.event.inputs.prt_comment }}
Test Result : ${{ github.event.inputs.pytest_result }}
```
pr_number: ${{ github.event.inputs.pr_number }}
GITHUB_TOKEN: ${{ secrets.CHERRYPICK_PAT }}
- name: Add the PRT passed/failed labels
id: prt-status
if: ${{ always() && github.event.inputs.build_status != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
const prNumber = ${{ github.event.inputs.pr_number }};
const buildStatus = "${{ github.event.inputs.build_status }}";
const labelToAdd = buildStatus === "SUCCESS" ? "PRT-Passed" : "PRT-Failed";
github.rest.issues.addLabels({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [labelToAdd]
});
- name: Remove failed label on test pass or vice-versa
if: ${{ always() && github.event.inputs.build_status != '' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CHERRYPICK_PAT }}
script: |
const prNumber = ${{ github.event.inputs.pr_number }};
const issue = await github.rest.issues.get({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: prNumber,
});
const buildStatus = "${{ github.event.inputs.build_status }}";
const labelToRemove = buildStatus === "SUCCESS" ? "PRT-Failed" : "PRT-Passed";
const labelExists = issue.data.labels.some(({ name }) => name === labelToRemove);
if (labelExists) {
github.rest.issues.removeLabel({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
name: [labelToRemove]
});
}