1616 types : [created, edited]
1717
1818jobs :
19- build :
19+ member :
20+ name : Check whether it is triggered by team members with issue_comment or push or pull_request
2021 runs-on : ubuntu-latest
2122 permissions :
2223 pull-requests : write
2324 if : >-
2425 (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim')) ||
2526 github.event_name == 'push' || github.event_name == 'pull_request'
2627 outputs :
27- repo_name : ${{ steps.pr_data.outputs.repo_name }}
28- ref : ${{ steps.pr_data.outputs.ref }}
28+ valid : ${{ steps.setValid.outputs.valid }}
2929 steps :
30- # if we could have secrets.ORG_READ_BOT_PAT, we can check against team rather than organization.
3130 -
uses :
tspascoal/[email protected] 3231 id : checkMember
3332 if : github.event_name == 'issue_comment'
@@ -42,16 +41,34 @@ jobs:
4241 message : |
4342 Sorry only cronos-dev team member could run simulations by '/runsim'.
4443 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
45- - name : Fail and exit the job if authentication failed
46- if : (steps.checkMember.outputs.isTeamMember == 'false') && (github.event_name == 'issue_comment')
47- run : exit 1
44+ - name : set valid if it is push/pull_request event or check if it is triggered by team members with issue_comment
45+ id : setValid
46+ run : |
47+ if [[ "${{ steps.checkUserMember.outputs.isTeamMember }}" == "true" ]]; then
48+ echo "::set-output name=valid::true"
49+ elif [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "pull_request" ]]; then
50+ echo "::set-output name=valid::true"
51+ else
52+ echo "::set-output name=valid::false"
53+ fi
54+
55+ build :
56+ runs-on : ubuntu-latest
57+ needs : member
58+ permissions :
59+ pull-requests : write
60+ if : needs.member.outputs.valid == 'true'
61+ outputs :
62+ repo_name : ${{ steps.pr_data.outputs.repo_name }}
63+ ref : ${{ steps.pr_data.outputs.ref }}
64+ steps :
4865 - name : Comment PR for Sim test started
4966 uses : crypto-org-chain/actions-pull-request-add-comment@master
5067 if : github.event_name == 'issue_comment'
5168 with :
5269 message : |
53- Simulation tests started and triggered by `/runsim`.
54- Can check further progress [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
70+ Simulation tests get triggered and started by `/runsim`.
71+ Please check further progress [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
5572 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5673 - name : Github API Request
5774 id : request
@@ -91,6 +108,16 @@ jobs:
91108 - name : Display go version
92109 run : go version
93110 - run : make build
111+ - name : Create file status_build.txt and write the job status into it
112+ if : github.event_name == 'issue_comment'
113+ run : |
114+ echo ${{ job.status }} > status_build.txt
115+ - name : Upload file status_build.txt as an artifact
116+ if : github.event_name == 'issue_comment'
117+ uses : actions/upload-artifact@v1
118+ with :
119+ name : pass_status_build
120+ path : status_build.txt
94121
95122 install-runsim :
96123 runs-on : ubuntu-latest
@@ -107,6 +134,16 @@ jobs:
107134 with :
108135 path : ~/go/bin
109136 key : ${{ runner.os }}-go-runsim-binary
137+ - name : Create file status_install.txt and write the job status into it
138+ if : github.event_name == 'issue_comment'
139+ run : |
140+ echo ${{ job.status }} > status_install.txt
141+ - name : Upload file status_install.txt as an artifact
142+ if : github.event_name == 'issue_comment'
143+ uses : actions/upload-artifact@v1
144+ with :
145+ name : pass_status_install
146+ path : status_install.txt
110147
111148 test-sim-nondeterminism :
112149 runs-on : ubuntu-latest
@@ -152,6 +189,16 @@ jobs:
152189 if : >-
153190 (env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) ||
154191 (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim'))
192+ - name : Create file status_sim1.txt and write the job status into it
193+ if : github.event_name == 'issue_comment'
194+ run : |
195+ echo ${{ job.status }} > status_sim1.txt
196+ - name : Upload file status_sim1.txt as an artifact
197+ if : github.event_name == 'issue_comment'
198+ uses : actions/upload-artifact@v1
199+ with :
200+ name : pass_status_sim1
201+ path : status_sim1.txt
155202
156203 test-sim-import-export :
157204 runs-on : ubuntu-latest
@@ -197,6 +244,16 @@ jobs:
197244 if : >-
198245 (env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) ||
199246 (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim'))
247+ - name : Create file status_sim2.txt and write the job status into it
248+ if : github.event_name == 'issue_comment'
249+ run : |
250+ echo ${{ job.status }} > status_sim2.txt
251+ - name : Upload file status_sim2.txt as an artifact
252+ if : github.event_name == 'issue_comment'
253+ uses : actions/upload-artifact@v1
254+ with :
255+ name : pass_status_sim2
256+ path : status_sim2.txt
200257
201258 test-sim-after-import :
202259 runs-on : ubuntu-latest
@@ -242,6 +299,16 @@ jobs:
242299 if : >-
243300 (env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) ||
244301 (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim'))
302+ - name : Create file status_sim3.txt and write the job status into it
303+ if : github.event_name == 'issue_comment'
304+ run : |
305+ echo ${{ job.status }} > status_sim3.txt
306+ - name : Upload file status_sim3.txt as an artifact
307+ if : github.event_name == 'issue_comment'
308+ uses : actions/upload-artifact@v1
309+ with :
310+ name : pass_status_sim3
311+ path : status_sim3.txt
245312
246313 test-sim-multi-seed-short :
247314 runs-on : ubuntu-latest
@@ -286,4 +353,84 @@ jobs:
286353 make test-sim-multi-seed-short
287354 if : >-
288355 (env.GIT_DIFF && (github.event_name == 'push' || github.event_name == 'pull_request')) ||
289- (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim'))
356+ (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/runsim'))
357+ - name : Create file status_sim4.txt and write the job status into it
358+ if : github.event_name == 'issue_comment'
359+ run : |
360+ echo ${{ job.status }} > status_sim4.txt
361+ - name : Upload file status_sim4.txt as an artifact
362+ if : github.event_name == 'issue_comment'
363+ uses : actions/upload-artifact@v1
364+ with :
365+ name : pass_status_sim4
366+ path : status_sim4.txt
367+
368+ report-status-pr :
369+ runs-on : ubuntu-latest
370+ needs : [member, test-sim-nondeterminism, test-sim-import-export, test-sim-after-import, test-sim-multi-seed-short]
371+ permissions :
372+ pull-requests : write
373+ if : always() && github.event_name == 'issue_comment' && needs.member.outputs.valid == 'true'
374+ steps :
375+ - name : Download artifact pass_status_build
376+ uses : actions/download-artifact@v1
377+ continue-on-error : true
378+ with :
379+ name : pass_status_build
380+ - name : Download artifact pass_status_install
381+ uses : actions/download-artifact@v1
382+ continue-on-error : true
383+ with :
384+ name : pass_status_install
385+ - name : Download artifact pass_status_sim1
386+ uses : actions/download-artifact@v1
387+ continue-on-error : true
388+ with :
389+ name : pass_status_sim1
390+ - name : Download artifact pass_status_sim2
391+ uses : actions/download-artifact@v1
392+ continue-on-error : true
393+ with :
394+ name : pass_status_sim2
395+ - name : Download artifact pass_status_sim3
396+ uses : actions/download-artifact@v1
397+ continue-on-error : true
398+ with :
399+ name : pass_status_sim3
400+ - name : Download artifact pass_status_sim4
401+ uses : actions/download-artifact@v1
402+ continue-on-error : true
403+ with :
404+ name : pass_status_sim4
405+ - name : Set the statuses of Jobs as output parameters
406+ id : set_outputs
407+ continue-on-error : true
408+ run : |
409+ echo "::set-output name=status_job01::$(<pass_status_build/status_build.txt)"
410+ echo "::set-output name=status_job02::$(<pass_status_install/status_install.txt)"
411+ echo "::set-output name=status_job03::$(<pass_status_sim1/status_sim1.txt)"
412+ echo "::set-output name=status_job04::$(<pass_status_sim2/status_sim2.txt)"
413+ echo "::set-output name=status_job05::$(<pass_status_sim3/status_sim3.txt)"
414+ echo "::set-output name=status_job06::$(<pass_status_sim4/status_sim4.txt)"
415+ - name : The sim jobs has succeed
416+ uses : crypto-org-chain/actions-pull-request-add-comment@master
417+ if : >-
418+ steps.set_outputs.outputs.status_job01 == 'success' && steps.set_outputs.outputs.status_job02 == 'success'
419+ && steps.set_outputs.outputs.status_job03 == 'success' && steps.set_outputs.outputs.status_job04 == 'success'
420+ && steps.set_outputs.outputs.status_job05 == 'success' && steps.set_outputs.outputs.status_job06 == 'success'
421+ with :
422+ message : |
423+ ✅ `/runsim` simulation test has succeeded 🎉
424+ Please further check [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
425+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
426+ - name : The sim jobs has failed
427+ uses : crypto-org-chain/actions-pull-request-add-comment@master
428+ if : >-
429+ steps.set_outputs.outputs.status_job01 != 'success' || steps.set_outputs.outputs.status_job02 != 'success'
430+ || steps.set_outputs.outputs.status_job03 != 'success' || steps.set_outputs.outputs.status_job04 != 'success'
431+ || steps.set_outputs.outputs.status_job05 != 'success' || steps.set_outputs.outputs.status_job06 != 'success'
432+ with :
433+ message : |
434+ ❌ `/runsim` simulation test has failed 😅
435+ Please further check [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
436+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments