Skip to content

Commit e7f4d9f

Browse files
authored
PHP 8+ / Move CI to GHA (#36)
1 parent 2fb9e00 commit e7f4d9f

25 files changed

+501
-181
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
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 - PHP ${{ matrix.php-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+
- php-version: '8.0'
37+
composer-flag: --prefer-lowest
38+
# Up to date versions => Latest versions allowed by composer config
39+
- php-version: '8.2'
40+
steps:
41+
- name: Check out code
42+
uses: actions/checkout@v3
43+
44+
- name: Enable coverage
45+
if: ${{ matrix.php-version == '8.2' }}
46+
run: |
47+
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
48+
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
49+
50+
- name: Setup PHP ${{ matrix.php-version }}
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: '${{ matrix.php-version }}'
54+
tools: composer
55+
coverage: ${{ env.COVERAGE_TYPE }}
56+
env:
57+
# Always use latest available patch for the version
58+
update: true
59+
60+
- name: Setup cache
61+
id: cache
62+
uses: actions/cache@v3
63+
with:
64+
path: |
65+
~/.composer
66+
./vendor
67+
${{ env.CODACY_CACHE_PATH }}
68+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
69+
key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
70+
71+
- name: Download codacy binary
72+
if: steps.cache.outputs.cache-hit != 'true'
73+
run: |
74+
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
75+
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
76+
&& chmod +x ${{ env.CODACY_BIN }} \
77+
&& ${{ env.CODACY_BIN }} download
78+
79+
- name: Build
80+
run: |
81+
make build
82+
83+
- name: Tests
84+
run: make test-unit && make test-functional
85+
86+
# Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false
87+
# And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context
88+
- name: Upload coverages to Codacy
89+
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-http-server-swagger-doc-sdk') && env.COVERAGE_TYPE == 'xdebug' }}
90+
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
91+
92+
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-http-server-swagger-doc-sdk
93+
- name: Upload unit tests coverage to codecov
94+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
95+
uses: codecov/codecov-action@v3
96+
with:
97+
file: "build/coverage-phpunit/unit.clover"
98+
name: "unit-tests-${{ matrix.php-version }}"
99+
flags: "unit-tests,php-${{ matrix.php-version }}"
100+
fail_ci_if_error: true
101+
move_coverage_to_trash: false
102+
verbose: ${{ runner.debug == '1' }}
103+
104+
- name: Upload functional tests coverage to codecov
105+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
106+
uses: codecov/codecov-action@v3
107+
with:
108+
files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover"
109+
name: "functional-tests-${{ matrix.php-version }}"
110+
flags: "functional-tests,php-${{ matrix.php-version }}"
111+
fail_ci_if_error: true
112+
move_coverage_to_trash: false
113+
verbose: ${{ runner.debug == '1' }}
114+
115+
static-checks:
116+
name: Static checks
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v3
120+
121+
- name: Setup PHP 8.2
122+
uses: shivammathur/setup-php@v2
123+
with:
124+
php-version: 8.2 # Latest supported
125+
tools: composer
126+
coverage: none
127+
env:
128+
# Always use latest available patch for the version
129+
update: true
130+
131+
- name: Setup cache
132+
id: cache
133+
uses: actions/cache@v3
134+
with:
135+
path: |
136+
~/.composer
137+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
138+
key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}
139+
140+
- name: Build
141+
run: make build
142+
143+
- name: ComposerRequireChecker
144+
uses: docker://webfactory/composer-require-checker:4.5.0
145+
146+
- name: Dependencies check
147+
if: ${{ github.event_name == 'pull_request' }}
148+
uses: actions/dependency-review-action@v1
149+
150+
finalize-codacy-coverage-report:
151+
runs-on: ubuntu-latest
152+
name: Finalize Codacy coverage report
153+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-http-server-swagger-doc-sdk' }}
154+
needs: [ tests ]
155+
steps:
156+
- name: Setup cache
157+
id: cache
158+
uses: actions/cache@v3
159+
with:
160+
path: |
161+
${{ env.CODACY_CACHE_PATH }}
162+
key: codacy-final
163+
164+
- name: Download codacy binary
165+
if: steps.cache.outputs.cache-hit != 'true'
166+
run: |
167+
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
168+
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
169+
&& chmod +x ${{ env.CODACY_BIN }} \
170+
&& ${{ env.CODACY_BIN }} download
171+
172+
- name: Finalize reporting
173+
run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }}
174+
175+
nightly-tests:
176+
name: Nightly - PHP ${{ matrix.php-version }}
177+
runs-on: ubuntu-latest
178+
env:
179+
COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+'
180+
continue-on-error: true
181+
needs: [ static-checks, tests ]
182+
strategy:
183+
fail-fast: false
184+
max-parallel: 4
185+
matrix:
186+
php-version:
187+
- '8.3' # Current php dev version
188+
189+
steps:
190+
- name: Check out code
191+
uses: actions/checkout@v3
192+
193+
- name: Setup PHP ${{ matrix.php-version }}
194+
uses: shivammathur/setup-php@v2
195+
with:
196+
php-version: '${{ matrix.php-version }}'
197+
tools: composer
198+
coverage: none
199+
env:
200+
# Always use latest available patch for the version
201+
update: true
202+
203+
- name: Setup cache
204+
id: cache
205+
uses: actions/cache@v3
206+
with:
207+
path: |
208+
~/.composer
209+
./vendor
210+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
211+
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
212+
213+
- name: Build
214+
run: |
215+
make build
216+
217+
- name: Test
218+
run: make test-unit && make test-functional

.remarkignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor

.remarkrc

Lines changed: 6 additions & 0 deletions
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)