From 96c9e2f97165921ee1650654b771556e560de1bc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 22 Mar 2021 01:27:10 +0100 Subject: [PATCH] CI: switch to GitHub Actions - step 4: introduce a quick test workflow 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 --- .github/workflows/quicktest.yml | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/quicktest.yml diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml new file mode 100644 index 000000000..2bad2f8f3 --- /dev/null +++ b/.github/workflows/quicktest.yml @@ -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