-
-
Notifications
You must be signed in to change notification settings - Fork 466
259 lines (224 loc) · 7.99 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
name: Zephir CI
on:
schedule:
- cron: '0 2 * * *' # Daily at 02:00 runs only on default branch
push:
paths-ignore:
- '**.md'
- '**.txt'
- '**/nightly.yml'
- '**/release.yml'
- '**/FUNDING.yml'
pull_request:
branches:
- master
- development
env:
RE2C_VERSION: 2.2
ZEPHIR_PARSER_VERSION: 1.6.1
PSR_VERSION: 1.2.0
CACHE_DIR: .cache
jobs:
analyze:
name: Static Code Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
PHP_CS_FIXER_VERSION: 3.37.0
with:
php-version: '8.0'
coverage: none
tools: php-cs-fixer:${{ env.PHP_CS_FIXER_VERSION }}, phpcs
- name: Run PHP_CodeSniffer
run: |
phpcs --version
phpcs --runtime-set ignore_warnings_on_exit true
# Disabling for now until I figure out the rules
# - name: Run PHP CS Fixer
# if: always()
# run: |
# php-cs-fixer fix --diff --dry-run -v --using-cache=no
- name: Run Shell Check
if: always()
run: shellcheck .ci/*.sh
build-and-test:
name: "PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
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 }
# 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' }
# Disabled due PSR extension wasn't complied for >=8.2
#- { 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
with:
fetch-depth: 5
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: mbstring, fileinfo, gmp, sqlite, pdo_sqlite, psr-${{ env.PSR_VERSION }}, zip, mysqli, zephir_parser-${{ env.ZEPHIR_PARSER_VERSION }}
tools: phpize, php-config
coverage: xdebug
# variables_order: https://github.com/zephir-lang/zephir/pull/1537
# enable_dl: https://github.com/zephir-lang/zephir/pull/1654
# allow_url_fopen: https://github.com/zephir-lang/zephir/issues/1713
# error_reporting: https://github.com/zendframework/zend-code/issues/160
ini-values: >-
variables_order=EGPCS,
enable_dl=On,
allow_url_fopen=On,
error_reporting=-1,
memory_limit=1G,
date.timezone=UTC,
xdebug.max_nesting_level=256
env:
phpts: ${{ matrix.ts }}
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Project Dependencies
run: composer install --prefer-dist --no-interaction --no-ansi --no-progress
- name: Fast Commands Test
run: php zephir --help
- name: Build Test Extension (Linux)
if: runner.os == 'Linux'
uses: ./.github/workflows/build-linux-ext
with:
compiler: ${{ matrix.compiler }}
cflags: '-O2 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1'
ldflags: '--coverage'
- name: Build Test Extension (macOS)
if: runner.os == 'macOS'
uses: ./.github/workflows/build-macos-ext
with:
compiler: ${{ matrix.compiler }}
cflags: '-O2 -fvisibility=hidden -Wparentheses -flto -DZEPHIR_RELEASE=1'
- name: Build Test Extension (Windows)
if: runner.os == 'Windows'
uses: ./.github/workflows/build-win-ext
with:
php_version: ${{ matrix.php }}
ts: ${{ matrix.ts }}
msvc: ${{ matrix.compiler }}
arch: ${{ matrix.arch }}
cflags: '/D ZEPHIR_RELEASE /Oi /Ot /Oy /Ob2 /Gs /GF /Gy /GL'
ldflags: '/LTCG'
env:
CACHE_DIR: 'C:\Downloads'
PHP_ROOT: 'C:\tools\php'
- name: Stub Extension Info
shell: pwsh
run: |
php --ini
php --ri stub
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Unit Tests (Stub Extension)
shell: pwsh
run: |
php vendor/bin/phpunit -c phpunit.ext.xml
env:
XDEBUG_MODE: coverage
- name: Unit Tests (Zephir)
if: always()
run: php vendor/bin/phpunit --testsuite Zephir --coverage-php ./tests/output/clover.xml
env:
XDEBUG_MODE: coverage
- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "unit-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
path: "tests/output/clover.xml"
- name: Black-box Testing
if: always() && runner.os != 'Windows'
shell: bash
working-directory: tests/sharness
run: |
make -j$(getconf _NPROCESSORS_ONLN)
upload-coverage:
permissions:
contents: read
name: "Upload coverage"
runs-on: "ubuntu-22.04"
needs:
- "build-and-test"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,./qodana.sarif.json
# - name: 'Qodana Scan'
# run: |
# docker run \
# -v $(pwd):/data/project/ \
# -v $(pwd):/data/base/ \
# -e QODANA_TOKEN="${{ secrets.CODECOV_TOKEN }}" \
# jetbrains/qodana-php \
# --baseline /data/base/qodana.sarif.json
- name: "Create download folder"
run: |
mkdir -p reports
- name: "Download coverage files"
uses: "actions/[email protected]"
with:
path: "reports"
- name: "Display structure of downloaded files"
run: ls -R
working-directory: reports
- name: "Upload to Codecov"
uses: "codecov/codecov-action@v3"
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: reports
fail_ci_if_error: true
verbose: true
name: codecov-umbrella
- name: "Upload to Qodana"
run: |
docker run \
-v $(pwd):/data/project/ \
-v ./reports/:/data/coverage \
-e QODANA_TOKEN="${{ secrets.QODANA_TOKEN }}" \
jetbrains/qodana-php
- name: Upload build artifacts after Failure
if: failure()
uses: actions/upload-artifact@v3
with:
name: debug-PHP-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}-${{ matrix.arch }}
path: |
${{ github.workspace }}/*.log
${{ github.workspace }}/ext/
!${{ github.workspace }}/ext/kernel/
!${{ github.workspace }}/ext/stub/
!${{ github.workspace }}/ext/Release/
!${{ github.workspace }}/ext/x64/Release/
${{ github.workspace }}/tests/output/
retention-days: 7