Skip to content

Commit 2a41e26

Browse files
authored
PHP 8+ / Move CI to GHA (#28)
1 parent a0febcc commit 2a41e26

File tree

10 files changed

+373
-218
lines changed

10 files changed

+373
-218
lines changed

.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/workflows/CI.yml

Lines changed: 147 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,218 @@
11
name: 'CI'
2-
on: # rebuild any PRs and main branch changes
2+
on: # Build any PRs and main branch changes
3+
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
34
pull_request:
45
types:
56
- opened
7+
- edited
68
- synchronize
79
push:
810
branches: [ master ]
11+
schedule:
12+
- cron: '0 0 1 * *' # Every month
913

1014
concurrency:
11-
group: "CI-${{ github.head_ref }}"
15+
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
1216
cancel-in-progress: true
1317

1418
env:
15-
# Cache params
16-
CACHE_VERSION: 2022031803 # To be able to create a new cache (YYYYMMDDXX)
17-
CI: 'true'
18-
COVERAGE_OUTPUT_STYLE: clover
19-
TEST_OUTPUT_STYLE: 'pretty'
20-
PHPCS_REPORT_STYLE: 'full'
21-
COMPOSER_OPTIONS: '--optimize-autoloader'
19+
TEST_OUTPUT_STYLE: pretty
20+
COMPOSER_OPTIONS: --optimize-autoloader
21+
CODACY_CACHE_PATH: ~/.cache/codacy
22+
CODACY_BIN: ~/.cache/codacy/codacy.sh
2223

2324
jobs:
24-
unit-tests:
25-
name: Unit / PHP ${{ matrix.php-version }}
25+
tests:
26+
name: UTs & FTs - PHP ${{ matrix.php-version }}
2627
runs-on: ubuntu-latest
28+
env:
29+
COVERAGE_TYPE: none
2730
strategy:
2831
fail-fast: true
32+
max-parallel: 4
2933
matrix:
30-
php-version:
31-
- '7.4'
32-
- '8.0'
33-
- '8.1'
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'
3440
steps:
3541
- name: Check out code
36-
uses: actions/checkout@v2
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
3749
38-
- name: Setup PHP
50+
- name: Setup PHP ${{ matrix.php-version }}
3951
uses: shivammathur/setup-php@v2
4052
with:
4153
php-version: '${{ matrix.php-version }}'
4254
tools: composer
43-
coverage: xdebug
55+
coverage: ${{ env.COVERAGE_TYPE }}
4456
env:
4557
# Always use latest available patch for the version
4658
update: true
4759

4860
- name: Setup cache
4961
id: cache
50-
uses: actions/cache@v2
62+
uses: actions/cache@v3
5163
with:
5264
path: |
5365
~/.composer
5466
./vendor
67+
${{ env.CODACY_CACHE_PATH }}
5568
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
56-
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
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
5778
5879
- name: Build
59-
run: make build
80+
run: |
81+
make build
6082
61-
- name: Test
62-
run: make test-unit
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-server-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
6391

64-
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
65-
- name: Upload coverage to codecov
66-
uses: codecov/codecov-action@v2
92+
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-server-doc-sdk
93+
- name: Upload unit tests coverage to codecov
94+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
95+
uses: codecov/codecov-action@v3
6796
with:
97+
file: "build/coverage-phpunit/unit.clover"
6898
name: "unit-tests-${{ matrix.php-version }}"
6999
flags: "unit-tests,php-${{ matrix.php-version }}"
70100
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
71145

72-
functional-tests:
73-
name: Functional / PHP ${{ matrix.php-version }}
74-
needs: [unit-tests]
146+
- name: Dependencies check
147+
if: ${{ github.event_name == 'pull_request' }}
148+
uses: actions/dependency-review-action@v1
149+
150+
finalize-codacy-coverage-report:
75151
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-server-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 ]
76182
strategy:
77-
fail-fast: true
183+
fail-fast: false
184+
max-parallel: 4
78185
matrix:
79186
php-version:
80-
- '7.4'
81-
- '8.0'
82-
- '8.1'
187+
- '8.3' # Current php dev version
188+
83189
steps:
84190
- name: Check out code
85-
uses: actions/checkout@v2
191+
uses: actions/checkout@v3
86192

87-
- name: Setup PHP
193+
- name: Setup PHP ${{ matrix.php-version }}
88194
uses: shivammathur/setup-php@v2
89195
with:
90196
php-version: '${{ matrix.php-version }}'
91197
tools: composer
92-
coverage: xdebug
198+
coverage: none
93199
env:
94200
# Always use latest available patch for the version
95201
update: true
96202

97203
- name: Setup cache
98204
id: cache
99-
uses: actions/cache@v2
205+
uses: actions/cache@v3
100206
with:
101207
path: |
102208
~/.composer
103209
./vendor
104210
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
105-
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
211+
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
106212

107213
- name: Build
108-
run: make build
214+
run: |
215+
make build
109216
110217
- name: Test
111-
run: make test-functional
112-
113-
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
114-
- name: Upload coverage to codecov
115-
uses: codecov/codecov-action@v2
116-
with:
117-
name: "functional-tests-${{ matrix.php-version }}"
118-
flags: "functional-tests,php-${{ matrix.php-version }}"
119-
fail_ci_if_error: true
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)