Skip to content
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

Update ci.yml #88

Merged
merged 14 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
on:
push:
branches:
- master
- "master"
- "1.3"
pull_request:
branches:
- master
- "master"
- "1.3"

env:
DRIVER_URL: "http://localhost:4444"
Expand All @@ -20,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.2 ]
php: [ 8.3 ]
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand All @@ -30,7 +32,7 @@ jobs:
extensions: zip, :xdebug
tools: composer
- id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.directory }}
Expand All @@ -48,11 +50,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.0, 8.1, 8.2 ]
php: [ 8.1, 8.2, 8.3 ]
browser: [ chrome, firefox ]
experimental: [false]
include:
- php: 8.3
- php: 8.4
experimental: true
browser: chrome
continue-on-error: ${{ matrix.experimental }}
Expand All @@ -71,7 +73,7 @@ jobs:

- name: Determine composer cache directory
id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v4
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ logs/
vendor-bin/**/vendor/
bin/
vendor/
composer.lock
!bin/browser
!bin/start_driver.sh
!bin/start_webserver.sh
.phpunit.result.cache
.php-cs-fixer.cache
driver.zip
driver.tar.gz
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP81Migration' => true,
'@PHPUnit91Migration:risky' => true,
'@Symfony' => true,
])
->setFinder($finder);
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Follow https://github.com/shivammathur/setup-php#local-testing-setup

## Copyright

Copyright (c) 2023 Oleg Andreyev <[email protected]>
Copyright (c) 2024 Oleg Andreyev <[email protected]>
19 changes: 1 addition & 18 deletions bin/browser/chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,8 @@ set -ex
MACHINE_FAMILY=$1
DRIVER_VERSION=$2

if [[ "$DRIVER_VERSION" == "latest" ]]; then
DRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
fi

mkdir -p chromedriver

if [[ $MACHINE_FAMILY == "windows" ]]; then
PLATFORM="win32"
fi

if [[ $MACHINE_FAMILY == "linux" ]]; then
PLATFORM="linux64"
fi

if [[ $MACHINE_FAMILY == "mac" ]]; then
PLATFORM="mac64"
fi

wget -q -t 3 "https://chromedriver.storage.googleapis.com/${DRIVER_VERSION}/chromedriver_${PLATFORM}.zip" -O driver.zip
unzip -qo driver.zip -d chromedriver/
./bin/bdi -vvv driver:chromedriver --driver-version=$DRIVER_VERSION --os=$MACHINE_FAMILY ./chromedriver

./chromedriver/chromedriver --port=4444 --verbose --enable-chrome-logs --whitelisted-ips=
27 changes: 1 addition & 26 deletions bin/browser/firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,8 @@ set -ex
MACHINE_FAMILY=$1
DRIVER_VERSION=$2

if [[ "$DRIVER_VERSION" == "latest" ]]; then
DRIVER_VERSION=$(curl -sS https://api.github.com/repos/mozilla/geckodriver/releases/latest | grep -E -o 'tag_name([^,]+)' | tr -d \" | tr -d " " | cut -d':' -f2)
fi

mkdir -p geckodriver

EXTENSION="tar.gz"

if [[ $MACHINE_FAMILY == "windows" ]]; then
PLATFORM="win64"
EXTENSION="zip"
fi

if [[ $MACHINE_FAMILY == "linux" ]]; then
PLATFORM="linux64"
fi

if [[ $MACHINE_FAMILY == "mac" ]]; then
PLATFORM="macos"
fi

wget -q -t 3 "https://github.com/mozilla/geckodriver/releases/download/${DRIVER_VERSION}/geckodriver-$DRIVER_VERSION-${PLATFORM}.${EXTENSION}" -O "driver.${EXTENSION}"

if [[ "$EXTENSION" == "tar.gz" ]]; then
tar -xf driver.tar.gz -C ./geckodriver/;
else
unzip -qo driver.zip -d geckodriver/
fi;
./bin/bdi -vvv driver:geckodriver --driver-version=$DRIVER_VERSION --os=$MACHINE_FAMILY ./geckodriver

./geckodriver/geckodriver --host 127.0.0.1 -vv --port 4444
2 changes: 1 addition & 1 deletion bin/start_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ UNAME=$(uname -s)
case "$UNAME" in
*NT*) MACHINE_FAMILY=windows ;;
Linux*) MACHINE_FAMILY=linux ;;
Darwin*) MACHINE_FAMILY=mac ;;
Darwin*) MACHINE_FAMILY=macos ;;
esac

if [ -z "$BROWSER_NAME" ]; then
Expand Down
22 changes: 20 additions & 2 deletions bin/start_webserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

set -ex

WEBSERVER_PID=0

function stop() {
echo "Stopping PHP server"
kill -9 $WEBSERVER_PID
}

trap stop INT
trap stop ERR
trap stop EXIT

echo "Starting PHP server on port 8002"
# see https://github.com/minkphp/driver-testsuite/pull/28
export USE_ZEND_ALLOC=0
php -S localhost:8002 -t ./vendor/mink/driver-testsuite/web-fixtures

php -S localhost:8002 -t ./vendor/mink/driver-testsuite/web-fixtures &
WEBSERVER_PID=$!
echo "Started PHP server on port 8002, pid $WEBSERVER_PID"

echo "Waiting for PHP server to be ready..."
ATTEMPT=0
until $(echo | nc localhost 8002); do
if [ $ATTEMPT -gt 5 ]; then
Expand All @@ -19,4 +32,9 @@ until $(echo | nc localhost 8002); do
echo waiting for PHP server on port 8002...;
ATTEMPT=$((ATTEMPT + 1))
done;

echo "PHP server started"
while true; do
echo "PHP server is running"
sleep 1
done
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
"require-dev": {
"ext-json": "*",
"roave/security-advisories": "dev-master",
"mink/driver-testsuite": "dev-integration-branch",
"mink/driver-testsuite": "dev-integration-branch-v2",
"behat/mink-extension": "^2.3",
"bamarni/composer-bin-plugin": "^1.8",
"jetbrains/phpstorm-attributes": "^1.0"
"jetbrains/phpstorm-attributes": "^1.0",
"dbrekelmans/bdi": "^1.3"
},
"scripts": {
"bin": "echo 'bin not installed'",
Expand Down
11 changes: 11 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
ignoreErrors:
-
message: "#^Method OAndreyev\\\\Mink\\\\Driver\\\\WebDriver\\:\\:setValue\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#"
count: 1
path: src/WebDriver.php

-
message: "#^Parameter \\#1 \\$timeout_in_second of method Facebook\\\\WebDriver\\\\Remote\\\\RemoteWebDriver\\:\\:wait\\(\\) expects int, float given\\.$#"
count: 1
path: src/WebDriver.php
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phpstan-baseline.neon

parameters:
level: 6
paths:
Expand Down
51 changes: 24 additions & 27 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Driver test suite">
<directory>tests</directory>
<directory>vendor/mink/driver-testsuite/tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="OAndreyev\Mink\Tests\Driver\ScreenshotListener"/>
</listeners>

<php>
<var name="driver_config_factory" value="OAndreyev\Mink\Tests\Driver\WebDriverConfig::getInstance" />

<!-- Docker for Mac, see https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos#i-want-to-connect-from-a-container-to-a-service-on-the-host -->
<!-- <server name="WEB_FIXTURES_HOST" value="http://host.docker.internal:8002"/>-->
<!-- See default value in \Behat\Mink\Tests\Driver\AbstractConfig::getWebFixturesUrl -->
<!-- <server name="WEB_FIXTURES_HOST" value="http://localhost:8002"/>-->

<!-- <env name="BROWSER_NAME" value="chrome"/>-->
<!-- https://peter.sh/experiments/chromium-command-line-switches/ -->
<!-- <env name="DRIVER_OPTIONS" value='{"args":["headless"]}'/>-->

<!-- <env name="BROWSER_NAME" value="firefox"/>-->
<!-- https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions#binary-->
<!-- <env name="DRIVER_OPTIONS" value='{"log": {"level":"trace"}, "args": ["-headless"], "binary": "/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox-bin"}'/>-->
<!-- <env name="DRIVER_OPTIONS" value='{"log": {"level":"trace"}, "binary": "/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox-bin"}'/>-->
<var name="driver_config_factory" value="OAndreyev\Mink\Tests\Driver\WebDriverConfig::getInstance"/>
<!--Docker for Mac, see https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos#i-want-to-connect-from-a-container-to-a-service-on-the-host -->
<!--<server name="WEB_FIXTURES_HOST" value="http://host.docker.internal:8002"/>-->
<!--See default value in \Behat\Mink\Tests\Driver\AbstractConfig::getWebFixturesUrl -->
<!--<server name="WEB_FIXTURES_HOST" value="http://localhost:8002"/>-->

<!-- where driver will connect to -->
<server name="DRIVER_URL" value="http://localhost:4444" />
<!--<server name="DRIVER_URL" value="http://localhost:4444"/>-->
<!-- Docker for Mac, see https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos#i-want-to-connect-from-a-container-to-a-service-on-the-host -->
<!-- <server name="DRIVER_URL" value="http://host.docker.internal:4444/wd/hub" />-->
<!--<server name="DRIVER_URL" value="http://host.docker.internal:4444/wd/hub" />-->

<!-- CHROME -->
<!--<env name="BROWSER_NAME" value="chrome"/>-->
<!--https://peter.sh/experiments/chromium-command-line-switches/ -->
<!--<env name="DRIVER_OPTIONS" value='{"args":["headless"]}'/>-->

<!-- FIREFOX -->
<!--<env name="BROWSER_NAME" value="firefox"/>-->
<!--https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions#binary-->
<!--<env name="DRIVER_OPTIONS" value='{"log": {"level":"trace"}, "args": ["-headless"]}'/>-->
<!--<env name="DRIVER_OPTIONS" value='{"log": {"level":"trace"}, "binary": "/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox-bin"}'/>-->
</php>

<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
Loading
Loading