-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (253 loc) · 7.88 KB
/
test-pull-request.yaml
File metadata and controls
289 lines (253 loc) · 7.88 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: Test Pull Request API
on:
workflow_call:
inputs:
branch:
type: string
required: true
description: The name of the branch
base:
type: string
required: true
description: The name of the branch to target
outputs:
pull-number:
value: ${{ jobs.create.outputs.pull-number }}
description: The created pull-request number
jobs:
create:
name: Create
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: write
outputs:
pull-number: ${{ steps.create.outputs.pull-number }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Pull Request
id: create
uses: ./pulls/create
with:
head: ${{ inputs.branch }}
base: ${{ inputs.base }}
title: "Integration Test ${{ github.run_id }}"
body: |
This is a test Github Issue initiated by [this workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
Please ignore this
test-labels:
name: Labels
runs-on: ubuntu-latest
needs: [create]
defaults:
run:
shell: bash
permissions:
pull-requests: write
issues: write
contents: write
env:
LABEL: integration-test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get PR Before
id: before
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert label is empty before action
if: success() && contains(steps.before.outputs.labels, env.LABEL)
run: |
echo "::error::PR labels before was '${{ steps.before.outputs.labels }}'; expected empty"
exit 1
- name: Add label
uses: ./pulls/add-labels
with:
pull-number: ${{ needs.create.outputs.pull-number }}
labels: |
${{ env.LABEL }}
- name: Get PR during
id: during
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert labels is added after action
if: success() && !contains(steps.during.outputs.labels, env.LABEL)
run: |
echo "::error::PR Labels is '${{ steps.before.outputs.labels }}'; does not contain ${{ env.LABEL }}"
exit 1
- name: Remove Label
uses: ./pulls/remove-labels
with:
pull-number: ${{ needs.create.outputs.pull-number }}
labels: |
${{ env.LABEL }}
- name: Get PR after
id: after
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert assignee is removed after action
if: success() && contains(steps.after.outputs.labels, env.LABEL)
run: |
echo "::error::PR Labels after is '${{ steps.after.outputs.labels }}'; expected empty"
exit 1
test-assignees:
name: Assignees
runs-on: ubuntu-latest
needs: [create]
defaults:
run:
shell: bash
permissions:
pull-requests: write
issues: write
contents: write
env:
ASSIGNEE: bitwizeshift
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get PR Before
id: before
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert assignee is empty before action
if: success() && contains(steps.before.outputs.assignees, env.ASSIGNEE)
run: |
echo "::error::PR Assignees before was '${{ steps.before.outputs.assignees }}'; expected empty"
exit 1
- name: Add assignees
uses: ./pulls/add-assignees
with:
pull-number: ${{ needs.create.outputs.pull-number }}
assignees: |
${{ env.ASSIGNEE }}
- name: Get PR during
id: during
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert assignee is added after action
if: success() && !contains(steps.during.outputs.assignees, env.ASSIGNEE)
run: |
echo "::error::PR Assignees is '${{ steps.before.outputs.assignees }}'; does not contain ${{ env.ASSIGNEE }}"
exit 1
- name: Remove Assignees
uses: ./pulls/remove-assignees
with:
pull-number: ${{ needs.create.outputs.pull-number }}
assignees: |
${{ env.ASSIGNEE }}
- name: Get PR after
id: after
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert assignee is removed after action
if: success() && contains(steps.after.outputs.assignees, env.ASSIGNEE)
run: |
echo "::error::PR Assignees after is '${{ steps.after.outputs.assignees }}'; expected empty"
exit 1
test-open-close:
name: Open/Close
runs-on: ubuntu-latest
needs: [create]
defaults:
run:
shell: bash
permissions:
pull-requests: write
issues: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get PR Before
id: before
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert Pull Request begins in open state
if: success() && steps.before.outputs.state != 'open'
run: |
echo "::error::PR State before was not 'opened'. Got '${{ steps.before.outputs.state }}'"
exit 1
- name: Close PR
uses: ./pulls/close
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Get PR during
id: during
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert Pull Request is closed by action
if: success() && steps.during.outputs.state != 'closed'
run: |
echo "::error::PR State during was not 'closed'. Got '${{ steps.during.outputs.state }}'"
exit 1
- name: Reopen PR
uses: ./pulls/open
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Get PR after
id: after
uses: ./pulls/get
with:
pull-number: ${{ needs.create.outputs.pull-number }}
- name: Assert Pull Request is reopened by action
if: success() && steps.after.outputs.state != 'open'
run: |
echo "::error::PR State after was not 'open'. Got '${{ steps.after.outputs.state }}'"
exit 1
test-comment:
name: Comment
runs-on: ubuntu-latest
needs: [create]
defaults:
run:
shell: bash
permissions:
pull-requests: write
issues: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create comment
id: create-comment
uses: ./pulls/create-comment
with:
pull-number: ${{ needs.create.outputs.pull-number }}
body: |
Testing creating an automated comment on the issue
- name: Update comment
uses: ./pulls/update-comment
with:
comment-id: ${{ steps.create-comment.outputs.comment-id }}
body: |
Testing creating an automated comment on the issue
This comment's url: ${{ steps.create-comment.outputs.comment-url }}
test-merge:
name: Merge
runs-on: ubuntu-latest
if: success()
needs:
- create
- test-assignees
- test-comment
- test-labels
- test-open-close
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Merge pull request
uses: ./pulls/merge
with:
pull-number: ${{ needs.create.outputs.pull-number }}
merge-method: rebase