-
Notifications
You must be signed in to change notification settings - Fork 166
240 lines (233 loc) · 8.49 KB
/
pr-change-check.yaml
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
name: PR Check
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
paths:
- 'FFXIVClientStructs/**/*.cs'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/composites/update-dotnet
- name: Install dependencies
run: dotnet restore
- name: Run CExporter
working-directory: ./
run: dotnet run --project CExporter/CExporter.csproj -c Release
- name: Check error txt file for content
id: check_error
run: |
if [ -s ./ida/errors.txt ]; then
echo "error=true" >> $GITHUB_OUTPUT
else
echo "error=false" >> $GITHUB_OUTPUT
fi
- name: Upload error txt to comment
if: steps.check_error.outputs.error == 'true'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const content = fs.readFileSync('./ida/errors.txt', 'utf8');
const comments = (await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const comment = comments.filter(comment => comment.user.login === 'github-actions[bot]');
if (comment.length > 0) {
comment.forEach(comment => {
github.rest.issues.deleteComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo
});
});
}
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: content
});
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["requested changes"]
})
- name: Exit with error
if: steps.check_error.outputs.error == 'true'
run: exit 1
- name: Cleanup issue
if: steps.check_error.outputs.error == 'false'
uses: actions/github-script@v7
with:
script: |
const comments = (await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const comment = comments.filter(comment => comment.user.login === 'github-actions[bot]');
if (comment.length > 0) {
comment.forEach(comment => {
github.rest.issues.deleteComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo
});
});
}
const labels = (await github.rest.issues.listLabelsOnIssue({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const label = labels.find(label => label.name === 'requested changes');
if (label) {
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
name: 'requested changes',
owner: context.repo.owner,
repo: context.repo.repo
});
}
- uses: actions/upload-artifact@v4
with:
name: structs.yml
path: ./ida/ffxiv_structs.yml
retention-days: 7
build-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/composites/update-dotnet
- name: Install dependencies for PR branch
run: dotnet restore
- name: Build PR branch
run: dotnet build FFXIVClientStructs/FFXIVClientStructs.csproj --output ida/cs
- uses: actions/upload-artifact@v4
with:
name: cs-pr
path: ida/cs/FFXIVClientStructs.dll
retention-days: 1
build-main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: ./.github/composites/update-dotnet
- name: Install dependencies for Main branch
run: dotnet restore
- name: Build Main branch
run: dotnet build FFXIVClientStructs/FFXIVClientStructs.csproj --output ida/cs
- uses: actions/upload-artifact@v4
with:
name: cs-main
path: ida/cs/FFXIVClientStructs.dll
retention-days: 1
check-breaking-changes:
runs-on: ubuntu-latest
needs: [build-pr, build-main, test]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: cs-pr
path: ida/cs-pr
- uses: actions/download-artifact@v4
with:
name: cs-main
path: ida/cs-main
- name: Check for breaking changes
id: breaking_changes
run: |
dotnet tool install -g Microsoft.DotNet.ApiCompat.Tool
dotnet run --project CompatChecker/CompatChecker.csproj -c Release -- ida/cs-main/FFXIVClientStructs.dll ida/cs-pr/FFXIVClientStructs.dll ida/errors.txt
if [ -s ./ida/errors.txt ]; then
echo "breaking=true" >> $GITHUB_OUTPUT
else
echo "breaking=false" >> $GITHUB_OUTPUT
fi
- name: Handle breaking change
uses: actions/github-script@v7
if: steps.breaking_changes.outputs.breaking == 'true'
with:
script: |
const fs = require('fs');
const content = fs.readFileSync('./ida/errors.txt', 'utf8');
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["breaking change"]
})
const comments = (await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const comment = comments.filter(comment => comment.user.login === 'github-actions[bot]');
if (comment.length > 0) {
comment.forEach(comment => {
github.rest.issues.deleteComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo
});
});
}
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: content
});
throw new Error('Breaking changes detected');
- name: Handle non breaking change
uses: actions/github-script@v7
if: steps.breaking_changes.outputs.breaking == 'false'
with:
script: |
const comments = (await github.rest.issues.listComments({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const comment = comments.filter(comment => comment.user.login === 'github-actions[bot]');
if (comment.length > 0) {
comment.forEach(comment => {
github.rest.issues.deleteComment({
comment_id: comment.id,
owner: context.repo.owner,
repo: context.repo.repo
});
});
}
const labels = (await github.rest.issues.listLabelsOnIssue({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo
})).data
const label = labels.find(label => label.name === 'breaking change');
if (label) {
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
name: 'breaking change',
owner: context.repo.owner,
repo: context.repo.repo
});
}