-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Travis CI with GitHub Actions workflows #447
Closed
schlessera
wants to merge
26
commits into
add/phpunit-polyfills-library
from
add/github-actions-testing
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3b4192b
Add code quality checks via GHA
schlessera 71523d2
Simplify CS workflow
schlessera 4318db1
Add basic unit testing workflow
schlessera f599b11
Avoid resetting Composer root version
schlessera a3ba0e7
Add missing TestCase file
schlessera b1c0eea
Start and stop proxy server
schlessera b0763cc
Install pip requirements first before using pip
schlessera 44115c1
Install pip wheel
schlessera 3417253
Avoid forcing an old version of the proxy server
schlessera 9d12893
Try to use apt to install mitmproxy
schlessera 73244c7
Use GITHUB_ENV to pass env variables between steps
schlessera 80f1c26
Remove left-over export keyword
schlessera a14d410
Improve quotes
schlessera 3dfb326
Use IP instead of localhost
schlessera 0001052
Revert "Use IP instead of localhost"
schlessera c0a1011
Use pip to install mitmproxy
schlessera ca37850
Ping proxy domain
schlessera e1348f9
Use --version instead of -v for mitmproxy check
schlessera a10ea71
Add 8080 to env checks
schlessera e83ad7d
Fix proxy scripts to work with newest mitmproxy release
schlessera 3fa16bc
Show header on curl requests
schlessera dd776cc
Add edge case TODO for fsockopen invalid auth test
schlessera 1ba6d61
Test from PHP 5.3 onwards
schlessera 2bdfa08
Terminate proxy servers properly
schlessera 793b2ca
Bump testing to PHP 5.5+
schlessera 4b48645
Also run GHA workflows on push to master
schlessera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Code Quality Checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
|
||
lint: #----------------------------------------------------------------------- | ||
name: Lint PHP files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up PHP envirnoment | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
tools: cs2pr | ||
|
||
- name: Get Composer cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Use Composer cache | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps['composer-cache'].outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run Linter | ||
run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr | ||
|
||
phpcs: #---------------------------------------------------------------------- | ||
name: PHPCS | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up PHP envirnoment | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
tools: cs2pr | ||
|
||
- name: Get Composer cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Use Composer cache | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run PHPCS | ||
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Testing | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
|
||
unit: | ||
name: Unit test / PHP ${{ matrix.php }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up PHP environment | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '${{ matrix.php }}' | ||
coverage: none | ||
tools: composer,cs2pr | ||
|
||
- name: Get Composer cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Use Composer cache | ||
uses: actions/cache@master | ||
with: | ||
path: ${{ steps['composer-cache'].outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- 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=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: Run PHPUnit | ||
run: composer test | ||
|
||
- name: Stop proxy server | ||
run: | | ||
PORT=9002 tests/utils/proxy/stop.sh | ||
PORT=9003 tests/utils/proxy/stop.sh | ||
|
||
- name: Stop test server | ||
run: vendor/bin/stop.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
class RequestsTest_TestCase extends \Yoast\PHPUnitPolyfills\TestCases\TestCase { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROXYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
PORT=${PORT:-9000} | ||
|
||
PROXYBIN=${PROXYBIN:-"$(which mitmdump)"} | ||
ARGS="-s '$PROXYDIR/proxy.py' -p $PORT" | ||
if [[ ! -z "$AUTH" ]]; then | ||
ARGS="$ARGS --singleuser=$AUTH" | ||
ARGS="$ARGS --proxyauth $AUTH" | ||
fi | ||
PIDFILE="$PROXYDIR/proxy.pid" | ||
PIDFILE="$PROXYDIR/proxy-$PORT.pid" | ||
|
||
set -x | ||
|
||
start-stop-daemon --verbose --start --background --pidfile $PIDFILE --make-pidfile --exec $PROXYBIN -- $ARGS | ||
|
||
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --exec $PROXYBIN -- $ARGS | ||
ps -p $(cat $PIDFILE) -u | ||
sleep 2 | ||
ps -p $(cat $PIDFILE) -u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROXYDIR="$PWD/$(dirname $0)" | ||
PORT=${PORT:-9000} | ||
|
||
PIDFILE="$PROXYDIR/proxy-$PORT.pid" | ||
|
||
PIDFILE="$PROXYDIR/proxy.pid" | ||
set -x | ||
|
||
start-stop-daemon --stop --pidfile $PIDFILE --make-pidfile && rm $PROXYDIR/proxy.pid | ||
start-stop-daemon --verbose --stop --pidfile $PIDFILE --remove-pidfile |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(here and everywhere else)