Repository navigation
209 lines (176 loc) · 7.61 KB
/
Copy pathci.yml
File metadata and controls
209 lines (176 loc) · 7.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: CI
on:
push:
branches: [master, main]
pull_request:
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
# ──────────────────────────────────────────────────────────────────────────
# PHP version matrix — NARROWED, restore tracked by LIBRARIES-3169.
#
# The intended matrix is 8.1 / 8.2 / 8.3 / 8.4, matching the "^7.4 || ^8.0"
# that composer.json declares. It ran on shivammathur/setup-php, which the
# org Actions policy does not admit (GitHub-owned actions only), so every
# workflow using it failed at startup with no check reported.
#
# The runner image ships exactly one PHP, so CI can only prove that one.
# PHP_MATRIX below is the single source of truth for all three matrix jobs:
# restoring breadth is a one-line change here once LIBRARIES-3169 lands a
# way to install other versions. PHP_PRIMARY is the leg that also produces
# coverage; it must stay a member of PHP_MATRIX.
#
# Do NOT widen PHP_MATRIX on its own — .github/actions/setup-php verifies the
# runtime and fails loudly on a version the image lacks, by design.
# ──────────────────────────────────────────────────────────────────────────
PHP_MATRIX: '["8.3"]'
PHP_PRIMARY: "8.3"
jobs:
# Resolves the env-level matrix into an output, because `strategy.matrix`
# cannot read `env` directly.
config:
name: Resolve matrix
# Bare ubuntu-latest gets no runner on same-repo PRs in this org; only the
# fork path may use it.
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }}
outputs:
php-versions: ${{ steps.set.outputs.php-versions }}
php-primary: ${{ steps.set.outputs.php-primary }}
steps:
- id: set
shell: bash
run: |
set -euo pipefail
echo "php-versions=${PHP_MATRIX}" >> "${GITHUB_OUTPUT}"
echo "php-primary=${PHP_PRIMARY}" >> "${GITHUB_OUTPUT}"
coding-standard:
name: Coding Standards
needs: [config]
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up PHP
uses: ./.github/actions/setup-php
with:
php-version: ${{ needs.config.outputs.php-primary }}
coverage: none
- name: Configure Artifactory
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main
with:
ecosystem: php
provider-name: github-actions-segmentio
- name: Install Composer dependencies
run: composer install --no-scripts --no-interaction --prefer-dist
# cs2pr came from setup-php's `tools:` and annotated PRs inline. Without
# it the report is only readable in the log and the artifact below —
# see LIBRARIES-3169.
- name: Check coding standards
continue-on-error: true
run: ./vendor/bin/phpcs -s --report-full --report-checkstyle=./phpcs-report.xml
- name: Upload PHPCS report
if: ${{ always() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: phpcs-report
path: phpcs-report.xml
if-no-files-found: warn
lint:
name: "Lint: PHP ${{ matrix.php }}"
needs: [config]
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }}
strategy:
fail-fast: false
matrix:
php: ${{ fromJSON(needs.config.outputs.php-versions) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up PHP
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Configure Artifactory
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main
with:
ecosystem: php
provider-name: github-actions-segmentio
- name: Install Composer dependencies
run: composer install --no-scripts --no-interaction --prefer-dist
- name: Lint against parse errors
run: composer lint
test:
name: "Test: PHP ${{ matrix.php }}"
needs: [config, coding-standard, lint]
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }}
strategy:
fail-fast: false
matrix:
php: ${{ fromJSON(needs.config.outputs.php-versions) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up PHP
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-values: error_reporting=E_ALL, display_errors=On
extensions: curl, json, mbstring
- name: Configure Artifactory
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main
with:
ecosystem: php
provider-name: github-actions-segmentio
- name: Install Composer dependencies
run: composer install --no-scripts --no-interaction --prefer-dist
- name: Run tests
run: ./vendor/bin/phpunit --no-coverage
- name: Run tests with coverage
if: ${{ matrix.php == needs.config.outputs.php-primary }}
run: ./vendor/bin/phpunit
# codecov/codecov-action is not allow-listed either, so coverage is kept
# as an artifact rather than uploaded — see LIBRARIES-3169.
- name: Upload coverage report
if: ${{ success() && matrix.php == needs.config.outputs.php-primary }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-clover
path: build/logs/clover.xml
if-no-files-found: error
build-verification:
name: Build Verification
needs: [config, test]
runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up PHP
uses: ./.github/actions/setup-php
with:
php-version: ${{ needs.config.outputs.php-primary }}
coverage: none
- name: Configure Artifactory
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: twilio/sdk-actions/artifactory-oidc@c94e420aa64ea686ff25bb03d4c66cdaf8e523e4 # main
with:
ecosystem: php
provider-name: github-actions-segmentio
- name: Install Composer dependencies (production)
run: composer install --no-scripts --no-interaction --prefer-dist --no-dev --optimize-autoloader
- name: Verify autoload
run: php -r "require 'vendor/autoload.php'; echo 'Autoload OK' . PHP_EOL;"
- name: Verify package structure
run: |
# Ensure required files exist for Packagist
test -f composer.json
test -f LICENSE.md
test -d lib
echo "Package structure verified"