-
Notifications
You must be signed in to change notification settings - Fork 0
352 lines (285 loc) · 9.1 KB
/
main.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
#
# JBZoo Toolbox - Csv-Blueprint.
#
# This file is part of the JBZoo Toolbox project.
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# @license MIT
# @copyright Copyright (C) JBZoo.com, All rights reserved.
# @see https://github.com/JBZoo/Csv-Blueprint
#
name: CI
on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'
schedule:
- cron: '0 0 * * *'
# To avoid copy-pasting the same commands and add control over the environment
env:
COLUMNS: 300
BLUEPRINT: time ./csv-blueprint
BLUEPRINT_PHAR: time ./build/csv-blueprint.phar
BLUEPRINT_DOCKER: time docker run --rm --workdir=/parent-host -v .:/parent-host jbzoo/csv-blueprint:local
CMD_VALIDATE: validate-csv --ansi -vvv
VALID_TEST: --csv=./tests/fixtures/batch/*.csv --schema=./tests/schemas/demo_valid.yml
INVALID_TEST: --csv=./tests/fixtures/batch/*.csv --schema=./tests/schemas/demo_*.yml --schema=./tests/schemas/invalid_schema.yml
jobs:
test-current-versions:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
ext-parallel: [ '', 'parallel' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
id: setup-php
with:
php-version: 8.3
coverage: xdebug
extensions: ast, ${{ matrix.ext-parallel }}
env:
phpts: zts
- name: Build project
run: make build --no-print-directory
- name: 🧪 PHPUnit Tests
run: make test --no-print-directory
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
continue-on-error: true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: 👍 Code Quality
run: make codestyle --no-print-directory
test-lowest-versions:
name: Tests - Lowest
runs-on: ubuntu-latest
env:
JBZOO_COMPOSER_UPDATE_FLAGS: '--prefer-lowest'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none
extensions: ast
- name: Install project
run: make build --no-print-directory
## To see the difference between the current and the lowest versions
- name: Downgrade dependencies
run: make update --no-print-directory
- name: 🧪 PHPUnit Tests
run: make test --no-print-directory
- name: 👍 Code Quality
run: make codestyle --no-print-directory
test-latest-libs:
name: Tests - Latest
runs-on: ubuntu-latest
env:
JBZOO_COMPOSER_UPDATE_FLAGS: '--with-all-dependencies'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: highest
coverage: none
extensions: ast
- name: Install project
run: make build --no-print-directory
## To see the difference between the current and the latest versions
- name: Upgrade dependencies
run: make update --no-print-directory
- name: 🧪 PHPUnit Tests
run: make test --no-print-directory
- name: 👍 Code Quality
run: make codestyle --no-print-directory
markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: 👍 Markdown Lint
uses: articulate/actions-markdownlint@v1
with:
config: .markdownlint.yml
files: '*.md'
verify-php-binary:
name: Verify PHP binary
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Build project in production mode
run: make build-prod --no-print-directory
- name: 🎨 Test help and logo
run: $BLUEPRINT --ansi -vvv
- name: 👍 Valid CSV files
run: $BLUEPRINT $CMD_VALIDATE $VALID_TEST
- name: 👎 Invalid CSV files
run: |
! $BLUEPRINT $CMD_VALIDATE $INVALID_TEST
- name: Test as composer package
if: github.ref != 'refs/heads/master'
run: |
mkdir -pv ./build/composer-test
cd ./build/composer-test
composer init --no-interaction --name="test/test"
composer require jbzoo/csv-blueprint:dev-${{ github.event.pull_request.head.ref }}
./vendor/bin/csv-blueprint
./vendor/bin/csv-blueprint validate-csv --ansi -vvv --csv="../../tests/fixtures/batch/*.csv" --schema="../../tests/schemas/demo_valid.yml"
verify-phar-binary:
name: Verify Phar
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 8.2, 8.3 ]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Build project in production mode
run: make build-prod build-phar-file --no-print-directory
- name: 🎨 Test help and logo
run: $BLUEPRINT_PHAR --ansi -vvv
- name: 👍 Valid CSV files
run: $BLUEPRINT_PHAR $CMD_VALIDATE $VALID_TEST
- name: 👎 Invalid CSV files
run: |
! $BLUEPRINT_PHAR $CMD_VALIDATE $INVALID_TEST
- name: Upload Artifacts
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: PHAR - PHP v${{ matrix.php-version }}
path: ./build/csv-blueprint.phar
compression-level: 0
verify-docker:
name: Verify Docker
runs-on: ubuntu-latest
env:
BENCH_COLS: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 🐳 Building Docker Image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: jbzoo/csv-blueprint:local
- name: 🎨 Test help and logo
run: $BLUEPRINT_DOCKER --ansi -vvv
- name: 👍 Valid CSV files
run: $BLUEPRINT_DOCKER $CMD_VALIDATE $VALID_TEST
- name: 👎 Invalid CSV files
run: |
! $BLUEPRINT_DOCKER $CMD_VALIDATE $INVALID_TEST
- name: 👍 Valid CSV files (Parallel)
run: $BLUEPRINT_DOCKER $CMD_VALIDATE $VALID_TEST --parallel
- name: 👎 Invalid CSV files (Parallel)
run: |
! $BLUEPRINT_DOCKER $CMD_VALIDATE $INVALID_TEST --parallel
- name: Prepare Benchmark
run: |
make build --no-print-directory
make bench-create-csv --no-print-directory
- name: 🔥 Benchmark (single thread)
run: |
! make bench-docker-quick --no-print-directory
- name: 🔥 Benchmark (multi threads)
run: |
! make bench-docker-quick-parallel --no-print-directory
- name: Push Docker Image (master)
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/master'
with:
context: .
push: true
tags: jbzoo/csv-blueprint:master
verify-ga:
name: Verify GitHub Actions
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: 👍 Valid CSV files
uses: ./
with:
csv: ./tests/fixtures/batch/*.csv
schema: ./tests/schemas/demo_valid.yml
- name: 👎 Invalid CSV files
uses: ./
with:
csv: ./tests/fixtures/batch/*.csv
schema: ./tests/schemas/demo_*.yml
continue-on-error: true
reports:
name: Reports
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: xdebug
extensions: ast
- name: Install project
run: make build --no-print-directory
- name: 📝 Build Reports
run: make report-all --no-print-directory
- name: Upload Artifacts
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: Reports
path: build/