-
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (145 loc) · 6.34 KB
/
tests.yml
File metadata and controls
165 lines (145 loc) · 6.34 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Run PHPUnit Tests
on:
workflow_call:
inputs:
min-coverage:
description: Minimum line coverage percentage enforced by dev-tools tests.
required: false
type: number
default: 80
run-dependencies-check:
description: Whether to run the dependency health check during CI.
required: false
type: boolean
default: true
max-outdated:
description: Maximum number of outdated packages allowed by the dependencies command.
required: false
type: number
default: 5
workflow_dispatch:
inputs:
min-coverage:
description: Minimum line coverage percentage enforced by dev-tools tests.
required: false
type: number
default: 80
run-dependencies-check:
description: Whether to run the dependency health check during CI.
required: false
type: boolean
default: true
max-outdated:
description: Maximum number of outdated packages allowed by the dependencies command.
required: false
type: number
default: 5
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'composer.json'
- 'composer.lock'
- '.github/actions/**'
- '.github/workflows/tests.yml'
push:
branches: [ "main" ]
permissions:
contents: read
concurrency:
group: ${{ github.event_name == 'pull_request' && format('tests-pr-{0}', github.event.pull_request.number) || format('tests-{0}', github.ref) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
resolve_php:
name: Resolve PHP Version
runs-on: ubuntu-latest
outputs:
php-version: ${{ steps.resolve.outputs.php-version }}
php-version-source: ${{ steps.resolve.outputs.php-version-source }}
test-matrix: ${{ steps.resolve.outputs.test-matrix }}
steps:
- uses: actions/checkout@v6
- name: Resolve workflow PHP version
id: resolve
uses: php-fast-forward/dev-tools/resources/resolve-php-version@main
tests:
needs: resolve_php
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.resolve_php.outputs.test-matrix) }}
env:
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
FORCE_COLOR: '1'
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: pcov, pcntl
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php-version }}-
${{ runner.os }}-composer-
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
COMPOSER_CACHE_DIR: /tmp/composer-cache
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer install --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Composer Audit
env:
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer audit
- name: Resolve minimum coverage
id: minimum-coverage
run: echo "value=${INPUT_MIN_COVERAGE:-80}" >> "$GITHUB_OUTPUT"
env:
INPUT_MIN_COVERAGE: ${{ inputs.min-coverage }}
- name: Run PHPUnit tests
env:
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer dev-tools tests -- --coverage=.dev-tools/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }}
dependency-health:
needs: resolve_php
name: Dependency Health
if: ${{ github.event_name != 'workflow_call' || inputs.run-dependencies-check }}
runs-on: ubuntu-latest
continue-on-error: true
env:
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
FORCE_COLOR: '1'
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ needs.resolve_php.outputs.php-version }}
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-composer-${{ needs.resolve_php.outputs.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ needs.resolve_php.outputs.php-version }}-
${{ runner.os }}-composer-
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }'
COMPOSER_CACHE_DIR: /tmp/composer-cache
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer install --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Run dependency health check
env:
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || 5 }}