Skip to content

Commit f0bd193

Browse files
committed
Improve caching and tidy actions
1 parent e7c5ea8 commit f0bd193

File tree

3 files changed

+61
-65
lines changed

3 files changed

+61
-65
lines changed
Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,67 @@
1-
name: "Continuous Integration"
1+
name: Continuous Integration
22

33
on:
44
- push
55
- pull_request
66

77
env:
8-
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9-
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1"
8+
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
109

1110
jobs:
1211
tests:
13-
name: "CI"
12+
name: CI
1413

1514
runs-on: ${{ matrix.os }}
1615

1716
strategy:
1817
matrix:
1918
php-version:
20-
- "5.3"
21-
- "5.4"
22-
- "5.5"
23-
- "5.6"
24-
- "7.0"
25-
- "7.1"
26-
- "7.2"
27-
- "7.3"
28-
- "7.4"
29-
- "8.0"
30-
- "8.1"
19+
- '5.3'
20+
- '5.4'
21+
- '5.5'
22+
- '5.6'
23+
- '7.0'
24+
- '7.1'
25+
- '7.2'
26+
- '7.3'
27+
- '7.4'
28+
- '8.0'
29+
- '8.1'
3130
os: [ubuntu-latest]
3231
include:
33-
- php-version: "5.3"
32+
- php-version: '5.3'
3433
os: windows-latest
35-
- php-version: "8.0"
34+
- php-version: '8.0'
3635
os: windows-latest
3736

3837
steps:
39-
- name: "Checkout"
40-
uses: "actions/checkout@v2"
38+
- name: Checkout
39+
uses: actions/checkout@v2
4140

42-
- name: "Install PHP"
43-
uses: "shivammathur/setup-php@v2"
41+
- name: Install PHP
42+
uses: shivammathur/setup-php@v2
4443
with:
45-
coverage: "none"
46-
php-version: "${{ matrix.php-version }}"
44+
coverage: none
45+
php-version: ${{ matrix.php-version }}
46+
47+
- name: Remove PHPStan if unsupported
48+
# Do this first to diffentiate cache keys
49+
if: ${{ matrix.php-version < '7.1' }}
50+
run: composer remove phpstan/phpstan --dev --no-update
4751

4852
- name: Get composer cache directory
4953
id: composercache
5054
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
5155

52-
- name: Cache dependencies
56+
- name: Restore cached dependencies
5357
uses: actions/cache@v2
5458
with:
5559
path: ${{ steps.composercache.outputs.dir }}
56-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
57-
restore-keys: ${{ runner.os }}-composer-
60+
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
61+
restore-keys: php-${{ matrix.php-version }}-composer-
5862

59-
- name: "Install latest dependencies"
60-
run: |
61-
# Remove PHPStan as it requires a newer PHP
62-
composer remove phpstan/phpstan --dev --no-update
63-
composer update ${{ env.COMPOSER_FLAGS }}
63+
- name: Install latest dependencies
64+
run: composer update ${{ env.COMPOSER_FLAGS }}
6465

65-
- name: "Run tests"
66-
run: "vendor/bin/simple-phpunit --verbose"
66+
- name: Run tests
67+
run: vendor/bin/simple-phpunit --verbose

.github/workflows/lint.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
name: "PHP Lint"
1+
name: PHP Lint
22

33
on:
44
- push
55
- pull_request
66

77
jobs:
88
tests:
9-
name: "Lint"
9+
name: Lint
1010

1111
runs-on: ubuntu-latest
1212

1313
strategy:
1414
matrix:
1515
php-version:
16-
- "5.3"
17-
- "8.0"
16+
- '5.3'
17+
- '8.0'
1818

1919
steps:
20-
- name: "Checkout"
21-
uses: "actions/checkout@v2"
20+
- name: Checkout
21+
uses: actions/checkout@v2
2222

23-
- name: "Install PHP"
24-
uses: "shivammathur/setup-php@v2"
23+
- name: Install PHP
24+
uses: shivammathur/setup-php@v2
2525
with:
26-
coverage: "none"
27-
php-version: "${{ matrix.php-version }}"
26+
coverage: none
27+
php-version: ${{ matrix.php-version }}
2828

29-
- name: "Lint PHP files"
29+
- name: Lint PHP files
3030
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"

.github/workflows/phpstan.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,46 @@
1-
name: "PHPStan"
1+
name: PHPStan
22

33
on:
44
- push
55
- pull_request
66

77
env:
8-
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
9-
SYMFONY_PHPUNIT_VERSION: ""
8+
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
109

1110
jobs:
1211
tests:
13-
name: "PHPStan"
12+
name: PHPStan
1413

1514
runs-on: ubuntu-latest
1615

1716
strategy:
1817
matrix:
1918
php-version:
20-
# pinned to 7.4 because we need PHPUnit 7.5 which does not support PHP 8
21-
- "7.4"
19+
- '8.0'
2220

2321
steps:
24-
- name: "Checkout"
25-
uses: "actions/checkout@v2"
22+
- name: Checkout
23+
uses: actions/checkout@v2
2624

27-
- name: "Install PHP"
28-
uses: "shivammathur/setup-php@v2"
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
2927
with:
30-
coverage: "none"
31-
php-version: "${{ matrix.php-version }}"
28+
coverage: none
29+
php-version: ${{ matrix.php-version }}
3230

3331
- name: Get composer cache directory
3432
id: composercache
3533
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3634

37-
- name: Cache dependencies
35+
- name: Restore cached dependencies
3836
uses: actions/cache@v2
3937
with:
4038
path: ${{ steps.composercache.outputs.dir }}
41-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
42-
restore-keys: ${{ runner.os }}-composer-
39+
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: php-${{ matrix.php-version }}-composer
4341

44-
- name: "Install latest dependencies"
45-
run: "composer update ${{ env.COMPOSER_FLAGS }}"
42+
- name: Install latest dependencies
43+
run: composer update ${{ env.COMPOSER_FLAGS }}
4644

4745
- name: Run PHPStan
48-
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
49-
run: |
50-
composer require --dev phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}
51-
vendor/bin/phpstan analyse
46+
run: vendor/bin/phpstan analyse

0 commit comments

Comments
 (0)