@@ -21,10 +21,33 @@ jobs:
21
21
with :
22
22
access_token : ${{ secrets.GITHUB_TOKEN }}
23
23
24
- generate- allure-report :
24
+ check-if- allure-artifacts-exist :
25
25
runs-on : ubuntu-22.04
26
- if : always()
27
26
needs : stop-previous-run
27
+ outputs :
28
+ artifacts-exist : ${{ steps.check-artifacts-exist.outputs.artifacts-exist }}
29
+ steps :
30
+ - name : Check if allure artifacts exist
31
+ id : check-artifacts-exist
32
+ uses : actions/github-script@v6
33
+ with :
34
+ script : |
35
+ const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
36
+ owner: context.repo.owner,
37
+ repo: context.repo.repo,
38
+ run_id: ${{github.event.workflow_run.id }}
39
+ });
40
+ const matchArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'allure-results');
41
+ if (!matchArtifact) {
42
+ core.setOutput('artifacts-exist', 'false');
43
+ } else {
44
+ core.setOutput('artifacts-exist', 'true');
45
+ }
46
+
47
+ generate-allure-report :
48
+ runs-on : ubuntu-22.04
49
+ needs : check-if-allure-artifacts-exist
50
+ if : ${{ needs.check-if-allure-artifacts-exist.outputs.artifacts-exist != 'false' }}
28
51
steps :
29
52
- name : Dowload artifacts
30
53
uses : actions/github-script@v6
63
86
with :
64
87
allure_results : ./
65
88
allure_history : allure-history
66
- keep_reports : 20
89
+ keep_reports : 30
67
90
68
91
- name : Deploy report to Github Pages
69
92
if : always()
77
100
comment-to-pr :
78
101
runs-on : ubuntu-22.04
79
102
needs : generate-allure-report
80
- if : >
81
- github.event.workflow_run.event == 'pull_request'
103
+ if : always() && github.event.workflow_run.event == 'pull_request'
82
104
steps :
83
105
- name : ' Download artifact'
84
106
uses : actions/github-script@v6
@@ -101,36 +123,21 @@ jobs:
101
123
});
102
124
const fs = require('fs');
103
125
fs.writeFileSync('${{github.workspace}}/env_for_comment.zip', Buffer.from(download.data));
104
- - run : unzip env_for_comment.zip
126
+ - run : |
127
+ unzip env_for_comment.zip
128
+ echo ${{ needs.generate-allure-report.result }}
105
129
106
- - name : ' Comment to PR -- if success'
107
- if : github.event.workflow_run.conclusion == 'success'
108
- uses : actions/github-script@v6
109
- with :
110
- script : |
111
- const fs = require('fs');
112
- const issue_number = Number(fs.readFileSync('./prNum'));
113
- const runNumber = process.env.RUN_NUMBER;
114
- const runId = Number(fs.readFileSync('./runId'));
115
- const repoFullName = fs.readFileSync('./repoFullName');
116
- const ownerName = fs.readFileSync('./ownerName');
117
- const githubPagesLink = 'https://' + ownerName.toString().toLowerCase().trim() + '.github.io/' + String(repoFullName).replace(`${ownerName.toString().trim()}/`, '') + '/';
118
- const githubRunLink = 'https://github.com/' + repoFullName + '/actions/runs/' + runId;
119
- github.rest.issues.createComment({
120
- issue_number: issue_number,
121
- owner: context.repo.owner,
122
- repo: context.repo.repo,
123
- body: 'All tests are passed ✅ \n Checkout tests results here: <a href="' + githubPagesLink + runNumber + '">Cypress e2e Test Report</a> \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
124
- })
125
-
126
- - name : ' Comment to PR -- if failed'
127
- if : github.event.workflow_run.conclusion == 'failure'
130
+ - name : ' Comment to PR -- if report generated'
131
+ if : needs.generate-allure-report.result == 'success'
128
132
uses : actions/github-script@v6
133
+ env :
134
+ WORKFLOW_CONCLUSION : ${{ github.event.workflow_run.conclusion }}
129
135
with :
130
136
script : |
131
137
const fs = require('fs');
132
138
const issue_number = Number(fs.readFileSync('./prNum'));
133
139
const runNumber = process.env.RUN_NUMBER;
140
+ const conclusion = process.env.WORKFLOW_CONCLUSION;
134
141
const runId = Number(fs.readFileSync('./runId'));
135
142
const repoFullName = fs.readFileSync('./repoFullName');
136
143
const ownerName = fs.readFileSync('./ownerName');
@@ -140,17 +147,20 @@ jobs:
140
147
issue_number: issue_number,
141
148
owner: context.repo.owner,
142
149
repo: context.repo.repo,
143
- body: ' Workflow is failed ❌ \n Test might not start, so please chekout workflow first \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Checkout tests results here: <a href="' + githubPagesLink + runNumber + ' ">Cypress e2e Test Report</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
150
+ body: ` Workflow status is ${conclusion === 'success'? conclusion + ' \u2705' : conclusion + ' \u274C'} \n Checkout tests results here: <a href="${ githubPagesLink}${ runNumber} ">Cypress e2e Test Report</a> \n Link to GitHub workflow: <a href="${githubRunLink}">Github Workflow Link</a> \n❕Note: Report deployment may take up to 10 minutes.`
144
151
})
145
152
146
- - name : ' Comment to PR -- if cancelled '
147
- if : github.event.workflow_run.conclusion == 'cancelled '
153
+ - name : ' Comment to PR -- if report wasnt generated '
154
+ if : needs.generate-allure-report.result == 'skipped '
148
155
uses : actions/github-script@v6
156
+ env :
157
+ WORKFLOW_CONCLUSION : ${{ github.event.workflow_run.conclusion }}
149
158
with :
150
159
script : |
151
160
const fs = require('fs');
152
161
const issue_number = Number(fs.readFileSync('./prNum'));
153
162
const runNumber = process.env.RUN_NUMBER;
163
+ const conclusion = process.env.WORKFLOW_CONCLUSION;
154
164
const runId = Number(fs.readFileSync('./runId'));
155
165
const repoFullName = fs.readFileSync('./repoFullName');
156
166
const ownerName = fs.readFileSync('./ownerName');
@@ -160,53 +170,41 @@ jobs:
160
170
issue_number: issue_number,
161
171
owner: context.repo.owner,
162
172
repo: context.repo.repo,
163
- body: 'Workflow is cancelled 🚫 \n Test might not start, so please chekout workflow first \n Link to GitHub workflow: <a href="' + githubRunLink + '">Github Workflow Link</a> \n Checkout tests results: <a href="' + githubPagesLink + runNumber + '">Cypress e2e Test Report</a> \n Take care of yourself and have a great day! 🌞 \n❕Note: Report deployment may take up to 5 minutes.'
164
- })
165
-
166
- - name : ' Add label to PR -- if success'
167
- if : github.event.workflow_run.conclusion == 'success'
168
- uses : actions/github-script@v6
169
- with :
170
- github-token : ${{ secrets.GITHUB_TOKEN }}
171
- script : |
172
- const fs = require('fs');
173
- const issue_number = Number(fs.readFileSync('./prNum'));
174
- const runNumber = process.env.RUN_NUMBER;
175
- github.rest.issues.addLabels({
176
- issue_number: issue_number,
177
- owner: context.repo.owner,
178
- repo: context.repo.repo,
179
- labels: ['e2e-success']
173
+ body: `Workflow status is ${conclusion === 'success'? conclusion + ' \u2705' : conclusion === 'cancelled'? conclusion + ' \u2757' : conclusion + ' \u274C'} \n Unfortunately test report wasn't generated, it can be if no workspaces changed. Please check the workflow run below. \n Link to GitHub workflow: <a href="${githubRunLink}">Github Workflow Link</a>`
180
174
})
181
175
182
- - name : ' Add label to PR -- if failed '
183
- if : github.event.workflow_run.conclusion == 'failure '
176
+ - name : ' Add e2e label to PR -- if report generated '
177
+ if : needs.generate-allure-report.result == 'success '
184
178
uses : actions/github-script@v6
179
+ env :
180
+ WORKFLOW_CONCLUSION : ${{ github.event.workflow_run.conclusion }}
185
181
with :
186
182
github-token : ${{ secrets.GITHUB_TOKEN }}
187
183
script : |
188
184
const fs = require('fs');
189
185
const issue_number = Number(fs.readFileSync('./prNum'));
190
- const runNumber = process.env.RUN_NUMBER ;
186
+ const conclusion = process.env.WORKFLOW_CONCLUSION ;
191
187
github.rest.issues.addLabels({
192
188
issue_number: issue_number,
193
189
owner: context.repo.owner,
194
190
repo: context.repo.repo,
195
- labels: [' e2e-failure' ]
191
+ labels: [` e2e-${conclusion}` ]
196
192
})
197
193
198
- - name : ' Add label to PR -- if cancelled '
199
- if : github.event.workflow_run.conclusion == 'cancelled'
194
+ - name : ' Add workflow label to PR'
195
+ if : always()
200
196
uses : actions/github-script@v6
197
+ env :
198
+ WORKFLOW_CONCLUSION : ${{ github.event.workflow_run.conclusion }}
201
199
with :
202
200
github-token : ${{ secrets.GITHUB_TOKEN }}
203
201
script : |
204
202
const fs = require('fs');
205
203
const issue_number = Number(fs.readFileSync('./prNum'));
206
- const runNumber = process.env.RUN_NUMBER ;
204
+ const conclusion = process.env.WORKFLOW_CONCLUSION ;
207
205
github.rest.issues.addLabels({
208
206
issue_number: issue_number,
209
207
owner: context.repo.owner,
210
208
repo: context.repo.repo,
211
- labels: ['e2e-cancelled' ]
209
+ labels: [`workflow-${conclusion}` ]
212
210
})
0 commit comments