Skip to content

Commit

Permalink
Merge pull request #467 from WordPress/feature/move-to-gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera authored Apr 16, 2021
2 parents 17e6afb + 44895bf commit 519ac37
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 73 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
codecov:
notify:
after_n_builds: 2

coverage:
round: nearest
# Status will be green when coverage is between 85 and 100%.
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.github/ export-ignore
bin/ export-ignore
docs/ export-ignore
examples/ export-ignore
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CS

on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
phpcs: #----------------------------------------------------------------------
name: 'PHPCS'
runs-on: ubuntu-latest

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: cs2pr

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: "ramsey/composer-install@v1"

# Check the code-style consistency of the PHP files.
- name: Check PHP code style
continue-on-error: true
run: composer checkcs -- --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
45 changes: 45 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint

on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
lint: #----------------------------------------------------------------------
runs-on: ubuntu-latest

strategy:
matrix:
# Lint against the high/low versions of each PHP major and select additional versions.
# Note: linting against PHP 5.2 , 5.3 and 5.4 is still done via Travis.
php: ['5.6', '7.0', '7.4', '8.0']
experimental: [false]

include:
- php: '8.1'
experimental: true

name: "Lint: PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.experimental }}

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

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

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies
uses: "ramsey/composer-install@v1"

- name: Lint against parse errors
run: composer lint -- --checkstyle | cs2pr
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 && matrix.php != 'latest' }}
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
144 changes: 144 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Test

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

jobs:
#### TEST STAGE ####
test:
runs-on: ubuntu-latest

strategy:
# Keys:
# - coverage: Whether to run the tests with code coverage.
# - experimental: Whether the build is "allowed to fail".
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
coverage: [false]
experimental: [false]

include:
# Run code coverage on high/low PHP.
- php: '5.5'
coverage: true
experimental: false
- php: '8.0'
coverage: true
experimental: false

# Test against PHP Nightly.
# This should be enabled once the PHPUnit version constraints have been widened.
#- php: '8.1'
# coverage: false
# experimental: true

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

continue-on-error: ${{ matrix.experimental }}

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

- name: Set coverage variable
id: set_cov
run: |
if [ ${{ matrix.coverage }} == "true" ]; then
echo '::set-output name=COV::xdebug'
else
echo '::set-output name=COV::none'
fi
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ steps.set_cov.outputs.COV }}
tools: cs2pr

# 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 && matrix.php != 'latest' }}
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 problem matcher to provide annotations for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- 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, no code coverage
if: ${{ matrix.coverage == false }}
run: composer test

- name: Run the unit tests with code coverage
if: ${{ matrix.coverage == true }}
run: vendor/bin/phpunit --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@v1
with:
files: ./clover.xml
fail_ci_if_error: true
verbose: true
Loading

0 comments on commit 519ac37

Please sign in to comment.