Skip to content

GH Actions: Bump ramsey/composer-install from 2 to 3 #720

GH Actions: Bump ramsey/composer-install from 2 to 3

GH Actions: Bump ramsey/composer-install from 2 to 3 #720

Workflow file for this run

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.4']
coverage: [false]
include:
# Run code coverage on low/high PHP.
- php: '5.6'
coverage: true
- php: '8.3'
coverage: true
name: "Test: PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.php == '8.4' }}
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.4' }}
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.4' }}
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.10'
- 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: Wandalen/wretry.action@master
with:
action: codecov/codecov-action@v3
with: |
files: ./clover.xml
fail_ci_if_error: true
verbose: true