generated from dsanders11/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
426 lines (371 loc) · 15.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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- 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: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.get-draft-issue.outputs.title }}', 'My Favorite Issue');
assert.strictEqual('${{ steps.get-draft-issue.outputs.field-value }}', 'Low');
assert.match(`${{ steps.get-draft-issue.outputs.body }}`, /Here's another bar/);
- 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 assert = require('node:assert');
const item = await actions.getItem(
'${{ steps.copy-project.outputs.owner }}',
'${{ steps.copy-project.outputs.number }}',
'${{ steps.get-draft-issue-id.outputs.id }}',
'Status'
)
assert.strictEqual(item.field?.value, 'Done');
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: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.get-added-item.outputs.field-value }}', new Date('${{ steps.get-date.outputs.result }}').toISOString().split('T')[0]);
- 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: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.get-edited-item.outputs.field-value }}', '⛰️ High');
- name: Test GitHub Script Action
uses: ./github-script/
with:
token: ${{ steps.get-auth-token.outputs.token }}
script: |
const assert = require('node:assert');
const item = await actions.getItem(
'${{ steps.copy-project.outputs.owner }}',
'${{ steps.copy-project.outputs.number }}',
'${{ steps.edit-item.outputs.id }}',
'Priority'
);
const items = await actions.getAllItems('${{ steps.copy-project.outputs.id }}');
assert.strictEqual(item.field?.value, '⛰️ High');
assert.strictEqual(items.length, 2, 'Expected 2 items');
# - 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/
id: link-project-to-repo
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: Check Project is Linked to Repository
uses: ./github-script/
if: ${{ matrix.owner == 'dsanders11' }}
with:
token: ${{ steps.get-auth-token.outputs.token }}
script: |
const assert = require('node:assert');
const { projectV2 } = await github.graphql(
`query getProjectLinkedRepos($projectId: ID!) {
projectV2: node(id: $projectId) {
... on ProjectV2 {
id
repositories(first: 10) {
nodes {
id
nameWithOwner
}
}
}
}
}`,
{ projectId: '${{ steps.copy-project.outputs.id }}' }
);
assert.strictEqual(projectV2.repositories.nodes.length, 1, 'Expected one linked repository');
assert.strictEqual(projectV2.repositories.nodes[0].nameWithOwner, 'dsanders11/project-actions', 'Project not linked to repository');
assert.strictEqual(projectV2.repositories.nodes[0].id, '${{ steps.link-project-to-repo.outputs.repository-id }}', `Output 'repository-id' is not as expected`);
- name: Link Project to Team
uses: ./link-project/
id: link-project-to-team
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: Check Project is Linked to Team
uses: ./github-script/
if: ${{ matrix.owner == 'dsanders11-playground-org' }}
with:
token: ${{ steps.get-auth-token.outputs.token }}
script: |
const assert = require('node:assert');
const { projectV2 } = await github.graphql(
`query getProjectLinkedRepos($projectId: ID!) {
projectV2: node(id: $projectId) {
... on ProjectV2 {
id
teams(first: 10) {
nodes {
id
name
}
}
}
}
}`,
{ projectId: '${{ steps.copy-project.outputs.id }}' }
);
assert.strictEqual(projectV2.teams.nodes.length, 1, 'Expected one linked team');
assert.strictEqual(projectV2.teams.nodes[0].name, 'maintainers', 'Project not linked to team');
assert.strictEqual(projectV2.teams.nodes[0].id, '${{ steps.link-project-to-team.outputs.team-id }}', `Output 'team-id' is not as expected`);
- 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: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.copy-project.outputs.number }}', '${{ steps.find-project.outputs.number }}', 'Expect to 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: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.get-project.outputs.title }}', 'New Title ${{ steps.copy-project.outputs.number }}');
assert.strictEqual('${{ steps.get-project.outputs.description }}', 'New Description');
assert.strictEqual('${{ steps.get-project.outputs.readme }}', 'This is the readme');
- name: Find Workflow
uses: ./find-workflow/
id: find-workflow
with:
owner: ${{ matrix.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
name: 'Item closed'
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Workflow Values
uses: ./github-script/
with:
script: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.find-workflow.outputs.name }}', 'Item closed');
assert.strictEqual(${{ steps.find-workflow.outputs.enabled }}, true);
assert.strictEqual('${{ steps.find-workflow.outputs.project-id }}', '${{ steps.get-project.outputs.id }}');
- name: Get Workflow
uses: ./get-workflow/
id: get-workflow
with:
owner: ${{ matrix.owner }}
project-number: ${{ steps.copy-project.outputs.number }}
number: ${{ steps.find-workflow.outputs.number }}
token: ${{ steps.get-auth-token.outputs.token }}
- name: Check Workflow Values
uses: ./github-script/
with:
script: |
const assert = require('node:assert');
assert.strictEqual('${{ steps.get-workflow.outputs.id }}', '${{ steps.find-workflow.outputs.id }}');
assert.strictEqual('${{ steps.get-workflow.outputs.name }}', 'Item closed');
assert.strictEqual('${{ steps.get-workflow.outputs.number }}', '${{ steps.find-workflow.outputs.number }}');
assert.strictEqual(${{ steps.get-workflow.outputs.enabled }}, true);
assert.strictEqual('${{ steps.get-workflow.outputs.project-id }}', '${{ steps.get-project.outputs.id }}');
- 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 }}