generated from dsanders11/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
176 lines (149 loc) · 6.77 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
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' }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Generate GitHub App Token
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
id: generate-token
with:
creds: ${{ secrets.GH_APP_CREDS }}
- name: Make changes to commit and stage them
run: |
date > current-date.txt
echo 'foobar' > README.md
git add current-date.txt
git add README.md
git rm LICENSE
git add --chmod=+x src/lib.ts
- name: Commit to new ref
uses: ./
id: commit-new-ref
with:
message: Test new ref commit
ref: integration-test-playground-${{ github.run_id }}-${{ github.run_number }}
token: ${{ steps.generate-token.outputs.token }}
- name: Confirm new ref commit
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const assert = require('node:assert');
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.commit-new-ref.outputs.sha }}'];
// Fetch the commit by both ref and sha
for (const ref of refs) {
const { data } = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'integration-test-playground-${{ github.run_id }}-${{ github.run_number }}',
});
assert.strictEqual(data.sha, '${{ steps.commit-new-ref.outputs.sha }}', 'Expected sha for commit to match');
assert.strictEqual(data.commit.message, 'Test new ref commit', 'Expected commit message to match');
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
}
- name: Update checkout
run: |
git fetch
git checkout integration-test-playground-${{ github.run_id }}-${{ github.run_number }}
- name: Make changes to commit and stage them
run: |
date > current-date.txt
echo 'baz' > README.md
git add current-date.txt
git add README.md
git rm .prettierignore
git add --chmod=+x src/main.ts
- name: Update existing ref
uses: ./
id: update-existing-ref
with:
message: Test updating existing ref
ref: integration-test-playground-${{ github.run_id }}-${{ github.run_number }}
token: ${{ steps.generate-token.outputs.token }}
- name: Confirm existing ref commit
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const assert = require('node:assert');
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.update-existing-ref.outputs.sha }}'];
// Fetch the commit by both ref and sha
for (const ref of refs) {
const { data } = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'integration-test-playground-${{ github.run_id }}-${{ github.run_number }}',
});
assert.strictEqual(data.sha, '${{ steps.update-existing-ref.outputs.sha }}', 'Expected sha for commit to match');
assert.strictEqual(data.commit.message, 'Test updating existing ref', 'Expected commit message to match');
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
}
- name: Update checkout
run: git pull
- name: Make more changes to commit and stage them
run: |
date > current-date.txt
git add current-date.txt
- name: Update existing ref (again)
uses: ./
id: update-existing-ref-2
with:
message: Test updating existing ref (again)
ref: integration-test-playground-${{ github.run_id }}-${{ github.run_number }}
token: ${{ steps.generate-token.outputs.token }}
- name: Confirm existing ref commit
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const assert = require('node:assert');
const refs = ['integration-test-playground-${{ github.run_id }}-${{ github.run_number }}', '${{ steps.update-existing-ref-2.outputs.sha }}'];
// Fetch the commit by both ref and sha
for (const ref of refs) {
const { data } = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'integration-test-playground-${{ github.run_id }}-${{ github.run_number }}',
});
assert.strictEqual(data.sha, '${{ steps.update-existing-ref-2.outputs.sha }}', 'Expected sha for commit to match');
assert.strictEqual(data.commit.message, 'Test updating existing ref (again)', 'Expected commit message to match');
assert.strictEqual(data.commit.verification.verified, true, 'Expected commit to be verified');
}
- name: Update checkout
run: |
git pull
git clean -fdx
- name: Optionally don't fail if no changes to commit
uses: ./
with:
fail-on-no-changes: false
message: Nothing to commit
ref: integration-test-playground-${{ github.run_id }}-${{ github.run_number }}
token: ${{ steps.generate-token.outputs.token }}
- name: Clean up new ref
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.generate-token.outputs.token }}
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'heads/integration-test-playground-${{ github.run_id }}-${{ github.run_number }}'
});