-
Notifications
You must be signed in to change notification settings - Fork 8
186 lines (170 loc) · 7.05 KB
/
pr-open.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Preview and Test PR
on:
pull_request:
types:
- opened
- reopened
- synchronize
# Only run the latest. Cancel old runs in progress.
concurrency:
cancel-in-progress: true
group: "preview-env-manage-${{ github.event.number }}"
jobs:
create-database:
name: Create preview env DB
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/create_db.yaml@develop
with:
db-name: "mindlogger_backend_pr_${{ github.event.number }}"
secrets: inherit
on-db-failure:
name: Database creation failed
runs-on: ubuntu-latest
if: ${{ always() && (needs.create_database.result == 'failure' || needs.create_database.result == 'timed_out') }}
needs: [create-database]
steps:
- name: "Send Slack message on failure"
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }}
SLACK_TITLE: Create Database
SLACK_MESSAGE: 'Error during database creation!'
SLACK_ICON: https://github.com/github.png?size=48
MSG_MINIMAL: actions url
run-unit-tests:
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/tests.yaml@develop
secrets: inherit
comment-unit-tests:
name: Comment on unit test outcome
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
needs: [ run-unit-tests ]
steps:
- name: Post the link to the report
uses: guibranco/github-status-action-v2@v1
with:
authToken: ${{secrets.PAT_TOKEN}}
context: 'Unit Test report'
state: ${{ needs.run-unit-tests.result }}
sha: ${{ github.event.pull_request.head.sha }}
target_url: ${{ needs.run-unit-tests.outputs.report-url }}
- name: "Send Slack message on failure"
if: ${{ needs.run-unit-tests.result != 'success' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }}
SLACKIFY_MARKDOWN: true
SLACK_TITLE: |
:rotating_light: Unit test suite failed
SLACK_MESSAGE: >-
Unit tests for PR-${{ github.event.pull_request.number}} failed in ${{ github.repository }}
\n\n
:arrow_right: [Action Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
\n\n
:label: [Pull Request](${{ github.event.pull_request.html_url || github.event.head_commit.url }}) | :chart_with_upwards_trend: [Test Report](${{ needs.run-unit-tests.outputs.report-url }})
SLACK_ICON: https://github.com/github.png?size=48
MSG_MINIMAL: true
create-preview-env:
needs: [create-database, run-unit-tests]
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/create-preview-env.yaml@develop
with:
env-name: "pr-${{ github.event.number }}"
env-snake-name: "pr_${{ github.event.number }}"
app-name: ${{ github.event.repository.name }}
vpc-id: vpc-0a83201b71e854abd
copilot-service: mindlogger-backend
secrets: inherit
comment-create-preview-env:
name: Comment on preview env
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
needs: [create-preview-env]
if: ${{ !cancelled() }}
steps:
- name: Comment on PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
:arrow_right: Preview environment created: [Click Me!](${{ needs.create-preview-env.outputs.service-url }})
reactions: eyes, rocket
comment_tag: service-url
- name: "Send Slack message on failure"
uses: rtCamp/action-slack-notify@v2
if: ${{ !cancelled() && needs.create-preview-env.result == 'failure' }}
env:
SLACK_COLOR: failure
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }}
SLACKIFY_MARKDOWN: true
SLACK_TITLE: |
:rotating_light: Preview Environment Failed
SLACK_MESSAGE: >-
Failed to create a preview env for PR-${{ github.event.pull_request.number}} in ${{ github.repository }}
\n\n
:arrow_right: [Action Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
\n\n
:label: [Pull Request](${{ github.event.pull_request.html_url || github.event.head_commit.url }})
MSG_MINIMAL: true
run-e2e-tests:
name: Run E2E Test Suite
needs: [ create-preview-env, run-unit-tests ]
if: ${{ !cancelled() && needs.run-unit-tests.result == 'success' && needs.create-preview-env.result == 'success' }}
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/e2e-tests.yaml@develop
secrets: inherit
with:
service-url: ${{ needs.create-preview-env.outputs.service-url }}
db-name: "mindlogger_backend_pr_${{ github.event.number }}"
comment-e2e-tests:
name: Comment on test outcome
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
needs: [run-e2e-tests]
steps:
- name: "Send Slack message on failure"
if: ${{ needs.run-e2e-tests.result != 'success' }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TEST_RESULTS }}
SLACKIFY_MARKDOWN: true
SLACK_TITLE: |
:rotating_light: E2E test suite failed
SLACK_MESSAGE: >-
E2E tests for PR-${{ github.event.pull_request.number}} failed in ${{ github.repository }}
\n\n
:arrow_right: [Action Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
\n\n
:label: [Pull Request](${{ github.event.pull_request.html_url || github.event.head_commit.url }}) | :chart_with_upwards_trend: [Test Report](${{ needs.run-e2e-tests.outputs.report-url }})
SLACK_ICON: https://github.com/github.png?size=48
MSG_MINIMAL: true
- name: Comment on PR with test success
if: ${{ needs.run-e2e-tests.result == 'success' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
:white_check_mark: E2E tests passed!
comment_tag: e2e-results
- name: Comment on PR with test failure
if: ${{ needs.run-e2e-tests.result != 'success' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
:x: E2E tests failed
comment_tag: e2e-results
- name: Post the link to the report
if: ${{ !cancelled() }}
uses: guibranco/github-status-action-v2@v1
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'E2E Test report'
state: ${{ needs.run-e2e-tests.result }}
sha: ${{ github.event.pull_request.head.sha }}
target_url: ${{ needs.run-e2e-tests.outputs.report-url }}