generated from dsanders11/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
338 lines (297 loc) · 11.4 KB
/
integration-tests.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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
name: Integration Tests
on:
workflow_dispatch:
workflow_run:
workflows: ['CI']
branches:
- main
- 'releases/*'
types:
- completed
schedule:
- cron: '0 22 * * 3'
jobs:
integration-tests:
name: Integration Test
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
strategy:
matrix:
include:
- auth: PAT
owner: dsanders11
project_number: 11
- auth: PAT
owner: dsanders11-playground-org
project_number: 2
- auth: GHA
owner: dsanders11-playground-org
project_number: 2
steps:
- name: Checkout
id: checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Get Date
uses: ./github-script/
id: get-date
with:
result-encoding: string
script: |
return new Date().toISOString()
- name: Generate GitHub App Token
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
id: generate-app-token
if: ${{ matrix.auth == 'GHA' }}
with:
creds: ${{ secrets.GH_APP_CREDS }}
org: ${{ matrix.owner }}
- name: Get Auth Token
id: get-auth-token
run: echo "token=${{ steps.generate-app-token.outputs.token || secrets.PAT }}" >> "$GITHUB_OUTPUT"
- name: Create Template View
uses: ./github-script/
id: template-view
with:
script: |
return {
"type": "Favorite",
"foo": "bar"
}
- name: Copy Project
uses: ./copy-project/
id: copy-project
with:
drafts: true
owner: ${{ matrix.owner }}
project-number: ${{ matrix.project_number }}
# public: true
target-owner: ${{ matrix.owner }}
template-view: ${{ steps.template-view.outputs.result }}
title: Integration Test Project
token: ${{ steps.get-auth-token.outputs.token }}
- name: Get Draft Issue ID
id: get-draft-issue-id
run: |
set -eo pipefail
echo "id=$(gh project item-list ${{ steps.copy-project.outputs.number }} --owner ${{ steps.copy-project.outputs.owner }} --format json | jq -r '.items[0] | .id')" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.get-auth-token.outputs.token }}
- name: Get Draft Issue
uses: ./get-item/
id: get-draft-issue
with:
field: Priority
item: ${{ steps.get-draft-issue-id.outputs.id }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Draft Issue
uses: ./github-script/
with:
script: |
if ("${{ steps.get-draft-issue.outputs.title }}" !== "My Favorite Issue") {
throw new Error("Draft issue title is not correct")
}
const body = `${{ steps.get-draft-issue.outputs.body }}`
if (!body.includes("Here's another bar")) {
throw new Error("Draft issue body is not correct")
}
if ("${{ steps.get-draft-issue.outputs.field-value }}" != "Low") {
throw new Error("Draft issue field is not correct")
}
- name: Run Completed By
uses: ./completed-by/
id: completed-by
with:
field-value: Done
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Draft Issue Is Completed
uses: ./github-script/
with:
script: |
const item = await actions.getItem(
"${{ steps.copy-project.outputs.owner }}",
"${{ steps.copy-project.outputs.number }}",
"${{ steps.get-draft-issue-id.outputs.id }}",
"Status"
)
if (item.field?.value !== "Done") {
throw new Error("Field value is not correct")
}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Add Item
uses: ./add-item/
id: add-item
with:
content-url: https://github.com/dsanders11/project-actions/pull/2
field: Added
field-value: ${{ steps.get-date.outputs.result }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Get Added Item
uses: ./get-item/
id: get-added-item
with:
field: Added
item: ${{ steps.add-item.outputs.id }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Added Item Field Value
uses: ./github-script/
with:
script: |
if ("${{ steps.get-added-item.outputs.field-value }}" !== new Date("${{ steps.get-date.outputs.result }}").toISOString().split('T')[0]) {
throw new Error("Field value is not correct")
}
- name: Edit Item
uses: ./edit-item/
id: edit-item
with:
field: Priority
field-value: ⛰️ High
item: ${{ steps.get-added-item.outputs.id }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Get Item
uses: ./get-item/
id: get-edited-item
with:
field: Priority
item: ${{ steps.edit-item.outputs.id }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Edited Item Field Value
uses: ./github-script/
with:
script: |
if ("${{ steps.get-edited-item.outputs.field-value }}" !== "⛰️ High") {
throw new Error("Field value is not correct")
}
- name: Test GitHub Script Action
uses: ./github-script/
with:
token: ${{ steps.get-auth-token.outputs.token }}
script: |
const item = await actions.getItem(
"${{ steps.copy-project.outputs.owner }}",
"${{ steps.copy-project.outputs.number }}",
"${{ steps.edit-item.outputs.id }}",
"Priority"
)
if (item.field?.value !== "⛰️ High") {
throw new Error("Field value is not correct")
}
# - name: Archive Item
# uses: ./archive-item/
# id: archive-item
# with:
# item: ${{ steps.add-item.outputs.id }}
# owner: ${{ steps.copy-project.outputs.owner }}
# project-number: ${{ steps.copy-project.outputs.number }}
# token: ${{ steps.get-auth-token.outputs.token }}
# - name: Unarchive Item
# uses: ./archive-item/
# id: unarchive-item
# with:
# archived: false
# item: ${{ steps.add-item.outputs.id }}
# owner: ${{ steps.copy-project.outputs.owner }}
# project-number: ${{ steps.copy-project.outputs.number }}
# token: ${{ steps.get-auth-token.outputs.token }}
- name: Delete Item
uses: ./delete-item/
id: delete-item
with:
item: ${{ steps.edit-item.outputs.id }}
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Link Project to Repository
uses: ./link-project/
if: ${{ matrix.owner == 'dsanders11' }}
with:
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
repository: dsanders11/project-actions
token: ${{ steps.get-auth-token.outputs.token }}
- name: Link Project to Team
uses: ./link-project/
if: ${{ matrix.owner == 'dsanders11-playground-org' }}
with:
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
team: dsanders11-playground-org/maintainers
token: ${{ steps.get-auth-token.outputs.token }}
- name: Edit Project
uses: ./edit-project/
id: edit-project
with:
description: New Description
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
readme: This is the readme
title: New Title ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Find Project
uses: ./find-project/
id: find-project
with:
owner: ${{ matrix.owner }}
title: New Title ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Confirm Project Found
uses: ./github-script/
with:
script: |
if ("${{ steps.copy-project.outputs.number }}" !== "${{ steps.find-project.outputs.number }}") {
throw new Error("Could not find project by title")
}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Get Project
uses: ./get-project/
id: get-project
with:
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Project Values
uses: ./github-script/
with:
script: |
if ("${{ steps.get-project.outputs.title }}" !== "New Title ${{ steps.copy-project.outputs.number }}") {
throw new Error("Project title is not correct")
}
if ("${{ steps.get-project.outputs.description }}" !== "New Description") {
throw new Error("Project description is not correct")
}
if ("${{ steps.get-project.outputs.readme }}" !== "This is the readme") {
throw new Error("Project readme is not correct")
}
- name: Close Project
uses: ./close-project/
id: close-project
with:
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Reopen Project
uses: ./close-project/
id: reopen-project
with:
closed: false
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Delete Project
uses: ./delete-project/
id: delete-project
with:
owner: ${{ steps.copy-project.outputs.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}