-
Notifications
You must be signed in to change notification settings - Fork 33
158 lines (134 loc) · 5.45 KB
/
Copy pathphp.yml
File metadata and controls
158 lines (134 loc) · 5.45 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
name: "CI"
on:
pull_request:
push:
branches:
- main
paths:
- "**.php"
- "bin/posthog"
- "composer.json"
- "composer.lock"
- "phpcs.xml"
- "phpunit.xml"
- "api/public-api.json"
- "scripts/**"
- ".github/workflows/php.yml"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
detect-markdown-only:
uses: PostHog/.github/.github/workflows/detect-markdown-only.yml@ec25337d9fae0100622cbfea1bd5bd88284ac10b
permissions:
pull-requests: read
composer-validate:
needs: detect-markdown-only
runs-on: ubuntu-latest
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
- name: Set up PHP
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
tools: composer
- name: Validate composer files
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: composer validate --no-check-version --strict
public-api:
needs: detect-markdown-only
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up PHP 8.4
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
tools: composer
- name: Install Dependencies
run: composer install --prefer-dist --no-progress
- name: Check public API snapshot
run: composer api:check
phpunit:
needs: detect-markdown-only
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: [8.2, 8.3, 8.4, 8.5]
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
- name: Set up PHP ${{ matrix.php-version }}
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ matrix.php-version }}
tools: composer, phpunit
- name: Install Dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: composer install --prefer-dist --no-progress
- name: Run PHPUnit Tests
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: ./vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml
coverage:
runs-on: ubuntu-latest
needs:
- detect-markdown-only
- phpunit
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up PHP 8.4
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
extensions: xdebug
tools: composer, phpunit
- name: Install Dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPUnit Coverage
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit --bootstrap vendor/autoload.php --configuration phpunit.xml --coverage-text
phpcs:
needs: detect-markdown-only
runs-on: ubuntu-latest
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
with:
fetch-depth: 0 # important!
- name: Set up PHP 8.4
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: 8.4
tools: composer
- name: Install Dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: composer install --prefer-dist --no-progress
- name: Check PHP formatting
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: |
./vendor/bin/phpcbf --standard=phpcs.xml --no-colors --runtime-set ignore_non_auto_fixable_on_exit 1
git diff --exit-code -- lib test
- uses: tinovyatkin/action-php-codesniffer@0043b33b3629611c37e8bc7ee8a4e061dc9a7ea2 # v1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
with:
files: "**.php" # you may customize glob as needed
phpcs_path: ./vendor/bin/phpcs
standard: phpcs.xml
scope: "file"