-
Notifications
You must be signed in to change notification settings - Fork 36
294 lines (253 loc) · 11.1 KB
/
ci.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
# This file is part of the Zephir Parser.
#
# (c) Zephir Team <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: Zephir Parser CI
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
env:
RE2C_VERSION: 2.2
CONFIGURE_COVERAGE: '' # Configure options for overage is empty by default
jobs:
builds:
name: PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
ts: [ 'ts', 'nts' ]
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-latest, compiler: gcc, ccov: 'ON' }
# macOS
- { name: macos-clang, os: macos-12, compiler: clang, ccov: 'OFF' }
# Windows
- { php: '7.0', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.0', ts: 'ts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.1', ts: 'nts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.1', ts: 'ts', arch: 'x64', name: 'windows2019-vc14', os: 'windows-2019', compiler: 'vc14', ccov: 'OFF' }
- { php: '7.2', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.2', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.3', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.3', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.4', ts: 'nts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '7.4', ts: 'ts', arch: 'x64', name: 'windows2019-vc15', os: 'windows-2019', compiler: 'vc15', ccov: 'OFF' }
- { php: '8.0', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.0', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.1', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.1', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.2', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.2', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.3', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
- { php: '8.3', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
#- { php: '8.4', ts: 'nts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
#- { php: '8.4', ts: 'ts', arch: 'x64', name: 'windows2019-vs16', os: 'windows-2019', compiler: 'vs16', ccov: 'OFF' }
steps:
- uses: actions/checkout@v4
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
env:
PHPTS: ${{ matrix.ts }}
- name: Setup Build System
shell: bash
run: |
echo "::group::Enable Code Coverage Capture"
if [ "${{ matrix.ccov }}" = "ON" ]; then
echo "CONFIGURE_COVERAGE=--enable-coverage" >> $GITHUB_ENV
fi
echo "::endgroup::"
echo "::group::Setup PHP executable for tests"
if [ "${{ runner.os }}" = "Windows" ]; then
echo "TEST_PHP_EXECUTABLE=C:\tools\php\php.exe" >> $GITHUB_ENV
else
echo "TEST_PHP_EXECUTABLE=$(which php)" >> $GITHUB_ENV
fi
echo "::endgroup::"
- name: Build Zephir Parser Extension (Linux)
uses: ./.github/actions/build-linux
if: runner.os == 'Linux'
- name: Build Zephir Parser Extension (macOS)
uses: ./.github/actions/build-mac
if: runner.os == 'macOS'
- name: Build Zephir Parser Extension (Windows)
uses: ./.github/actions/build-win
if: runner.os == 'Windows'
with:
php_version: ${{ matrix.php }}
ts: ${{ matrix.ts }}
msvc: ${{ matrix.compiler }}
arch: ${{ matrix.arch }}
env:
CACHE_DIR: 'C:\Downloads'
TOOLS_DIR: 'C:\tools'
- name: Run Tests for Zephir Parser
shell: bash
run: |
php --ri zephir_parser
php run-tests.php -q; exit $?
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
- name: Collect Build Artifacts
shell: bash
run: |
echo "::group::Creating ZIP with Zephir Parser extension"
if [ "${{ runner.os }}" = "Windows" ]; then
EXTENSION="$(find ./x64 -type f -name 'php_zephir_parser.dll')"
else
EXTENSION="$(find ./modules -type f -name 'zephir_parser.so')"
fi
zip -rvj zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip \
$EXTENSION VERSION LICENSE CREDITS NO_WARRANTY CHANGELOG.md
echo "::endgroup::"
# Artifact names should be in next format:
# zephir_parser-{php-version}-{ts}-{os.name}-{compiler}-{arch}
# example:
# zephir_parser-php-7.3-nts-macos-clang-x64.zip
# zephir_parser-php-7.3-nts-ubuntu-gcc-x64.zip
# zephir_parser-php-7.3-nts-windows2019-vc15-x64.zip
- name: Upload Zephir Parser
uses: actions/upload-artifact@v4
with:
name: zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}.zip
path: |
${{ github.workspace }}/zephir_parser-*.zip
- name: Check for Errors
if: always()
shell: pwsh
run: |
Get-ChildItem (Get-Item -Path "./" -Verbose).FullName *.log |
ForEach-Object{
$BaseName = $_.BaseName
Write-Output "::group::-- Log details: ${BaseName}.log --"
Get-Content -Path "${env:GITHUB_WORKSPACE}\${BaseName}.log"
Write-Output "::endgroup::"
}
- name: Capture Coverage Data
if: success() && matrix.ccov == 'ON'
run: make coverage-capture
- name: Upload Code Coverage Report
if: matrix.ccov == 'ON'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info
flags: unittests,${{ runner.os }}
- name: Upload Info for Debug on Fail
if: failure()
uses: actions/upload-artifact@v4
with:
retention-days: 2
name: debug-zephir_parser-php-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
path: |
${{ github.workspace }}/tests
${{ github.workspace }}/parser
${{ github.workspace }}/Release*
${{ github.workspace }}/**/Release*
pecl:
name: Build PECL package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: pecl
- name: Install System Dependencies
run: |
sudo apt-get update --quiet --yes 1>/dev/null
sudo apt-get install --no-install-recommends -q -y re2c
- name: Build Zephir Parser
run: |
echo "::group::Run phpize"
phpize
echo "::endgroup::"
echo "::group::Run configure"
./configure \
--enable-zephir-parser \
--enable-zephir-parser-debug
echo "::endgroup::"
echo "::group::Compile"
make -j$(getconf _NPROCESSORS_ONLN)
echo "::endgroup::"
- name: Prepare PECL package config
shell: pwsh
run: |
echo "-- Replacing Release data"
$Config = [xml](Get-Content ./package.xml)
$Config.package.date = $(Get-Date -Format "yyyy-MM-dd")
$Config.package.time = $(Get-Date -Format "HH:mm:ss")
$Config.package.version.Item(1).release = $(Get-Content ./VERSION)
$Config.package.version.Item(1).api = $Config.package.version.release
echo "-- Parsing CHANGELOG"
./.ci/release-notes.sh ./CHANGELOG.md > ./release-notes.md
$Config.package.notes = $(Get-Content ./release-notes.md -Encoding UTF8 -Raw)
$Config.Save('./package.xml')
- name: Create PECL package
run: |
pecl package
zephir_parser_package="`ls | grep zephir_parser-*tgz`"
mv $zephir_parser_package zephir_parser-pecl.tgz
- name: Validate PECL Package
run: |
pecl package-validate zephir_parser-pecl.tgz
pecl info zephir_parser-pecl.tgz
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: 'zephir_parser-pecl'
path: zephir_parser-pecl.tgz
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [ builds, pecl ]
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get the release version
id: get-version
run: |
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
- name: Download Zephir Parser 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 zephir_parser*.zip -exec cp {} ./build-artifacts/release/ ";"
echo "-- Creating Release Notes"
./.ci/release-notes.sh ./CHANGELOG.md > ./build-artifacts/release/release-notes.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ steps.get-version.outputs.version }}
tag: ${{ steps.get-version.outputs.version }}
bodyFile: "./build-artifacts/release/release-notes.md"
allowUpdates: true
artifacts: "./build-artifacts/release/*.zip"
artifactContentType: application/octet-stream