Repository navigation
147 lines (126 loc) · 4.98 KB
/
Copy pathphp-integration-tests.yml
File metadata and controls
147 lines (126 loc) · 4.98 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
name: PHP integration tests
# Runs the PHP client tests for PRs to master that touch PHP code, tests, examples or documentation, and on
# manual dispatch from any branch.
on:
pull_request:
branches: [master]
paths:
- '**/*.php'
- 'composer.json'
- 'composer.lock'
- '.php-cs-fixer.dist.php'
- 'phpstan.neon.dist'
- 'phpunit.xml.dist'
# The "Test examples" step checks the documentation snippets.
- 'docs/**'
- 'README.md'
- '.github/workflows/php-integration-tests.yml'
workflow_dispatch:
# One run per ref at a time, since the runs share the test account.
concurrency:
group: php-integration-${{ github.ref }}
cancel-in-progress: true
jobs:
# Unit tests with the PECL brotli and zstd extensions, so their real codec tests run instead of skipping.
# The `test` job has neither, which covers the gzip fallback. Needs no API token.
unit-codecs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.4.0
- name: Set up PHP (with brotli and zstd)
uses: shivammathur/setup-php@2.40.0
with:
php-version: '8.1'
extensions: mbstring, json, curl, zlib, brotli, zstd
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Fail if a codec extension is missing
run: |
if ! php -r "exit(extension_loaded('brotli') && extension_loaded('zstd') ? 0 : 1);"; then
echo "::error::The brotli or zstd extension failed to load; the real codec tests would skip."
exit 1
fi
- name: Unit tests (brotli and zstd)
run: vendor/bin/phpunit --testsuite unit
# The zstd integration tests, with the PECL zstd extension that the `test` job lacks. They skip themselves
# without the extension or the token, so both are checked first.
integration-zstd:
runs-on: ubuntu-latest
# APIFY_TOKEN is an environment secret of the `tests` environment.
environment: tests
steps:
- name: Checkout
uses: actions/checkout@v4.4.0
- name: Set up PHP (with zstd)
uses: shivammathur/setup-php@2.40.0
with:
php-version: '8.1'
extensions: mbstring, json, curl, zlib, zstd
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Require the zstd extension and APIFY_TOKEN
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: |
if ! php -r "exit(extension_loaded('zstd') ? 0 : 1);"; then
echo "::error::The zstd extension failed to load; the zstd integration tests would skip."
exit 1
fi
if [ -z "${APIFY_TOKEN}" ]; then
echo "::error::APIFY_TOKEN secret (tests environment) is empty or missing; the zstd integration tests would skip."
exit 1
fi
- name: Integration tests (zstd)
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: vendor/bin/phpunit --testsuite integration --filter ZstdCompressionIntegrationTest
test:
runs-on: ubuntu-latest
# APIFY_TOKEN is an environment secret of the `tests` environment.
environment: tests
steps:
- name: Checkout
uses: actions/checkout@v4.4.0
- name: Set up PHP
uses: shivammathur/setup-php@2.40.0
with:
php-version: '8.1'
# intl is optional, and loaded so that the punycode test runs.
extensions: mbstring, json, curl, zlib, intl
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
# Formatting (PSR-12, php-cs-fixer).
- name: Check formatting (php-cs-fixer)
run: composer lint
# Static analysis.
- name: Static analysis (PHPStan)
run: composer stan
# Offline unit tests with a mock transport.
- name: Unit tests
run: vendor/bin/phpunit --testsuite unit
# The integration tests skip themselves without APIFY_TOKEN, so fail here instead of passing silently.
- name: Require APIFY_TOKEN secret
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: |
if [ -z "${APIFY_TOKEN}" ]; then
echo "::error::APIFY_TOKEN secret (tests environment) is empty or missing; integration tests would not run against the API."
exit 1
fi
- name: Integration tests
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: vendor/bin/phpunit --testsuite integration
# Runs the documentation examples against the live API (ExamplesTest) and lints every PHP snippet
# of the documentation (DocSnippetsTest).
- name: Test examples
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: vendor/bin/phpunit --testsuite examples