-
Notifications
You must be signed in to change notification settings - Fork 1
239 lines (199 loc) · 6.75 KB
/
develop.yml
File metadata and controls
239 lines (199 loc) · 6.75 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
name: PR Code review
on:
push:
branches:
- main
pull_request:
env:
# Define the primary PHP version for release, build, coverage uploads and badge generation
PRIMARY_PHP_VERSION: '8.4'
jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up runtime
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PRIMARY_PHP_VERSION }}
tools: composer
- name: Validate dependency file
run: composer validate --strict
- name: Install dependencies
run: composer run install:ci
- name: Run PHP lint (phpcs, rector, php-cs-fixer)
id: lint
continue-on-error: true
run: composer run lint:all
- name: Show error message if lint fails
if: steps.lint.outcome == 'failure'
run: |
echo "::error::Linting failed! Please run 'composer run fix:all' locally to fix issues."
exit 1
- name: symfony-insight
# Need to check how to setup symfony insight properly
if: false
run: |
composer require --dev sensiolabs/insight-cli
./vendor/bin/insight analyze --level=minor --fail-on=critical
tests:
name: Test on PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.1, 8.2, 8.3, 8.4]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up runtime
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
extensions: mbstring, intl, json, curl
- name: Install dependencies
run: composer run install:ci
- name: Run unit tests
run: composer run test:unit
doc:
name: Generate Documentation
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: ./.github/actions/doc
with:
default-runtime-version: ${{ env.PRIMARY_PHP_VERSION }}
coverage:
name: Code Coverage Report
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: ./.github/actions/coverage
with:
default-runtime-version: ${{ env.PRIMARY_PHP_VERSION }}
codecov-secret: ${{ secrets.CODECOV_TOKEN || 'Please define a CODECOV_TOKEN in your GitHub envVars' }}
github-secret: ${{ secrets.OPENAPI_WORKFLOW_TOKEN || 'Please define a OPENAPI_WORKFLOW_TOKEN in your GitHub envVars' }}
build:
name: Build Project
runs-on: ubuntu-latest
needs: [ coverage, quality ]
# Deactivated as not necessary for PHP
if: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up runtime
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PRIMARY_PHP_VERSION }}
extensions: mbstring, intl, json, curl
- name: Install dependencies
run: composer run install:ci
- name: Build project
run: composer run build
compare-signatures:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [ coverage ]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- 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_NODE_BRANCH: main
SDK_PHP_BRANCH: ${{ github.head_ref || github.ref_name }}
WORKFLOW_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
GH_TOKEN: ${{ secrets.WORKFLOW_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.WORKFLOW_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
});
}