Skip to content

Commit 3c3a8ef

Browse files
committed
Rework CI
- Use ramsey/composer-install action - Drop testing on multiple OSes as it's not relevant - Move timezone setting to bootstrap file - Run standalone PHPStan and Code Style checks - Bump justinrainbow/json-schema to v5.2 as it supports PHP 8.0 - Conflict with symfony/yaml `3.4.0 - 3.4.4 || 4.0.0 - 4.4.17 || 5.0.0 - 5.1.9 || 5.2.0` in order to prevent installing broken versions (especially this issue symfony/symfony#39521)
1 parent 41db38d commit 3c3a8ef

File tree

6 files changed

+81
-71
lines changed

6 files changed

+81
-71
lines changed

.github/workflows/code-style.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Code Style
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
code-style:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Install PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 7.1
19+
20+
- name: Check code style
21+
run: make check-style

.github/workflows/php.yml

+27-67
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP Composer
1+
name: Tests
22

33
on:
44
push:
@@ -7,35 +7,32 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build:
11-
10+
phpunit:
11+
name: Tests
12+
runs-on: ubuntu-latest
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
# os: [ubuntu-latest, macos-latest, windows-latest]
16-
os: [ubuntu-latest]
17-
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
18-
# max 4.4.16, see https://github.com/symfony/symfony/issues/39521
19-
# max 5.1.8, see https://github.com/symfony/symfony/issues/39521
20-
yaml: ['5.2.9', '5.1.11', '4.4.24', '^3.4']
16+
php:
17+
- "7.1"
18+
- "7.2"
19+
- "7.3"
20+
- "7.4"
21+
- "8.0"
22+
dependencies:
23+
- "lowest"
24+
- "highest"
25+
symfony-yaml: ['^3.4', '^4', '^5']
2126
exclude:
22-
# Symfony YAML does not run on PHP 7.1
23-
- php: '7.1'
24-
yaml: '5.1.11'
27+
# symfony/yaml v5 does not run on PHP 7.1
2528
- php: '7.1'
26-
yaml: '5.2.9'
27-
include:
28-
- php: '7.4'
29-
os: windows-latest
30-
yaml: '5.2.9'
31-
- php: '7.4'
32-
os: macos-latest
33-
yaml: '5.2.9'
29+
symfony-yaml: '^5'
30+
# symfony/yaml v3.4 is not compatible with PHP 8.0 but has no upper-bound, so it installs on it
31+
- php: '8.0'
32+
symfony-yaml: '^3.4'
3433

35-
36-
runs-on: ${{ matrix.os }}
3734
env:
38-
YAML: ${{ matrix.yaml }}
35+
SYMFONY_YAML: ${{ matrix.symfony-yaml }}
3936

4037
steps:
4138
- uses: actions/checkout@v2
@@ -44,60 +41,23 @@ jobs:
4441
uses: shivammathur/setup-php@v2
4542
with:
4643
php-version: ${{ matrix.php }}
47-
ini-values: date.timezone='UTC'
4844
coverage: pcov
4945
tools: composer:v2
5046

51-
- name: Determine composer cache directory (Linux/MacOS)
52-
if: matrix.os != 'windows-latest'
53-
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
54-
55-
- name: Determine composer cache directory (Windows)
56-
if: matrix.os == 'windows-latest'
57-
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
58-
59-
- name: Cache dependencies installed with composer
60-
uses: actions/cache@v2
61-
with:
62-
path: ${{ env.COMPOSER_CACHE_DIR }}
63-
key: php${{ matrix.php }}-os${{ matrix.os }}-yaml${{ matrix.yaml }}-composer-${{ hashFiles('**/composer.json') }}
64-
65-
66-
- name: Validate composer.json and composer.lock
67-
run: composer validate --ansi
68-
69-
- name: Install dependencies (Linux/MacOS)
70-
if: matrix.os != 'windows-latest'
47+
- name: Require specific symfony/yaml version
7148
run: |
72-
make install
73-
composer require symfony/yaml:"${YAML}" --prefer-dist --no-interaction --ansi
49+
composer require symfony/yaml:"${SYMFONY_YAML}" --prefer-dist --no-interaction --ansi --no-install
7450
75-
- name: Install dependencies (Windows)
76-
if: matrix.os == 'windows-latest'
77-
run: |
78-
composer install --prefer-dist --no-interaction --no-progress --ansi
79-
composer require symfony/yaml:5.1.8 --prefer-dist --no-interaction --ansi
51+
- name: "Install dependencies with Composer"
52+
uses: "ramsey/composer-install@v2"
53+
with:
54+
dependency-versions: "${{ matrix.dependencies }}"
8055

8156
- name: Validate test data
82-
if: matrix.os == 'ubuntu-latest'
8357
run: make lint
8458

85-
- name: PHP Stan analysis
86-
if: matrix.os == 'ubuntu-latest'
87-
run: make stan
88-
89-
- name: PHPUnit tests (Linux/MacOS)
90-
if: matrix.os != 'windows-latest'
59+
- name: PHPUnit tests
9160
run: make test
9261

93-
- name: PHPUnit tests (Windows)
94-
if: matrix.os == 'windows-latest'
95-
run: vendor/bin/phpunit --colors=always
96-
97-
- name: Check code style
98-
if: matrix.os == 'ubuntu-latest'
99-
run: make check-style
100-
10162
- name: Code coverage
102-
if: matrix.os == 'ubuntu-latest'
10363
run: make coverage

.github/workflows/phpstan.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
phpstan:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Install PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: "7.1"
19+
tools: composer:v2
20+
21+
- name: "Install dependencies with Composer"
22+
uses: "ramsey/composer-install@v2"
23+
24+
- name: PHPStan analysis
25+
run: make stan

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test:
2525
php $(PHPARGS) $(XPHPARGS) bin/php-openapi validate tests/spec/data/recursion.json
2626
php $(PHPARGS) $(XPHPARGS) bin/php-openapi validate tests/spec/data/recursion2.yaml
2727

28-
lint:
28+
lint: install
2929
php $(PHPARGS) $(XPHPARGS) bin/php-openapi validate tests/spec/data/reference/playlist.json
3030
php $(PHPARGS) $(XPHPARGS) bin/php-openapi validate tests/spec/data/recursion.json
3131
php $(PHPARGS) $(XPHPARGS) bin/php-openapi validate tests/spec/data/recursion2.yaml

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@
2020
"require": {
2121
"php": ">=7.1.0",
2222
"ext-json": "*",
23-
"symfony/yaml": "^3.4 | ^4.0 | ^5.0",
24-
"justinrainbow/json-schema": "^5.0"
23+
"symfony/yaml": "^3.4 || ^4 || ^5",
24+
"justinrainbow/json-schema": "^5.2"
2525
},
2626
"require-dev": {
2727
"cebe/indent": "*",
2828
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4",
29-
3029
"oai/openapi-specification": "3.0.3",
3130
"mermade/openapi3-examples": "1.0.0",
3231
"apis-guru/openapi-directory": "1.0.0",
3332
"nexmo/api-specification": "1.0.0",
3433
"phpstan/phpstan": "^0.12.0"
3534
},
35+
"conflict": {
36+
"symfony/yaml": "3.4.0 - 3.4.4 || 4.0.0 - 4.4.17 || 5.0.0 - 5.1.9 || 5.2.0"
37+
},
3638
"autoload": {
3739
"psr-4": {
3840
"cebe\\openapi\\": "src/"

tests/bootstrap.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
}
1010

1111
require __DIR__ . '/../vendor/autoload.php';
12+
13+
date_default_timezone_set('UTC');

0 commit comments

Comments
 (0)