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

[#1336, #1063] Moved to selenium/standalone-chrome for ARM. #1345

Merged
merged 2 commits into from
Aug 31, 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
1 change: 1 addition & 0 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ commands:
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-${PWD##*/}} \
DREVOPS_HOST_DB_PORT=$(docker compose port mariadb 3306 2>/dev/null | cut -d : -f 2) \
DREVOPS_HOST_SOLR_PORT=$(docker compose port solr 8983 2>/dev/null | cut -d : -f 2) \
DREVOPS_HOST_SELENIUM_VNC_PORT=$(docker compose port chrome 7900 2>/dev/null | cut -d : -f 2) \
DREVOPS_HOST_HAS_SEQUELACE=$(uname -a | grep -i -q darwin && mdfind -name 'Sequel Ace' 2>/dev/null | grep -q "Ace" && echo 1 || true) \
ahoy cli ./scripts/drevops/info.sh "$@"

Expand Down
6 changes: 6 additions & 0 deletions .scaffold/.ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ commands:
npm --prefix tests ci
npm --prefix docs ci

docs:
name: Build Scaffold docs.
cmd: |
npm --prefix docs ci
npm --prefix docs run start

lint:
name: Lint Scaffold project.
cmd: |
Expand Down
1 change: 0 additions & 1 deletion .scaffold/docs/content/getting-started/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ with addition of several configuration files and directories.
├── behat.yml # Behat configuration file.
├── composer.json # Composer configuration file.
├── docker-compose.yml # Docker Compose configuration file.
├── docker-compose.override.default.yml # Docker Compose local configuration file.
├── phpcs.xml # PHP CodeSniffer configuration file.
├── phpmd.xml # PHP Mess Detector configuration file.
├── phpstan.neon # PHPStan configuration file.
Expand Down
29 changes: 29 additions & 0 deletions .scaffold/docs/content/tools/behat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,32 @@ There are also example tests in the [`tests/behat/features`](https://github.com/
directory that can be used as a starting point for writing tests. These tests
define `@smoke` tests for the homepage and login page as well as tests for
contributed modules.

## Connecting to the browser

For `@javascript` tests, Behat uses Selenium to connect to the browser. The
browser runs within a container and can be observed from the host machine by
using a browser thanks to the VNC server running in the container and [noVNC](https://novnc.com/).

Run

```shell
ahoy info
```
and click on the link next to `Selenium VNC URL on host` to open the browser.

Or use the following command to get the port number:
```shell
docker compose port chrome 7900
```
and open `http://localhost:<port>/?autoconnect=1&password=secret` in the browser.

:::tip

When running tests, you can add `And I wait for 60 seconds` step to suspend
the test execution for a minute and interact with the headless browser in a
container through a browser on your host machine.

:::

![behat-novnc.gif](/img/behat-novnc.gif)
3 changes: 1 addition & 2 deletions .scaffold/docs/content/tools/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ sections.

Docker Compose reads the configuration from the `docker-compose.yml` and
`docker-compose.override.yml` files. The configuration files are written in
YAML,
which [support anchors and references](http://blog.daemonl.com/2016/02/yaml.html)
YAML, which [support anchors and references](http://blog.daemonl.com/2016/02/yaml.html)
that help to reduce duplication.

The file provided by Scaffold contains the following sections:
Expand Down
1 change: 1 addition & 0 deletions .scaffold/docs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"localdev",
"mglaman",
"minimised",
"novnc",
"oomphinc",
"optimise",
"optimised",
Expand Down
Binary file added .scaffold/docs/static/img/behat-novnc.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion .scaffold/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ assert_files_present_drevops() {
assert_file_exists "behat.yml"
assert_file_exists "composer.json"
assert_file_exists ".ahoy.local.example.yml"
assert_file_exists "docker-compose.override.default.yml"
assert_file_exists ".env.local.default"
assert_file_exists "docker-compose.yml"
assert_file_exists "phpcs.xml"
Expand Down
8 changes: 1 addition & 7 deletions .scaffold/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ prepare_sut() {
mkdir -p .idea
touch .idea/idea_file.txt
assert_file_exists .idea/idea_file.txt

# LCOV_EXCL_START
if uname -a | grep -q ARM64; then
substep "Override local Docker Compose for ARM."
cp docker-compose.override.default.yml docker-compose.override.yml
fi
# LCOV_EXCL_STOP
}

docker_remove_image() {
Expand Down Expand Up @@ -310,6 +303,7 @@ assert_ahoy_info() {
assert_output_not_contains "DB-in-image : ${db_image}"
fi
assert_output_contains "Solr URL on host :"
assert_output_contains "Selenium VNC URL on host :"
assert_output_contains "Mailhog URL : http://mailhog.docker.amazee.io/"
assert_output_contains "Xdebug : Disabled ('ahoy debug' to enable)"
assert_output_not_contains "Containers are not running."
Expand Down
9 changes: 8 additions & 1 deletion .scaffold/tests/bats/fixtures/docker-compose.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"TZ": "Australia/Melbourne",
"XDEBUG_ENABLE": ""
},
"image": "selenium/standalone-chrome:VERSION",
"image": "selenium/standalone-chromium:VERSION",
"labels": {
"lagoon.type": "none"
},
"networks": {
"default": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"target": 7900
}
],
"shm_size": "1073741824",
"volumes": [
{
Expand Down
9 changes: 8 additions & 1 deletion .scaffold/tests/bats/fixtures/docker-compose.env_local.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"TZ": "Australia/Melbourne",
"XDEBUG_ENABLE": ""
},
"image": "selenium/standalone-chrome:VERSION",
"image": "selenium/standalone-chromium:VERSION",
"labels": {
"lagoon.type": "none"
},
"networks": {
"default": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"target": 7900
}
],
"shm_size": "1073741824",
"volumes": [
{
Expand Down
9 changes: 8 additions & 1 deletion .scaffold/tests/bats/fixtures/docker-compose.env_mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"TZ": "Australia/Melbourne",
"XDEBUG_ENABLE": "1"
},
"image": "selenium/standalone-chrome:VERSION",
"image": "selenium/standalone-chromium:VERSION",
"labels": {
"lagoon.type": "none"
},
"networks": {
"default": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"target": 7900
}
],
"shm_size": "1073741824",
"volumes": [
{
Expand Down
9 changes: 8 additions & 1 deletion .scaffold/tests/bats/fixtures/docker-compose.noenv.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"TZ": "Australia/Melbourne",
"XDEBUG_ENABLE": ""
},
"image": "selenium/standalone-chrome:VERSION",
"image": "selenium/standalone-chromium:VERSION",
"labels": {
"lagoon.type": "none"
},
"networks": {
"default": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"target": 7900
}
],
"shm_size": "1073741824",
"volumes": [
{
Expand Down
4 changes: 0 additions & 4 deletions README.dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ to DrevOps progress. Remove this section once onboarding is finished.
- `pygmy up`
- `ahoy build`

### Apple M1 adjustments

Copy `docker-compose.override.default.yml` to `docker-compose.override.yml`.

## Project documentation

- [FAQs](docs/faqs.md)
Expand Down
16 changes: 15 additions & 1 deletion behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ default:
base_url: http://nginx:8080
files_path: '%paths.base%/tests/behat/fixtures'
browser_name: chrome
javascript_session: selenium2
selenium2:
wd_host: "http://chrome:4444/wd/hub"
javascript_session: selenium2
capabilities:
browser: chrome
extra_capabilities:
"goog:chromeOptions":
args:
- '--disable-gpu' # Disables hardware acceleration required in containers and cloud-based instances (like CI runners) where GPU is not available.
# Options to increase stability and speed.
- '--disable-extensions' # Disables all installed Chrome extensions. Useful in testing environments to avoid interference from extensions.
- '--disable-infobars' # Hides the infobar that Chrome displays for various notifications, like warnings when opening multiple tabs.
- '--disable-popup-blocking' # Disables the popup blocker, allowing all popups to appear. Useful in testing scenarios where popups are expected.
- '--disable-translate' # Disables the built-in translation feature, preventing Chrome from offering to translate pages.
- '--no-first-run' # Skips the initial setup screen that Chrome typically shows when running for the first time.
- '--test-type' # Disables certain security features and UI components that are unnecessary for automated testing, making Chrome more suitable for test environments.

# Provides integration with Drupal APIs.
Drupal\DrupalExtension:
blackbox: ~
Expand Down
9 changes: 0 additions & 9 deletions docker-compose.override.default.yml

This file was deleted.

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ services:
context: .
dockerfile: .docker/clamav.dockerfile
ports:
- "3310" # Find port on host with `docker-compose port clamav 3310`.
- "3310" # Find port on host with `docker compose port clamav 3310`.
environment:
<< : *default-environment
networks:
Expand All @@ -217,7 +217,9 @@ services:

# Chrome container, used for browser testing.
chrome:
image: selenium/standalone-chrome:111.0
image: selenium/standalone-chromium:128.0
ports:
- "7900" # Find port on host with `docker compose port chrome 7900`.
shm_size: '1gb' # Increase '/dev/shm' partition size to avoid browser crashing.
<<: *default-volumes # Use default volumes to provide access to test fixtures.
environment:
Expand Down
16 changes: 0 additions & 16 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,6 @@
"drupal/core-recommended"
]
},
{
"groupName": "Container images excluded",
"matchManagers": [
"dockerfile",
"docker-compose"
],
"matchDepNames": [
"selenium/standalone-chrome",
"seleniarm/standalone-chromium"
],
"enabled": false
},
{
"groupName": "Container images",
"groupSlug": "docker",
Expand All @@ -95,10 +83,6 @@
"dockerfile",
"docker-compose",
"custom.regex"
],
"matchPackageNames": [
"!selenium/standalone-chrome",
"!seleniarm/standalone-chromium"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions scripts/drevops/info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
if [ -n "${DREVOPS_HOST_SOLR_PORT:-}" ]; then
note "Solr URL on host : http://127.0.0.1:${DREVOPS_HOST_SOLR_PORT}"
fi
if [ -n "${DREVOPS_HOST_SELENIUM_VNC_PORT:-}" ]; then
note "Selenium VNC URL on host : http://localhost:${DREVOPS_HOST_SELENIUM_VNC_PORT}/?autoconnect=1&password=secret"

Check warning on line 48 in scripts/drevops/info.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/info.sh#L47-L48

Added lines #L47 - L48 were not covered by tests
fi
note "Mailhog URL : http://mailhog.docker.amazee.io/"
note "Xdebug : $(php -v | grep -q Xdebug && echo "Enabled ('ahoy up cli' to disable)" || echo "Disabled ('ahoy debug' to enable)")"
if [ "${DREVOPS_SHOW_LOGIN}" = "1" ] || [ -n "${1:-}" ]; then
Expand Down