diff --git a/.github/workflows/ci-analysis.yml b/.github/workflows/ci-analysis.yml new file mode 100644 index 0000000..d12dbd8 --- /dev/null +++ b/.github/workflows/ci-analysis.yml @@ -0,0 +1,34 @@ +name: Analysis + +on: + push: + pull_request: + workflow_dispatch: + +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 --ansi + + check_code: + name: Static analysis + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + coverage: none + php-version: '8.2' + - run: composer update --ansi --no-progress --prefer-dist --no-interaction + - run: vendor/bin/phpstan analyze --ansi --no-progress diff --git a/.github/workflows/ci-test-official.yml b/.github/workflows/ci-test-official.yml new file mode 100644 index 0000000..1d112b4 --- /dev/null +++ b/.github/workflows/ci-test-official.yml @@ -0,0 +1,79 @@ +name: Official Tests + +on: + push: + pull_request: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + run_tests: + name: ${{ matrix.name }} + uses: "./.github/workflows/test.yml" + with: + name: ${{ matrix.name }} + driverRepoUrl: ${{ matrix.driverRepoUrl }} + driverRepoBranch: ${{ matrix.driverRepoBranch }} + php: ${{ matrix.php }} + setUpCmd: ${{ matrix.setUpCmd }} + testCmd: ${{ matrix.testCmd }} + tearDownCmd: ${{ matrix.tearDownCmd }} + strategy: + fail-fast: false + matrix: + include: + - name: "BrowserKit (http client)" + driverRepoUrl: "https://github.com/minkphp/MinkBrowserKitDriver.git" + driverRepoBranch: "master" + php: "7.2" + # language=bash + testCmd: ./vendor/bin/phpunit --colors=always --testdox --configuration ./phpunit.http_client.xml + + - name: "BrowserKit (http kernel)" + driverRepoUrl: "https://github.com/minkphp/MinkBrowserKitDriver.git" + driverRepoBranch: "master" + php: "7.2" + # language=bash + testCmd: ./vendor/bin/phpunit --colors=always --testdox + + - name: "Selenium2" + driverRepoUrl: "https://github.com/minkphp/MinkSelenium2Driver.git" + driverRepoBranch: "master" + php: "7.2" + # language=bash + setUpCmd: | + export SELENIUM_IMAGE=selenium/standalone-firefox:2.53.1 + docker compose up --wait --quiet-pull + curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:4444/wd/hub/status + # language=bash + testCmd: | + export WEB_FIXTURES_BROWSER=firefox + export SELENIUM_VERSION=2.53.1 + export DRIVER_MACHINE_BASE_PATH=/fixtures/ + export WEB_FIXTURES_HOST=http://host.docker.internal:8002 + ./vendor/bin/phpunit --colors=always --testdox + # language=bash + tearDownCmd: | + docker compose logs --no-color --no-log-prefix --timestamps selenium &> ./logs/selenium.docker.log + + - name: "WebDriver-Classic" + driverRepoUrl: "https://github.com/minkphp/webdriver-classic-driver.git" + driverRepoBranch: "main" + php: "7.4" + # language=bash + setUpCmd: | + export SELENIUM_IMAGE=selenium/standalone-firefox:4 + docker compose up --wait --quiet-pull + curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:4444/wd/hub/status + # language=bash + testCmd: | + export WEB_FIXTURES_BROWSER=firefox + export DRIVER_MACHINE_BASE_PATH=/fixtures/ + export WEB_FIXTURES_HOST=http://host.docker.internal:8002 + ./vendor/bin/phpunit --colors=always --testdox + # language=bash + tearDownCmd: | + docker compose logs --no-color --no-log-prefix --timestamps selenium &> ./logs/selenium.docker.log diff --git a/.github/workflows/ci-test-unofficial.yml b/.github/workflows/ci-test-unofficial.yml new file mode 100644 index 0000000..4f97ecb --- /dev/null +++ b/.github/workflows/ci-test-unofficial.yml @@ -0,0 +1,47 @@ +name: Unofficial Tests + +on: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + run_tests: + name: ${{ matrix.name }} + uses: "./.github/workflows/test.yml" + with: + name: ${{ matrix.name }} + driverRepoUrl: ${{ matrix.driverRepoUrl }} + driverRepoBranch: ${{ matrix.driverRepoBranch }} + php: ${{ matrix.php }} + setUpCmd: ${{ matrix.setUpCmd }} + testCmd: ${{ matrix.testCmd }} + tearDownCmd: ${{ matrix.tearDownCmd }} + strategy: + fail-fast: false + matrix: + include: + - name: "Chrome" + driverRepoUrl: "https://gitlab.com/behat-chrome/chrome-mink-driver.git" + driverRepoBranch: "main" + php: "8.1" + # language=bash + setUpCmd: | + docker run --detach --quiet --network=host --shm-size=1g --entrypoint= \ + --volume ./vendor/mink/driver-testsuite/web-fixtures:/fixtures \ + --name chrome zenika/alpine-chrome:latest \ + chromium-browser --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 --enable-logging=stderr --v=1 \ + --no-sandbox --enable-automation --headless=new --no-first-run --disable-background-networking \ + --disable-gpu --disable-extensions --disable-web-security --disable-features=UseDbus + sed -e "s#http://localhost/#http://localhost:8002/#" -e "s#http://localhost:9222#http://127.0.0.1:9222#" phpunit.xml.dist > phpunit.xml + curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:9222/ + # language=bash + testCmd: | + export WEB_FIXTURES_BROWSER=chrome + export DRIVER_MACHINE_BASE_PATH=/fixtures/ + ./vendor/bin/phpunit --colors=always --testdox + # language=bash + tearDownCmd: | + docker logs --timestamps chrome &> ./logs/chrome.docker.log diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e0126c4..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: CI - -on: - push: - pull_request: - workflow_dispatch: - -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5431744 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,79 @@ +on: + workflow_call: + inputs: + name: + description: Name of the driver test + required: true + type: string + driverRepoUrl: + description: Git URL of the driver repository + required: true + type: string + driverRepoBranch: + description: Driver repository branch to check out + required: true + type: string + php: + description: PHP version for running tests + required: true + type: string + setUpCmd: + description: Command to run before test + required: false + type: string + testCmd: + description: Command that runs the test + required: true + type: string + tearDownCmd: + description: Command to run after test + required: false + type: string + +jobs: + Test: + runs-on: ubuntu-latest + steps: + - name: Set up workspace for driver repo + # language=bash + run: git clone --single-branch --branch "${{ inputs.driverRepoBranch }}" "${{ inputs.driverRepoUrl }}" . + + - uses: shivammathur/setup-php@v2 + with: + coverage: none + php-version: ${{ inputs.php }} + + - name: Install driver dependencies + # language=bash + run: composer install --no-interaction --ansi --no-progress + + - name: Set up driver test suite as composer dependency + # This is instead of `composer require "mink/driver-testsuite:dev-master#${{ github.sha }}"`, which works with forks + uses: actions/checkout@v4 + with: + path: ./vendor/mink/driver-testsuite + + - name: Set up + # language=bash + run: | + mkdir ./logs + MINK_HOST=0.0.0.0:8002 ./vendor/bin/mink-test-server &> ./logs/mink-test-server.log & + eval "${{ inputs.setUpCmd }}" + curl --retry 5 --retry-all-errors --retry-delay 1 --max-time 10 --head -X GET http://localhost:8002/ + + - name: Run tests + # language=bash + run: eval "${{ inputs.testCmd }}" + + - name: Tear down + if: always() + # language=bash + run: | + eval "${{ inputs.tearDownCmd }}" + + - name: Upload logs as artifact + uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ inputs.name }}-logs + path: ./logs