-
-
Notifications
You must be signed in to change notification settings - Fork 2k
416 lines (354 loc) · 14.3 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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# This file is part of Phalcon.
#
# (c) Phalcon Team <team@phalcon.io>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: Phalcon CI
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
workflow_dispatch:
env:
# All versions should be declared here
PHALCON_VERSION: 5.8.0
ZEPHIR_PARSER_VERSION: 1.6.1
# For tests
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
# Windows specific
TOOLS_DIR: 'C:\tools'
# PHP extensions required by Composer
EXTENSIONS: apcu, gettext, gd, igbinary, imagick, intl, json, mbstring, msgpack, memcached, sqlite3, yaml, redis, :memcache, openssl
permissions: {}
jobs:
# Configure Workflow for correct run reusable workflow
# This is required step. It's workaround for non-initialized ENVs when trying to pass input variables from ENVs.
# https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#limitations
setup_workflow:
name: Setup workflow
runs-on: ubuntu-latest
outputs:
zephir_extensions: ${{ steps.setup-zephir-ext.outputs.extensions }}
steps:
- id: setup-zephir-ext
name: Setup Zephir Extensions
run: |
echo "extensions=zephir_parser-${{ env.ZEPHIR_PARSER_VERSION }}" >> "$GITHUB_OUTPUT"
# PHP CodeSniffer inspection
phpcs:
permissions:
contents: read
uses: zephir-lang/templates/.github/workflows/phpcs.yml@main
with:
standard: ./phpcs.xml
# Generate stubs and validates with PSALM
stubs:
needs: setup_workflow
uses: zephir-lang/templates/.github/workflows/phalcon-stubs-zephir-composer.yml@main
with:
extensions: ${{ needs.setup_workflow.outputs.zephir_extensions }}
generate:
needs: setup_workflow
uses: zephir-lang/templates/.github/workflows/phalcon-pecl-zephir-composer.yml@main
with:
extensions: ${{ needs.setup_workflow.outputs.zephir_extensions }}
php_version: '8.3'
secrets:
composer-token: ${{ secrets.GITHUB_TOKEN }}
build-and-test:
permissions:
contents: read # to fetch code (actions/checkout)
name: tests / PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
needs: [generate]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
ts: [ 'nts', 'ts' ]
arch: [ 'x64' ]
name:
- ubuntu-gcc
- macos-clang
# matrix names should be in next format:
# {php}-{ts}-{os.name}-{compiler}-{arch}
include:
# Linux
- { name: ubuntu-gcc, os: ubuntu-20.04, compiler: gcc }
# macOS
- { name: macos-clang, os: macos-12, compiler: clang }
# Windows
- { php: '8.0', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
#- { php: '8.1', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
#- { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
# Most of the extensions wasn't compiled for PHP 8.2.
# So it is not possible to test in this version, inside Windows OS.
# List of .dlls - https://windows.php.net/downloads/pecl/releases/
#- { php: '8.2', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
#- { php: '8.2', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16' }
steps:
- uses: actions/checkout@v4
- name: Setup platform specific environment
shell: pwsh
run: |
git config --global core.autocrlf false
$SessionSavePath = if ("${{ runner.os }}" -eq "Windows") { 'C:\temp' } else { '/tmp' }
Write-Output "SESSION_SAVE_PATH=$SessionSavePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli=on, session.save_path=${{ env.SESSION_SAVE_PATH }}
tools: pecl, phpize, php-config
coverage: xdebug
env:
PHPTS: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v4
with:
name: phalcon-pecl
path: ./phalcon-pecl
- name: Build Phalcon Extension (Linux)
uses: ./.github/actions/build-phalcon-linux
if: runner.os == 'Linux'
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
php-version: ${{ matrix.php }}
- name: Build Phalcon Extension (macOS)
uses: ./.github/actions/build-phalcon-mac
if: runner.os == 'macOS'
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
- name: Build Phalcon Extension (Windows)
uses: ./.github/actions/build-phalcon-win
if: runner.os == 'Windows'
with:
pecl: 'phalcon-pecl\phalcon-pecl.tgz'
php_version: ${{ matrix.php }}
ts: ${{ matrix.ts }}
msvc: ${{ matrix.compiler }}
arch: ${{ matrix.arch }}
env:
CACHE_DIR: 'C:\Downloads'
TOOLS_DIR: ${{ env.TOOLS_DIR }}
- name: Get Phalcon Extension path
id: phalcon-ext-path
shell: pwsh
run: |
if ( "${{ runner.os }}" -eq 'Windows' ) {
$ReleaseFolder = if ("${{ matrix.ts }}" -eq "ts") { "Release_TS" } else { "Release" }
$ReleaseFolder = if ("${{ matrix.arch }}" -eq "x64") { "x64\${ReleaseFolder}" } else { "${ReleaseFolder}" }
$PhalconExtPath = "${{ env.TOOLS_DIR }}\pecl\phalcon\phalcon-${{ env.PHALCON_VERSION }}\${ReleaseFolder}\php_phalcon.dll"
} else {
$PhalconExtPath = "$(php-config --extension-dir)/phalcon.so"
}
echo "::set-output name=extension-path::$PhalconExtPath"
# echo "extension-path=$PhalconExtPath" >> "$GITHUB_OUTPUT"
- name: Creates build artifact with Phalcon extension
uses: ./.github/actions/pack-phalcon-ext
with:
target-name: phalcon-php${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
ext-path: ${{ steps.phalcon-ext-path.outputs.extension-path }}
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist"
- name: Setup Tests
shell: bash
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
./.ci/linux-setup-locales.sh
fi
cp tests/_config/.env.default .env
php tests/_config/generate-db-schemas.php
vendor/bin/codecept build
- name: Run Unit Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit
- name: Run CLI Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli
- name: Check Release notes parser
if: runner.os == 'Linux'
shell: bash
run: |
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG-5.0.md
install:
needs: setup_workflow
uses: zephir-lang/templates/.github/workflows/phalcon-install-from-build.yml@main
with:
extensions: ${{ needs.setup_workflow.outputs.zephir_extensions }}
integration-test:
permissions:
contents: read # to fetch code (actions/checkout)
needs: [generate]
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: phalcon
MYSQL_DATABASE: phalcon
MYSQL_PASSWORD: secret
postgres:
image: postgres:12-alpine
ports:
- "5432:5432"
env:
POSTGRES_USER: phalcon
POSTGRES_PASSWORD: secret
POSTGRES_DB: phalcon
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:5-alpine
ports:
- "6379:6379"
memcached:
image: memcached:1.5-alpine
ports:
- "11211:11211"
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
ini-values: apc.enable_cli=on, session.save_path=/tmp
tools: pecl
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download Phalcon Pecl Package
uses: actions/download-artifact@v4
with:
name: phalcon-pecl
path: ./phalcon-pecl
- name: Build Phalcon Extension from Pecl
uses: ./.github/actions/build-phalcon-linux
with:
pecl: ./phalcon-pecl/phalcon-pecl.tgz
php-version: ${{ matrix.php }}
- name: Prepare test Environment
run: |
echo "::group::Set up locales"
./.ci/linux-setup-locales.sh
echo "::endgroup::"
- name: "Validate composer"
run: composer validate --no-check-all --no-check-publish
- name: "Install development dependencies with Composer"
uses: ramsey/composer-install@v2
with:
composer-options: "--prefer-dist"
- name: Setup Tests
run: |
cp tests/_config/.env.default .env
php tests/_config/generate-db-schemas.php
vendor/bin/codecept build
- name: Run Unit Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter unit
- name: Run CLI Tests
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter cli
- name: Run Integration Tests
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter integration
- name: Run Database Tests (Common)
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database -g common
- name: Run Database Tests (MySQL)
env:
DATA_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
DATA_MYSQL_USER: root
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env mysql -g mysql
- name: Run Database Tests (Sqlite)
env:
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env sqlite -g sqlite
- name: Run Database Tests (Postgres)
env:
DATA_POSTGRES_USER: phalcon
DATA_POSTGRES_PASS: secret
DATA_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
if: always()
run: vendor/bin/codecept run --coverage-xml=coverage-${{ matrix.php }}.xml --ext DotReporter database --env pgsql -g pgsql
# - name: Run Database Tests (SQL Server)
# env:
# DATA_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
# DATA_MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }}
# run: vendor/bin/codecept run --ext DotReporter database --env sqlsrv
release:
permissions:
contents: write # to create a release (ncipollo/release-action)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [generate, install, build-and-test, integration-test]
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the release version
id: get-version
run: |
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
# echo ::set-output name=version::${GITHUB_REF#refs/tags/}
# echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" # This needs to be checked
- name: Download Phalcon build artifacts
id: download
uses: actions/download-artifact@v4
with:
path: ./build-artifacts
- name: Prepare Release assets
run: |
mkdir -p ./build-artifacts/release
find ./build-artifacts -type f -name phalcon*.zip -exec cp {} ./build-artifacts/release/ ";"
find ./build-artifacts -type f -name phalcon*.tgz -exec cp {} ./build-artifacts/release/ ";"
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG-5.0.md > ./build-artifacts/release/release-notes.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ env.version }}
tag: ${{ env.version }}
bodyFile: "./build-artifacts/release/release-notes.md"
allowUpdates: true
artifacts: "./build-artifacts/release/*.zip,./build-artifacts/release/*.tgz"
artifactContentType: application/octet-stream