Repository navigation
87 lines (79 loc) · 3.44 KB
/
Copy pathci.yml
File metadata and controls
87 lines (79 loc) · 3.44 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
name: tests
# Tests the package AS PUBLISHED: a fresh dependency resolution from the
# manifest Composer actually reads, which is a different question from the
# monorepo's php-sensor-ci.yml and the reason this exists at all.
#
# NOTE ON EDITING THIS REPO. Content here (src, tests, composer.json, README) is
# synced from php-sensor/ in the application monorepo by release.sh, and edits to
# it are lost on the next release. This workflow is not part of that synced set:
# it is infrastructure belonging to this repo, so it is edited here.
#
# push only. Commits arrive from release.sh, never from a pull request, so the
# pull_request trigger could not fire and only risked double-billing the org's
# shared Actions minutes if that ever changed.
on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# The supported PHP range has ONE definition, composer.json, and this job
# reads it. It used to be a hardcoded ['7.4','8.0','8.2','8.4'] alongside a
# manifest that claimed ">=7.4" while the code used readonly promoted
# properties (8.1+). Both were wrong, they were wrong together, and this
# workflow said so on every run: 7.4 and 8.0 failed with ParseError from the
# day the package was first published. Nobody read the red, and v0.1.0 shipped
# to Packagist telling users it ran on 7.4.
#
# Deriving the floor means the matrix cannot drift from what we advertise. If
# the floor rises, the job testing it rises with it, in one edit.
matrix:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.read.outputs.versions }}
steps:
- uses: actions/checkout@v4
- id: read
run: |
FLOOR=$(grep -oE '"php": *">=[0-9]+\.[0-9]+"' composer.json \
| grep -oE '[0-9]+\.[0-9]+')
if [ -z "$FLOOR" ]; then
echo "Could not read a >=X.Y php constraint from composer.json." >&2
echo "If the constraint style changed, update this parser: a silent" >&2
echo "empty matrix would report success while testing nothing." >&2
exit 1
fi
# The floor, because that is the version this package has actually
# broken on, and a current release to catch the opposite drift.
echo "versions=[\"$FLOOR\", \"8.4\"]" >> "$GITHUB_OUTPUT"
echo "Testing floor $FLOOR and 8.4"
phpunit:
needs: matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ${{ fromJSON(needs.matrix.outputs.versions) }}
name: PHP ${{ matrix.php }}
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, json
coverage: none
- run: composer validate --strict --no-check-lock
- run: composer install --prefer-dist --no-interaction
# phpunit only loads the classes a test touches, so a file that cannot be
# parsed on the floor could still pass. bootstrap.php is the
# auto_prepend_file entry point and has no unit test, which makes it both
# the least likely to be caught and the most costly to get wrong: a parse
# error there fails every PHP request on the host.
- name: Syntax check every shipped file
run: find src bootstrap.php -name '*.php' -print0 | xargs -0 -n1 php -l
- run: vendor/bin/phpunit