-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (94 loc) · 2.91 KB
/
test-php.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
name: Test PHP
on:
push:
branches:
- main
pull_request:
branches:
- main
- 'feature/**'
workflow_dispatch:
inputs:
enable_terminal:
type: boolean
description: 'Enable terminal session.'
required: false
default: false
jobs:
test-php:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov
ini-values: pcov.directory=.
- name: Install dependencies
run: composer install
- name: Validate composer.json
run: |
composer --verbose validate
composer normalize --dry-run
- name: Check coding standards
run: composer lint
continue-on-error: ${{ vars.CI_LINT_IGNORE_FAILURE == '1' }}
- name: Run tests
run: composer test-coverage
continue-on-error: ${{ vars.CI_TEST_IGNORE_FAILURE == '1' }}
- name: Upload coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: ${{github.job}}-code-coverage-report-${{ matrix.php-versions }}
path: ./.coverage-html
include-hidden-files: true
if-no-files-found: error
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5
if: ${{ env.CODECOV_TOKEN != '' }}
with:
files: ./cobertura.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Setup tmate session
if: ${{ !cancelled() && github.event.inputs.enable_terminal }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5
# yamllint disable-line #;< PHP_PHAR
build-php:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- name: Install dependencies
run: composer install
- name: Build PHAR
run: composer build
- name: Test PHAR
run: ./.build/php-command.phar || exit 1
- name: Setup tmate session
if: ${{ !cancelled() && github.event.inputs.enable_terminal }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5
# yamllint disable-line #;> PHP_PHAR