Skip to content

Commit 3387777

Browse files
author
Simon Mönch
authored
Add PHP 8 support (#508)
1 parent d778d66 commit 3387777

File tree

12 files changed

+219
-102
lines changed

12 files changed

+219
-102
lines changed

.github/workflows/build.yml

Lines changed: 147 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,26 @@ on:
88
types: [ created ]
99

1010
jobs:
11-
tests:
11+
unit-tests:
1212
runs-on: ubuntu-latest
13-
name: Build and test
13+
name: "Unit-Tests: ${{ matrix.php }} - ${{ matrix.tools }} - PHAR readonly ${{ matrix.phar-readonly }}"
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
include:
18-
- php: 7.3
19-
tools: "composer:v1"
20-
coverage: "none"
21-
publish-phar: true
22-
git-fetch-depth: 0 # box/composer needs history to determine a recent git version
23-
- php: 7.3
24-
tools: "composer:v1"
25-
coverage: "none"
26-
phar-readonly: true
27-
git-fetch-depth: 1
28-
- php: 7.4
29-
tools: "composer:v1"
30-
coverage: "pcov"
31-
git-fetch-depth: 1
32-
- php: 7.4
33-
tools: "composer:v2"
34-
coverage: "none"
35-
git-fetch-depth: 1
17+
php: [ 7.3, 7.4, 8.0 ]
18+
tools: [ "composer:v1", "composer:v2" ]
19+
phar-readonly: [ true, false ]
3620

3721
steps:
3822
- uses: actions/checkout@v2
39-
with:
40-
fetch-depth: ${{ matrix.git-fetch-depth }}
4123

4224
- name: Setup PHP
4325
uses: shivammathur/setup-php@v2
4426
with:
4527
php-version: ${{ matrix.php }}
46-
ini-values: "phar.readonly=0"
28+
ini-values: phar.readonly=0
4729
tools: ${{ matrix.tools }}
48-
coverage: ${{ matrix.coverage }}
30+
coverage: none
4931
extensions: ctype, iconv, xml
5032

5133
- name: Get composer cache directory
@@ -71,29 +53,160 @@ jobs:
7153
- name: validate box config
7254
run: bin/box validate
7355

74-
- name: Run tests (coverage)
75-
if: matrix.coverage == 'pcov'
76-
run: make tm
77-
7856
- name: Run tests (phar readonly)
7957
if: matrix.phar-readonly == true
8058
run: make tu_box_phar_readonly
8159

8260
- name: Run tests
83-
if: matrix.coverage != 'pcov' && matrix.phar-readonly != true
84-
run: make test
61+
if: matrix.phar-readonly == false
62+
run: make tu
63+
64+
coverage:
65+
runs-on: ubuntu-latest
66+
name: Coverage
67+
68+
steps:
69+
- uses: actions/checkout@v2
70+
71+
- name: Setup PHP
72+
uses: shivammathur/setup-php@v2
73+
with:
74+
php-version: 7.4
75+
ini-values: phar.readonly=0
76+
tools: composer:v2
77+
coverage: pcov
78+
extensions: ctype, iconv, xml
79+
80+
- name: Get composer cache directory
81+
id: composercache
82+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
83+
84+
- name: Cache composer dependencies
85+
uses: actions/cache@v2
86+
with:
87+
path: ${{ steps.composercache.outputs.dir }}
88+
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
89+
restore-keys: |
90+
composer-${{ runner.os }}-${{ matrix.php }}-
91+
composer-${{ runner.os }}-
92+
composer-
93+
94+
- name: Install dependencies
95+
run: composer install --no-interaction --no-progress --prefer-dist
96+
97+
- name: Install requirement-checker dependencies
98+
run: composer install --no-interaction --no-progress --prefer-dist --working-dir requirement-checker
99+
100+
- name: Run tests (coverage)
101+
run: make tm
102+
103+
e2e-tests:
104+
runs-on: ubuntu-latest
105+
name: "e2e-Tests: ${{ matrix.e2e }} - ${{ matrix.php }} - ${{ matrix.tools }}"
106+
strategy:
107+
fail-fast: false
108+
matrix:
109+
e2e:
110+
- 'e2e_php_settings_checker'
111+
- 'e2e_scoper_alias'
112+
- 'e2e_scoper_whitelist'
113+
- 'e2e_check_requirements'
114+
- 'e2e_symfony'
115+
- 'e2e_composer_installed_versions'
116+
php: [ '7.3', '8.0' ]
117+
tools: [ 'composer:v1', 'composer:v2' ]
118+
119+
steps:
120+
- uses: actions/checkout@v2
121+
with:
122+
fetch-depth: 0
123+
124+
- name: Setup PHP
125+
uses: shivammathur/setup-php@v2
126+
with:
127+
php-version: ${{ matrix.php }}
128+
ini-values: "phar.readonly=0"
129+
tools: ${{ matrix.tools }}
130+
coverage: pcov
131+
132+
- name: Get composer cache directory
133+
id: composercache
134+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
135+
136+
- name: Cache composer dependencies
137+
uses: actions/cache@v2
138+
with:
139+
path: ${{ steps.composercache.outputs.dir }}
140+
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
141+
restore-keys: |
142+
composer-${{ runner.os }}-${{ matrix.php }}-
143+
composer-${{ runner.os }}-
144+
composer-
145+
146+
- name: Install dependencies
147+
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist
148+
149+
- name: Install requirement-checker dependencies
150+
run: composer install --no-interaction --no-progress --prefer-dist --working-dir requirement-checker
151+
152+
- name: Run e2e ${{ matrix.e2e }}
153+
run: make ${{ matrix.e2e }}
154+
155+
build-phar:
156+
runs-on: ubuntu-latest
157+
name: Build PHAR
158+
159+
steps:
160+
- uses: actions/checkout@v2
161+
with:
162+
fetch-depth: 0
163+
164+
- name: Setup PHP
165+
uses: shivammathur/setup-php@v2
166+
with:
167+
php-version: 7.3
168+
ini-values: phar.readonly=0
169+
tools: composer:v2
170+
coverage: none
171+
172+
- name: Get composer cache directory
173+
id: composercache
174+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
175+
176+
- name: Cache composer dependencies
177+
uses: actions/cache@v2
178+
with:
179+
path: ${{ steps.composercache.outputs.dir }}
180+
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
181+
restore-keys: |
182+
composer-${{ runner.os }}-${{ matrix.php }}-
183+
composer-${{ runner.os }}-
184+
composer-
185+
186+
- name: Install dependencies
187+
run: composer install --no-interaction --no-progress --prefer-dist
188+
189+
- name: Install requirement-checker dependencies
190+
run: composer install --no-interaction --no-progress --prefer-dist --working-dir requirement-checker
191+
192+
- name: Build PHAR
193+
run: make compile
85194

86195
- uses: actions/upload-artifact@v1
87-
name: Publish the PHAR
88-
if: matrix.publish-phar == true
196+
name: Upload the PHAR artifact
89197
with:
90198
name: box.phar
91199
path: bin/box.phar
92200

201+
93202
publish-phar:
94203
runs-on: ubuntu-latest
95204
name: Publish the PHAR
96-
needs: tests
205+
needs:
206+
- unit-tests
207+
- coverage
208+
- e2e-tests
209+
- build-phar
97210
if: github.event_name == 'release'
98211
steps:
99212
- uses: actions/download-artifact@v1

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ tc: bin/phpunit
8181
INFECTION=vendor-bin/infection/vendor/bin/infection
8282
tm: ## Runs Infection
8383
tm: $(TU_BOX_DEPS) $(INFECTION)
84-
$(PHPNOGC) $(INFECTION) --only-covered
84+
$(PHPNOGC) $(INFECTION) --threads=$(shell nproc || sysctl -n hw.ncpu || 1) --only-covered
8585

8686
.PHONY: e2e
8787
e2e: ## Runs all the end-to-end tests

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"minimum-stability": "dev",
4242
"prefer-stable": true,
4343
"require": {
44-
"php": "^7.3",
44+
"php": "^7.3 || ^8.0",
4545
"ext-phar": "*",
4646
"composer-plugin-api": "^1.0 || ^2.0",
4747
"amphp/parallel-functions": "^0.1.3",

0 commit comments

Comments
 (0)