Skip to content

Commit

Permalink
CI: switch to GitHub Actions - step 4: introduce a quick test workflow
Browse files Browse the repository at this point in the history
Previous, the Travis all-in-one workflow would run on every push and every PR, making for a lot of redundancy in the builds.

GH Actions allows to run workflows far more selectively.

The "Test" workflow has been configured to run against all supported PHP versions for pushes (merges) to `master`, as well as for pull requests.

This commit introduces a "Quick test" workflow, which is basically the same as the full "Test" workflow (without code coverage checking).
This workflow will only run the tests against a few select PHP versions on `push` events, when the push is not to the `master` branch.

This allows for people working on feature branches to still get a quick impression of whether their branch is ready to be pulled, while conserving resources by not running the full build until the branch has been pulled.

Co-authored-by: Alain Schlesser <[email protected]>
  • Loading branch information
jrfnl and schlessera committed Apr 16, 2021
1 parent f1fdc98 commit 96c9e2f
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Quicktest

on:
push:
branches-ignore:
- master
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
#### QUICK TEST STAGE ####
# Runs the tests against select PHP versions for pushes to arbitrary branches.
quicktest:
runs-on: ubuntu-latest

strategy:
matrix:
php: ['5.5', '7.2', 'latest']

name: "Quick Test: PHP ${{ matrix.php }}"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false }}
uses: "ramsey/composer-install@v1"

# For PHP 8.0 and "nightly", we need to install with ignore platform reqs.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }}
uses: "ramsey/composer-install@v1"
with:
composer-options: --ignore-platform-reqs

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Setup proxy server
run: pip3 install mitmproxy

- name: Start test server
run: |
PORT=8080 vendor/bin/start.sh
echo "REQUESTS_TEST_HOST_HTTP=localhost:8080" >> $GITHUB_ENV
- 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 Heroku is spun up
run: curl -s -I http://requests-php-tests.herokuapp.com/ > /dev/null

- name: Check mitmproxy version
run: mitmdump --version

- name: Ping localhost domain
run: ping -c1 localhost

- 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: Show PHPUnit version
run: vendor/bin/phpunit --version

- name: Run the unit tests
run: composer test

- 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

0 comments on commit 96c9e2f

Please sign in to comment.