-
-
Notifications
You must be signed in to change notification settings - Fork 6
101 lines (89 loc) · 3.61 KB
/
ci.yml
File metadata and controls
101 lines (89 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
on:
push:
branches:
- master
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [
8.1,
8.2,
8.3,
8.4,
8.5
]
composer: [basic]
# Test against both supported nikic/php-parser major versions.
# php-parser v4 requires phpunit ^9.6 because phpunit/php-code-coverage v11+
# has a hard dependency on php-parser v5; phpunit 9 uses php-code-coverage v9
# which is compatible with both.
parser-version: [v4, v5]
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: zip
tools: composer
- name: Determine composer cache directory
id: composer-cache
run: echo "directory=$(composer config cache-dir)" >> "$GITHUB_OUTPUT"
- name: Cache composer dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.composer-cache.outputs.directory }}
# Include parser-version in the key to avoid cache poisoning between v4/v5 runs.
key: ${{ matrix.php }}-${{ matrix.parser-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ matrix.php }}-${{ matrix.parser-version }}-composer-
- name: Install dependencies
run: |
if [[ "${{ matrix.parser-version }}" == "v4" ]]; then
# php-parser v4: pin phpunit to ^9.6 because phpunit 11's php-code-coverage requires php-parser v5.
# Use --with (temporary constraint) instead of listing packages positionally: the latter is a
# partial-update and requires a lock file, which libraries do not commit. --with does a full
# resolve with the extra constraint, so it works fine without a lock file.
composer update --prefer-dist --no-interaction --with nikic/php-parser:'^4.18' --with phpunit/phpunit:'^9.6'
elif [[ "${{ matrix.composer }}" == "lowest" ]]; then
composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable
else
composer update --prefer-dist --no-interaction
fi
composer dump-autoload -o
- name: Run tests
run: |
mkdir -p build/logs
php vendor/bin/phpunit -c phpunit.xml --coverage-filter=src --coverage-clover=build/logs/clover.xml
- name: Run phpstan
if: ${{ matrix.php == '8.3' }}
run: |
php vendor/bin/phpstan analyse
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
- name: Upload coverage results to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
files: build/logs/clover.xml
- name: Archive logs artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: logs_composer-${{ matrix.composer }}_parser-${{ matrix.parser-version }}_php-${{ matrix.php }}
path: |
build/logs