Skip to content

Commit 44165b7

Browse files
authored
PHP 8+ / Move CI to GHA (#22)
1 parent 7b3688a commit 44165b7

30 files changed

+694
-392
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
10+
[Makefile]
11+
indent_style = tab
12+
indent_size = 8
13+
14+
[{*.yml,*.yaml}]
15+
indent_style = space
16+
indent_size = 2

.gitattributes

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Ignore all test and documentation for archive
2+
/.github export-ignore
3+
/.gitattributes export-ignore
4+
/.gitignore export-ignore
5+
/.scrutinizer.yml export-ignore
6+
/.travis.yml export-ignore
7+
/.editorconfig export-ignore
8+
/codecov.yml export-ignore
9+
/.remarkrc export-ignore
10+
/.remarkignore export-ignore
11+
/behat.yml export-ignore
12+
/phpunit.xml.dist export-ignore
13+
/phpcs.xml.dist export-ignore
14+
/CODE_OF_CONDUCT.md export-ignore
15+
/CONTRIBUTING.md export-ignore
16+
/Makefile export-ignore
17+
/tests export-ignore
18+
/features export-ignore
19+
/docs export-ignore

.github/.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.yml]
2+
indent_style = space
3+
indent_size = 2

.github/workflows/CI.yml

+261
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
name: 'CI'
2+
on: # Build any PRs and main branch changes
3+
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
push:
10+
branches: [ master ]
11+
schedule:
12+
- cron: '0 0 1 * *' # Every month
13+
14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
16+
cancel-in-progress: true
17+
18+
env:
19+
TEST_OUTPUT_STYLE: pretty
20+
COMPOSER_OPTIONS: --optimize-autoloader
21+
CODACY_CACHE_PATH: ~/.cache/codacy
22+
CODACY_BIN: ~/.cache/codacy/codacy.sh
23+
24+
jobs:
25+
tests:
26+
name: UTs & FTs - Symfony ${{ matrix.symfony-version }}
27+
runs-on: ubuntu-latest
28+
env:
29+
COVERAGE_TYPE: none
30+
strategy:
31+
fail-fast: true
32+
max-parallel: 4
33+
matrix:
34+
include:
35+
# Bare minimum => Lowest versions allowed by composer config
36+
- symfony-version: '4.4'
37+
php-version: '8.0'
38+
composer-flag: --prefer-lowest
39+
# Up to date versions => Latest versions allowed by composer config
40+
- symfony-version: '5.4'
41+
php-version: '8.2'
42+
# Late symfony migration => Lowest symfony version with latest minor php version allowed by composer config
43+
- symfony-version: '4.4'
44+
php-version: '8.2'
45+
composer-flag: --prefer-lowest
46+
# Late php migration => Latest symfony version with lowest minor php version allowed by composer config
47+
- symfony-version: '5.4'
48+
php-version: '8.0'
49+
# Symfony 6.0 latest
50+
- symfony-version: '6.0'
51+
php-version: '8.2'
52+
# Symfony 6.0 lowest
53+
- symfony-version: '6.0'
54+
php-version: '8.0'
55+
composer-flag: --prefer-lowest
56+
steps:
57+
- name: Check out code
58+
uses: actions/checkout@v3
59+
60+
- name: Enable coverage
61+
if: ${{ matrix.php-version == '8.2' }}
62+
run: |
63+
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
64+
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
65+
66+
- name: Setup PHP ${{ matrix.php-version }}
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: '${{ matrix.php-version }}'
70+
tools: composer
71+
coverage: ${{ env.COVERAGE_TYPE }}
72+
env:
73+
# Always use latest available patch for the version
74+
update: true
75+
76+
- name: Setup cache
77+
id: cache
78+
uses: actions/cache@v3
79+
with:
80+
path: |
81+
~/.composer
82+
./vendor
83+
${{ env.CODACY_CACHE_PATH }}
84+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
85+
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
86+
87+
- name: Download codacy binary
88+
if: steps.cache.outputs.cache-hit != 'true'
89+
run: |
90+
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
91+
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
92+
&& chmod +x ${{ env.CODACY_BIN }} \
93+
&& ${{ env.CODACY_BIN }} download
94+
95+
- name: Build
96+
run: |
97+
SF_VERSION=${{ matrix.symfony-version }}
98+
# Issue with ParamterBag below 4.4.30 => https://github.com/symfony/symfony/commit/3eca446b21607ea1c7a865ece2dd8254c33679cc
99+
test '${{ matrix.symfony-version }}' = '4.4' && test '${{ matrix.php-version }}' = '8.2' && SF_VERSION=4.4.30
100+
composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
101+
symfony/http-foundation:^$SF_VERSION \
102+
symfony/http-kernel:^$SF_VERSION \
103+
symfony/config:^$SF_VERSION \
104+
symfony/dependency-injection:^$SF_VERSION \
105+
symfony/framework-bundle:^$SF_VERSION \
106+
symfony/routing:^$SF_VERSION \
107+
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
108+
&& make build
109+
110+
- name: Tests
111+
run: make test-unit && make test-functional
112+
113+
# Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false
114+
# And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context
115+
- name: Upload coverages to Codacy
116+
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server-doc') && env.COVERAGE_TYPE == 'xdebug' }}
117+
run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial
118+
119+
# See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server-doc
120+
- name: Upload unit tests coverage to codecov
121+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
122+
uses: codecov/codecov-action@v3
123+
with:
124+
file: "build/coverage-phpunit/unit.clover"
125+
name: "unit-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
126+
flags: "unit-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}"
127+
fail_ci_if_error: true
128+
move_coverage_to_trash: false
129+
verbose: ${{ runner.debug == '1' }}
130+
131+
- name: Upload functional tests coverage to codecov
132+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
133+
uses: codecov/codecov-action@v3
134+
with:
135+
files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover"
136+
name: "functional-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}"
137+
flags: "functional-tests,php-${{ matrix.php-version }},sf-${{ matrix.symfony-version }}"
138+
fail_ci_if_error: true
139+
move_coverage_to_trash: false
140+
verbose: ${{ runner.debug == '1' }}
141+
142+
static-checks:
143+
name: Static checks
144+
runs-on: ubuntu-latest
145+
steps:
146+
- uses: actions/checkout@v3
147+
148+
- name: Setup PHP 8.2
149+
uses: shivammathur/setup-php@v2
150+
with:
151+
php-version: 8.2 # Latest supported
152+
tools: composer
153+
coverage: none
154+
env:
155+
# Always use latest available patch for the version
156+
update: true
157+
158+
- name: Setup cache
159+
id: cache
160+
uses: actions/cache@v3
161+
with:
162+
path: |
163+
~/.composer
164+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
165+
key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}
166+
167+
- name: Build
168+
run: make build
169+
170+
- name: ComposerRequireChecker
171+
uses: docker://webfactory/composer-require-checker:4.5.0
172+
173+
- name: Dependencies check
174+
if: ${{ github.event_name == 'pull_request' }}
175+
uses: actions/dependency-review-action@v1
176+
177+
finalize-codacy-coverage-report:
178+
runs-on: ubuntu-latest
179+
name: Finalize Codacy coverage report
180+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server-doc' }}
181+
needs: [ tests ]
182+
steps:
183+
- name: Setup cache
184+
id: cache
185+
uses: actions/cache@v3
186+
with:
187+
path: |
188+
${{ env.CODACY_CACHE_PATH }}
189+
key: codacy-final
190+
191+
- name: Download codacy binary
192+
if: steps.cache.outputs.cache-hit != 'true'
193+
run: |
194+
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
195+
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
196+
&& chmod +x ${{ env.CODACY_BIN }} \
197+
&& ${{ env.CODACY_BIN }} download
198+
199+
- name: Finalize reporting
200+
run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }}
201+
202+
nightly-tests:
203+
name: Nightly - Symfony ${{ matrix.symfony-version }}
204+
runs-on: ubuntu-latest
205+
env:
206+
COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+'
207+
continue-on-error: true
208+
needs: [ static-checks, tests ]
209+
strategy:
210+
fail-fast: false
211+
max-parallel: 4
212+
matrix:
213+
php-version:
214+
- '8.3' # Current php dev version
215+
symfony-version:
216+
- '4.4' # Lowest LTS
217+
- '5.4' # Latest LTS
218+
- '6.0' # Current major version
219+
include:
220+
- symfony-version: '6.3' # Next symfony minor version to manage with latest supported PHP version
221+
php-version: '8.2'
222+
223+
steps:
224+
- name: Check out code
225+
uses: actions/checkout@v3
226+
227+
- name: Setup PHP ${{ matrix.php-version }}
228+
uses: shivammathur/setup-php@v2
229+
with:
230+
php-version: '${{ matrix.php-version }}'
231+
tools: composer
232+
coverage: none
233+
env:
234+
# Always use latest available patch for the version
235+
update: true
236+
237+
- name: Setup cache
238+
id: cache
239+
uses: actions/cache@v3
240+
with:
241+
path: |
242+
~/.composer
243+
./vendor
244+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
245+
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
246+
247+
- name: Build
248+
run: |
249+
composer config minimum-stability dev \
250+
&& composer require -W ${{ env.COMPOSER_OPTIONS }} \
251+
symfony/http-foundation:^${{ matrix.symfony-version }} \
252+
symfony/http-kernel:^${{ matrix.symfony-version }} \
253+
symfony/config:^${{ matrix.symfony-version }} \
254+
symfony/dependency-injection:^${{ matrix.symfony-version }} \
255+
symfony/framework-bundle:^${{ matrix.symfony-version }} \
256+
symfony/routing:^${{ matrix.symfony-version }} \
257+
&& composer update ${{ env.COMPOSER_OPTIONS }} \
258+
&& make build
259+
260+
- name: Test
261+
run: make test-unit && make test-functional

.remarkignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor

.remarkrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": [
3+
"remark-preset-lint-consistent",
4+
"remark-preset-lint-recommended"
5+
]
6+
}

0 commit comments

Comments
 (0)