-
Notifications
You must be signed in to change notification settings - Fork 70
120 lines (102 loc) · 4.18 KB
/
ci.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: CI
on:
workflow_dispatch: # Can manually run from any branch
push:
branches:
- trunk
pull_request:
jobs:
php-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
php: [ '8.3', '8.2', '8.1' ]
os: [ 'ubuntu-latest' ]
include:
- php: '8.0'
os: 'ubuntu-20.04'
- php: '7.4'
os: 'ubuntu-20.04'
fail-fast: false
env:
COVERAGE_CACHE_PATH: phpunit-coverage-cache
PHP_VERSION: ${{ matrix.php }}
steps:
- uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2.4.2
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # v2.28.0
with:
php-version: ${{ matrix.php }}
coverage: pcov
- name: Get Composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # v2.1.7
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Restore phpunit coverage cache
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # v2.1.7
with:
path: ${{ env.COVERAGE_CACHE_PATH }}
key: ${{ runner.os }}-coverage-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-coverage-${{ github.ref }}-
${{ runner.os }}-coverage-
- name: Execute tests with PHPUnit and output code coverage report
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
# Generate coverage file, so it can be uploaded later if we choose.
# Otherwise, current coverage can be viewed in the action output.
# Tests should be run randomly to catch any test dependency issue.
run: |
vendor/bin/phpunit --order-by="random" --coverage-cache="$COVERAGE_CACHE_PATH" --coverage-clover=./clover.xml --coverage-text
- name: Upload test coverage results to Coveralls
if: ${{ env.PHP_VERSION == '8.1' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
vendor/bin/php-coveralls --coverage_clover="./clover.xml" --json_path="./coveralls-upload.json" -v
php-compatibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-req php
- name: Run PHP Code Sniffer using the PHPCompatibility standard
run: vendor/bin/phpcs
php-static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: |
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run phpstan
run: vendor/bin/phpstan