-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (202 loc) · 6.56 KB
/
develop.yml
File metadata and controls
249 lines (202 loc) · 6.56 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
name: PR Code review
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: write
issues: write
env:
# Define the primary Node.js version for release, build, coverage uploads and badge generation
PRIMARY_NODE_VERSION: '25'
jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up runtime - Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v6
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
cache: 'npm'
- name: Validate dependency file
run: npm install --dry-run
- name: Install dependencies
run: npm ci
- name: Run JS/TS lint (eslint, prettier)
run: npm run lint:all
tests:
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up runtime - Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- name: Install OpenAPI Generator CLI
run: npm run spec:generate:install
- name: Generate OpenAPI client
run: npm run spec:generate
- name: Run unit tests
run: npm run test:unit
doc:
name: Generate Documentation
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: ./.github/workflows/actions/doc
with:
default-runtime-version: ${{ env.PRIMARY_NODE_VERSION }}
coverage:
name: Code Coverage Report
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: ./.github/workflows/actions/coverage
if: false
with:
default-runtime-version: ${{ env.PRIMARY_NODE_VERSION }}
codecov-secret: ${{ secrets.CODECOV_TOKEN || 'Please define a CODECOV_TOKEN in your GitHub envVars' }}
build:
name: Build Project
runs-on: ubuntu-latest
needs: [ coverage, quality ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up runtime - Node.js ${{ env.PRIMARY_NODE_VERSION }}
uses: actions/setup-node@v6
with:
node-version: ${{ env.PRIMARY_NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- name: Install OpenAPI Generator CLI
run: npm run spec:generate:install
- name: Generate OpenAPI client
run: npm run spec:generate
- name: Build project
run: npm run build
compare-signatures:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [ build ]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Install repo dependencies
run: npm ci
- name: Install SDK checker
run: npm install --no-save upsun-sdk-checker@latest
- name: Run SDK comparison (informational)
id: sdk_checker
continue-on-error: true
env:
EXCLUDE_OPTIONAL_PARAMS: "true"
EXCLUDE_DEPRECATED: "true"
SDK_PHP_BRANCH: main
SDK_NODE_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -o pipefail
npx upsun-sdk-checker full:checks 2>&1 | tee sdk-checker-report.txt
- name: Comment SDK comparison output on PR
if: github.event_name == 'pull_request'
continue-on-error: true
uses: actions/github-script@v9
env:
REPORT_PATH: sdk-checker-report.txt
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const marker = '<!-- upsun-sdk-checker-report -->';
const reportPath = process.env.REPORT_PATH;
let report = '';
try {
report = fs.readFileSync(reportPath, 'utf8');
} catch (error) {
report = `Unable to read ${reportPath}: ${error.message}`;
}
// Remove ANSI/control sequences and replacement chars to keep PR comments readable.
report = report
.replace(/\u001B\[[0-9;]*[A-Za-z]/g, '')
.replace(/\u009B[0-9;]*[A-Za-z]/g, '')
.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, '')
.replace(/\uFFFD/g, '');
const maxLength = 60000;
let truncationNote = '';
if (report.length > maxLength) {
report = report.slice(0, maxLength);
truncationNote = `\n\n_Output truncated to ${maxLength} characters._`;
}
const safeReport = report.replace(/```/g, '\\\`\\\`\\\`');
const body = [
marker,
'## Upsun SDK checker report',
'',
'<details>',
'<summary>Display raw output</summary>',
'',
'```text',
safeReport,
'```',
'</details>',
truncationNote
].join('\n');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100
});
const existing = comments.find(comment =>
comment.user?.type === 'Bot' &&
comment.body?.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}