Skip to content

Commit

Permalink
UHF-9125: Updated platform
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Oct 10, 2023
1 parent 2078599 commit 09d3fe4
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 157 deletions.
7 changes: 2 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ STAGE_FILE_PROXY_ORIGIN_DIR=
DRUPAL_HOSTNAME=helfi-rekry.docker.so

# Docker image
DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.1
DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.2

# Default source @alias where to sync database and files from
DRUPAL_SYNC_SOURCE=main
COMPOSE_PROFILES=search,queue

# Public webroot
DRUPAL_WEBROOT=public

DRUPAL_SYNC_FILES=no

# Client ID for Helbit integration
HELBIT_CLIENT_ID=

Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
name: CI
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
SIMPLETEST_BASE_URL: http://app:8888
jobs:
tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/city-of-helsinki/drupal-php-docker:8.2-alpine
options: --hostname app

services:
db:
Expand All @@ -31,7 +33,7 @@ jobs:
run: composer install --no-interaction

- name: Scan security updates
run: drush pm:security
run: composer audit

- name: Check that subtheme is not built with dev mode
run: if grep -q 'sourceMappingURL=' -R public/themes/custom/hdbt_subtheme/dist/css; then exit 1; fi
Expand All @@ -53,11 +55,7 @@ jobs:
- name: Start services
run: |
drush runserver $SIMPLETEST_BASE_URL > /dev/null 2>&1 &
chromedriver --port=4444 > /dev/null 2>&1 &
# Chromium browser is required to run 'functional-javascript' and
# 'existing-site-javascript' tests.
chromium-browser --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 &
drush runserver $SIMPLETEST_BASE_URL --dns > /dev/null 2>&1 &
# Wait for drush server to start.
for i in {1..5}; do RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$SIMPLETEST_BASE_URL" || true); if [ "$RESPONSE_CODE" -gt "301" ] || [ "$RESPONSE_CODE" -lt "200" ]; then sleep 2; fi; done
Expand All @@ -66,3 +64,4 @@ jobs:
run: |
composer test-php public/modules/custom
if [ -d "tests/" ]; then composer test-php tests/; else echo "No DTT tests found. Ignoring..."; fi
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 0 additions & 39 deletions docker-compose.override.yml

This file was deleted.

60 changes: 57 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
STAGE_FILE_PROXY_ORIGIN: "${STAGE_FILE_PROXY_ORIGIN}"
STAGE_FILE_PROXY_ORIGIN_DIR: "${STAGE_FILE_PROXY_ORIGIN_DIR}"
APP_ENV: "${APP_ENV:-local}"
ELASTIC_PROXY_URL: ${ELASTIC_PROXY_URL:-""}
DRUPAL_ROUTES: "https://varnish-${DRUPAL_HOSTNAME},https://helfi-proxy.docker.so,http://${COMPOSE_PROJECT_NAME}-varnish"
DRUPAL_REVERSE_PROXY_ADDRESS: helfi-proxy.docker.so
DRUSH_OPTIONS_URI: "https://${DRUPAL_HOSTNAME}"
Expand All @@ -21,9 +22,9 @@ services:
# xdebug by default (like /etc/environments, ~/.bashrc, or ~/.zshrc).
XDEBUG_ENABLE: "${XDEBUG_ENABLE:-false}"
# DOCKERHOST: host.docker.internal
# Use drush server to run functional tests so we don't have to care about
# permission issues.
SIMPLETEST_BASE_URL: "http://127.0.0.1:8888"
# Use drush server to run functional tests, so we don't have to care about
# permission or SSL issues.
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"
Expand Down Expand Up @@ -82,6 +83,59 @@ services:
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-varnish.tls=true"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}-varnish.loadbalancer.server.port=6081"
- "traefik.docker.network=stonehenge-network"
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:8.4.0
container_name: "${COMPOSE_PROJECT_NAME}-elastic"
environment:
- node.name="${COMPOSE_PROJECT_NAME}-elastic"
- discovery.seed_hosts=elastic
- cluster.name=es-docker-cluster
- cluster.initial_master_nodes="${COMPOSE_PROJECT_NAME}-elastic"
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "http.cors.allow-origin=\"*\""
- "http.cors.enabled=true"
- "http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization"
- "http.cors.allow-credentials=true"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
ports:
- 9200-9220:9200
networks:
- internal
- stonehenge-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.entrypoints=https"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.rule=Host(`elastic-${DRUPAL_HOSTNAME}`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}-elastic.tls=true"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}-elastic.loadbalancer.server.port=9200"
- "traefik.docker.network=stonehenge-network"
- "traefik.port=9200"
profiles:
- search
artemis:
container_name: "${COMPOSE_PROJECT_NAME}-artemis"
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
Expand Down
22 changes: 13 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./public/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="false"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="false"
failOnRisky="true"
failOnWarning="true"
failOnSkipped="true"
verbose="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
>
<php>
<!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/>
<!-- Do not limit the amount of memory tests take to run. -->
<ini name="memory_limit" value="-1"/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="public/sites/simpletest"/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"w3c": false, "args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://127.0.0.1:4444"]' />
<env name="DTT_MINK_DRIVER_ARGS" value='["chrome", {"chromeOptions":{"w3c": false }}, "http://127.0.0.1:4444"]'/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"w3c": false}}, "http://chromium:4444"]' />
<env name="DTT_MINK_DRIVER_ARGS" value='["chrome", {"chromeOptions":{"w3c": false }}, "http://chromium:4444"]'/>
<env name="DTT_API_OPTIONS" value='{"socketTimeout": 360, "domWaitTimeout": 3600000}' />
<env name="DTT_API_URL" value="http://127.0.0.1:9222"/>
<env name="DTT_BASE_URL" value="http://127.0.0.1:8888"/>
<env name="DTT_API_URL" value="http://chromium:9222"/>
<env name="DTT_BASE_URL" value="http://app:8888"/>
</php>
<testsuites>
<testsuite name="unit">
Expand Down
65 changes: 63 additions & 2 deletions public/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@
ini_set('zend.enable_gc', 'Off');
}


if (!function_exists('drupal_get_env')) {
/**
* Gets the value of given environment variable.
*
* @param string|array $variables
* The variables to scan.
*
* @return mixed
* The value.
*/
function drupal_get_env(string|array $variables) : mixed {
if (!is_array($variables)) {
$variables = [$variables];
}

foreach ($variables as $var) {
if ($value = getenv($var)) {
return $value;
}
}
return NULL;
}
}

if ($simpletest_db = getenv('SIMPLETEST_DB')) {
$parts = parse_url($simpletest_db);
putenv(sprintf('DRUPAL_DB_NAME=%s', substr($parts['path'], 1)));
Expand Down Expand Up @@ -69,6 +94,10 @@
}
$routes[] = 'http://127.0.0.1';

if ($simpletest_base_url = getenv('SIMPLETEST_BASE_URL')) {
$routes[] = $simpletest_base_url;
}

if ($drush_options_uri = getenv('DRUSH_OPTIONS_URI')) {
$routes[] = $drush_options_uri;
}
Expand Down Expand Up @@ -102,8 +131,14 @@
'driver' => 'helfi_azure',
'config' => [
'name' => $blob_storage_name,
'key' => getenv('AZURE_BLOB_STORAGE_KEY'),
'token' => getenv('AZURE_BLOB_STORAGE_SAS_TOKEN'),
'key' => drupal_get_env([
'AZURE_BLOB_STORAGE_KEY',
'BLOBSTORAGE_ACCOUNT_KEY',
]),
'token' => drupal_get_env([
'AZURE_BLOB_STORAGE_SAS_TOKEN',
'BLOBSTORAGE_SAS_TOKEN',
]),
'container' => getenv('AZURE_BLOB_STORAGE_CONTAINER'),
'endpointSuffix' => 'core.windows.net',
'protocol' => 'https',
Expand Down Expand Up @@ -205,6 +240,32 @@
$config['helfi_proxy.settings']['robots_header_enabled'] = (bool) $robots_header_enabled;
}

$artemis_destination = drupal_get_env([
'ARTEMIS_DESTINATION',
'PROJECT_NAME',
]);

if ($artemis_brokers = getenv('ARTEMIS_BROKERS') && $artemis_destination) {
$settings['stomp']['default'] = [
'clientId' => getenv('ARTEMIS_CLIENT_ID') ?: 'artemis',
'login' => getenv('ARTEMIS_LOGIN'),
'passcode' => getenv('ARTEMIS_PASSCODE'),
'destination' => sprintf('/queue/%s', $artemis_destination),
'brokers' => $artemis_brokers,
'timeout' => ['read' => 15000],
'heartbeat' => [
'send' => 12000,
'receive' => 0,
'observers' => [
[
'class' => '\Stomp\Network\Observer\HeartbeatEmitter',
],
],
],
];
$settings['queue_default'] = 'queue.stomp.default';
}

$config['filelog.settings']['rotation']['schedule'] = 'never';

if (
Expand Down
Loading

0 comments on commit 09d3fe4

Please sign in to comment.