Skip to content

Merge pull request #406 from aik099/use-docker-compose #257

Merge pull request #406 from aik099/use-docker-compose

Merge pull request #406 from aik099/use-docker-compose #257

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
DRIVER_URL: "http://localhost:4444/wd/hub"
defaults:
run:
shell: bash
jobs:
check_composer:
name: Check composer.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.2'
- run: composer validate --strict --no-check-lock
static_analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.2'
- name: Install dependencies
run: composer update --ansi --no-progress --prefer-dist --no-interaction
- run: vendor/bin/phpstan analyze
tests:
name: "Tests (PHP ${{ matrix.php }}, Selenium ${{ matrix.selenium_version }})${{ matrix.with_coverage == true && ' with coverage' || ''}}"
runs-on: ubuntu-latest
strategy:
matrix:
selenium_version: [ '2.53.1' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
with_coverage: [ false ]
include:
- selenium_version: '2.53.1'
php: '8.3'
with_coverage: true
- selenium_version: '3.141.59'
php: '8.3'
with_coverage: true
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "xdebug"
php-version: "${{ matrix.php }}"
tools: composer
# PHP 7.1 development web server segfaults if timezone not set.
ini-values: date.timezone=Europe/Paris, error_reporting=-1, display_errors=On
- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist
- name: Setup Mink test server
env:
MINK_HOST: 0.0.0.0:8002
run: |
mkdir ./logs
./vendor/bin/mink-test-server &> ./logs/mink-test-server.log &
- name: Start Selenium
run: |
SELENIUM_IMAGE=selenium/standalone-firefox:${{ matrix.selenium_version }} docker compose up --wait
- name: Wait for browser & PHP to start
run: |
curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:4444/wd/hub/status
curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:8002/index.html
- name: Run tests with Coverage
if: "${{ matrix.with_coverage == true }}"
env:
SELENIUM_VERSION: ${{ matrix.selenium_version }}
DRIVER_URL: http://localhost:4444/wd/hub
WEB_FIXTURES_HOST: http://host.docker.internal:8002
WEB_FIXTURES_BROWSER: firefox
DRIVER_MACHINE_BASE_PATH: /fixtures/
run: |
vendor/bin/phpunit -v --coverage-clover=coverage.xml --log-junit junit.xml
- name: Run tests without Coverage
if: "${{ matrix.with_coverage == false }}"
env:
SELENIUM_VERSION: ${{ matrix.selenium_version }}
DRIVER_URL: http://localhost:4444/wd/hub
WEB_FIXTURES_HOST: http://host.docker.internal:8002
WEB_FIXTURES_BROWSER: firefox
DRIVER_MACHINE_BASE_PATH: /fixtures/
run: |
vendor/bin/phpunit -v
- name: Upload coverage to Codecov
if: ${{ matrix.with_coverage == true && !cancelled() }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
- name: Upload test results to Codecov
if: ${{ matrix.with_coverage == true && !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Extract docker logs
if: ${{ failure() }}
run: |
docker compose logs --no-color &> ./logs/selenium.log
- name: Archive logs artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: logs_php-${{ matrix.php }}_selenium-${{ matrix.selenium_version }}_firefox
path: |
logs