-
Notifications
You must be signed in to change notification settings - Fork 502
154 lines (124 loc) · 5.26 KB
/
test.yml
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
name: Test
on:
push:
branches:
- stable
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
#### TEST STAGE ####
test:
runs-on: ubuntu-latest
strategy:
# Keys:
# - coverage: Whether to run the tests with code coverage.
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.5']
coverage: [false]
include:
# Run code coverage on low/high PHP.
- php: '5.6'
coverage: true
- php: '8.4'
coverage: true
name: "Test: PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.php == '8.5' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On, log_errors_max_len=0
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
tools: cs2pr
# At least one test needs a non-en_US locale to be available, so make sure it is.
- name: Install locales
run: |
sudo apt-get update
sudo apt-get install locales-all
- name: Show available locales
run: locale -a
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: ${{ matrix.php != '8.5' }}
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
# For PHP "nightly", we need to install with ignore platform reqs.
- name: Install Composer dependencies - with ignore platform
if: ${{ matrix.php == '8.5' }}
uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php+"
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Setup problem matcher to provide annotations for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup proxy server
run: pip3 install mitmproxy
- name: Check mitmproxy version
run: mitmdump --version
- name: Start test server
run: |
PORT=8080 vendor/bin/start.sh
echo "REQUESTS_TEST_HOST_HTTP=localhost:8080" >> $GITHUB_ENV
- name: Ping localhost domain
run: ping -c1 localhost
- name: Start proxy server
run: |
PORT=9002 tests/utils/proxy/start.sh
PORT=9003 AUTH="test:pass" tests/utils/proxy/start.sh
echo "REQUESTS_HTTP_PROXY=localhost:9002" >> $GITHUB_ENV
echo "REQUESTS_HTTP_PROXY_AUTH=localhost:9003" >> $GITHUB_ENV
echo "REQUESTS_HTTP_PROXY_AUTH_USER=test" >> $GITHUB_ENV
echo "REQUESTS_HTTP_PROXY_AUTH_PASS=pass" >> $GITHUB_ENV
- name: Ensure the HTTPS test instance on Render is spun up
run: curl -s -I https://requests-test-server.onrender.com/ > /dev/null
- name: Access localhost on port 8080
run: curl -i http://localhost:8080
- name: Access localhost on port 9002
run: curl -i http://localhost:9002
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
- name: Run the unit tests, no code coverage (PHPUnit < 10)
if: ${{ matrix.coverage == false && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer test
- name: Run the unit tests, no code coverage (PHPUnit 10+)
if: ${{ matrix.coverage == false && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer test10
- name: Run the unit tests with code coverage (PHPUnit < 10)
if: ${{ matrix.coverage == true && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer coverage -- --coverage-clover clover.xml
- name: Run the unit tests with code coverage (PHPUnit 10+)
if: ${{ matrix.coverage == true && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer coverage10 -- --coverage-clover clover.xml
- name: Stop proxy server
continue-on-error: true
run: |
PORT=9002 tests/utils/proxy/stop.sh
PORT=9003 tests/utils/proxy/stop.sh
- name: Stop test server
continue-on-error: true
run: vendor/bin/stop.sh
- name: Send coverage report to Codecov
if: ${{ success() && matrix.coverage == true }}
uses: codecov/codecov-action@v5
with:
token: "${{ secrets.CODECOV_TOKEN }}"
files: ./clover.xml
fail_ci_if_error: true
verbose: true