From 71643bfc6a9b15f9a47772f049fb924c93be1bf8 Mon Sep 17 00:00:00 2001 From: tuutti Date: Sat, 7 Oct 2023 12:12:44 +0300 Subject: [PATCH] UHF-9099: Run functional js tests in separate container, removed chromium and chromium-driver from CI/local images --- CHANGELOG.md | 9 +++++++++ README.project.md | 4 ---- docker-compose.yml | 12 +++++++++++- documentation/README.md | 6 ++++-- documentation/installation.md | 2 +- documentation/local.md | 8 ++++++++ documentation/queue.md | 13 +------------ documentation/testing.md | 21 +++++++++++++++++++++ phpunit.xml.dist | 4 ++-- 9 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 documentation/local.md create mode 100644 documentation/testing.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9af6f0..fc752a54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 2023-10-07 + +Local and CI Docker images no longer ship with chromium/chromium-driver. + +### Required actions + +- Update `docker-compose.yml`, `phpunit.xml.dist` files from this repository. +- Start your project using `testing` Docker compose profile. See [documentation](/documentation/local.md) for more information. + ## 2023-09-27 base.sh cron has been updated with a feature which prevents running cron during deployment process. diff --git a/README.project.md b/README.project.md index 7135e52b..26fab917 100644 --- a/README.project.md +++ b/README.project.md @@ -50,10 +50,6 @@ This will log you inside the app container: $ make shell ``` -## Docker compose profiles - -Modify the value of `COMPOSE_PROFILES` environment variable from `.env` file or start the project with `COMPOSE_RROFILES=your-profiles make up`. - ## Documentation See [documentatation](https://github.com/City-of-Helsinki/drupal-helfi-platform/tree/main/documentation). diff --git a/docker-compose.yml b/docker-compose.yml index f22fa655..c7dc6ba8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: # DOCKERHOST: host.docker.internal # Use drush server to run functional tests, so we don't have to care about # permission or SSL issues. - SIMPLETEST_BASE_URL: "http://127.0.0.1:8888" + SIMPLETEST_BASE_URL: "http://app:8888" SIMPLETEST_DB: "mysql://drupal:drupal@db:3306/drupal" BROWSERTEST_OUTPUT_BASE_URL: "https://${DRUPAL_HOSTNAME}" DRUPAL_VARNISH_HOST: "${COMPOSE_PROJECT_NAME}-varnish" @@ -122,10 +122,20 @@ services: image: quay.io/artemiscloud/activemq-artemis-broker environment: AMQ_EXTRA_ARGS: "--nio --user admin --password admin" + depends_on: + - app networks: - internal profiles: - queue + chromium: + # @todo Update this to newer version once minkphp supports Selenium 4. + # @see https://github.com/minkphp/MinkSelenium2Driver/pull/372 + image: selenium/standalone-chrome:106.0 + networks: + - internal + profiles: + - testing networks: internal: external: false diff --git a/documentation/README.md b/documentation/README.md index 4855cf67..44c976d3 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -4,14 +4,16 @@ [Basic installation instructions (in Finnish)](/documentation/installation.md) -## Infrastructure +## Infrastructure documentation - [Infrastructure documentation (OpenShift)](/documentation/openshift.md) - [Using OpenShift origin client (OC)](/documentation/openshift-oc.md) - [Syncing databases between environments](/documentation/openshift-db-sync.md) - [Building assets](/documentation/build-assets.md) - [Profiling code with Blackfire.io](/documentation/blackfire.md) -- [Queue](/documentation/queue.md) +- [Queue service](/documentation/queue.md) +- [Testing and CI](/documentation/testing.md) +- [Local environment](/documentation/local.md) ## Testing diff --git a/documentation/installation.md b/documentation/installation.md index 8698c782..66d215b8 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -3,7 +3,7 @@ Ennen käyttöönottoa Platform vaatii toimiakseen seuraavanlaisen ympäristön: -* PHP 8 ja Composer 2.x +* PHP 8.1+ ja Composer 2.x * [Docker ja Stonehenge](https://github.com/druidfi/guidelines/blob/master/docs/local_dev_env.md) diff --git a/documentation/local.md b/documentation/local.md new file mode 100644 index 00000000..ec434a1a --- /dev/null +++ b/documentation/local.md @@ -0,0 +1,8 @@ +# Local environment + +## Docker compose profiles + +Compose profiles are used to only run services that are actually needed. For example, there is no reason to start `elasticsearch` or `artemis` containers if your project is not using them. + +Modify the value of `COMPOSE_PROFILES` environment variable from `.env` file or start the project with `COMPOSE_RROFILES=your-profiles make up`. + diff --git a/documentation/queue.md b/documentation/queue.md index 86c47d1c..12e13132 100644 --- a/documentation/queue.md +++ b/documentation/queue.md @@ -4,18 +4,7 @@ Apache Artemis is used to manage Drupal queues. ## Configuration -Add and expose the following environment variables: - -```bash -# This should be something like 'tcp://route-to-artemis:61613'. -ARTEMIS_BROKERS -# The username of Artemis service. -ARTEMIS_LOGIN -# The password of Artemis service. -ARTEMIS_PASSCODE -``` - -@todo: Figure out where to find these values. +@todo: Figure out what configuration is required. ## Running queues diff --git a/documentation/testing.md b/documentation/testing.md new file mode 100644 index 00000000..e7ef1575 --- /dev/null +++ b/documentation/testing.md @@ -0,0 +1,21 @@ +# Testing + +## Drupal tests + +Tests can be run with `vendor/bin/phpunit -c /app/phpunit.xml.dist /path/to/test`. + +### Functional tests + +Functional tests are run using build-in Drush webserver. + +The server should be started automatically on local environment, in case it's not, you can run it with something like `drush rs $SIMPLETEST_BASE_URL --dns`. + +### Functional JavaScript tests + +To run Functional JS tests, you must start your local environment with `testing` compose profile. + +You can either modify your project's `.env` file and append `testing` to `COMPOSE_PROFILES` environment variable, or start the project with `COMPOSE_PROFILES=testing make up`. + +## CI tests + +@todo diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ae082a9..740d3d79 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,8 +12,8 @@ - - + +