Skip to content

Commit

Permalink
Merge pull request #59 from WengerK/drupal-10.4
Browse files Browse the repository at this point in the history
add support for Drupal 10.4-dev using docker tag 10.3
  • Loading branch information
WengerK authored Aug 20, 2024
2 parents 15ea050 + b04ac74 commit 46b6c03
Show file tree
Hide file tree
Showing 13 changed files with 349 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/container-structure-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
drupal_version: ['8.9', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5', '10.0', '10.1', '10.2', '10.3', '11.0', '11.1']
drupal_version: ['8.9', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5', '10.0', '10.1', '10.2', '10.3', '10.4', '11.0', '11.1']
include:
- drupal_version: '8.9'
drupal_major: '8'
Expand All @@ -33,6 +33,8 @@ jobs:
drupal_major: '10'
- drupal_version: '10.3'
drupal_major: '10'
- drupal_version: '10.4'
drupal_major: '10'
- drupal_version: '11.0'
drupal_major: '11'
- drupal_version: '11.1'
Expand All @@ -58,7 +60,7 @@ jobs:
', github.ref)
strategy:
matrix:
drupal_version: ['8.9', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5', '10.0', '10.1', '10.2', '10.3', '11.0', '11.1']
drupal_version: ['8.9', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5', '10.0', '10.1', '10.2', '10.3', '10.4', '11.0', '11.1']
include:
- drupal_version: '8.9'
drupal_major: '8'
Expand All @@ -82,6 +84,8 @@ jobs:
drupal_major: '10'
- drupal_version: '10.3'
drupal_major: '10'
- drupal_version: '10.4'
drupal_major: '10'
- drupal_version: '11.0'
drupal_major: '11'
- drupal_version: '11.1'
Expand Down
55 changes: 55 additions & 0 deletions 10/10.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ARG BASE_IMAGE_TAG
FROM drupal:${BASE_IMAGE_TAG}-apache

ARG DRUPAL_VER

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV DRUPAL_VER="${DRUPAL_VER}"

WORKDIR /opt/drupal

# Install git and zip library.
# Necessary for some composer operations.
RUN set -eux; \
\
apt-get update; \
apt-get install -y \
git \
zip \
unzip \
;

# Install wait-for-it script to be able to check if services are up.
RUN curl -OL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && \
chmod +x wait-for-it.sh && \
mv wait-for-it.sh /usr/local/bin/wait-for-it

# As of Composer 2.2.0, the allow-plugins option adds a layer of security.
# Some plugin Installer must be authorized. Not allowing it may lead to an instance of Drupal
# installed into the vendor directory.
RUN composer config --no-interaction allow-plugins true

# Install Drush.
# Drush will be heavily use to setup a working Drupal environment.
RUN COMPOSER_MEMORY_LIMIT=-1 composer require drush/drush:^12.0

# Prepare for Drupal 10.4 upgrade.
# @see https://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-to-drupal-9-or-higher
RUN composer require drupal/core-recommended:~${DRUPAL_VER} --update-with-all-dependencies --no-update
RUN composer require drupal/core-dev:~${DRUPAL_VER} --dev --update-with-all-dependencies --no-update

# Set the minimum stability to "dev" to allow installing unstable Drupal Core.
RUN composer config minimum-stability dev

# Perform Drupal 10.1 installation.
RUN COMPOSER_MEMORY_LIMIT=-1 composer update --with-all-dependencies

# Clean repository.
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy a default template for PHPUnit testing.
COPY templates/phpunit.xml /opt/drupal/web/phpunit.xml

# Create the output directory for PHPUnit.
RUN mkdir -p /opt/drupal/web/sites/default/files/simpletest/browser_output
RUN chown www-data:www-data /opt/drupal/web/sites/default/files/simpletest/browser_output
65 changes: 65 additions & 0 deletions 10/10.4/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
DRUPAL_VER ?= 10.4
DRUPAL_VER_MAJOR ?= $(shell echo "${DRUPAL_VER}" | grep -oE '^[0-9]+\.[0-9]+')

BASE_IMAGE_TAG = 10.3
ARCH_TO_BUILD ?= "linux/amd64"

REPO = wengerk/drupal-for-contrib
NAME = drupal-$(DRUPAL_VER_MAJOR)

TAG ?= $(DRUPAL_VER_MAJOR)

ifneq ($(BASE_IMAGE_STABILITY_TAG),)
BASE_IMAGE_TAG := $(BASE_IMAGE_TAG)-$(BASE_IMAGE_STABILITY_TAG)
endif

ifneq ($(STABILITY_TAG),)
ifneq ($(TAG),latest)
override TAG := $(TAG)-$(STABILITY_TAG)
endif
endif

.PHONY: build test push shell run start stop logs clean release

default: build

build:
docker buildx build -t $(REPO):$(TAG) \
--platform=${ARCH_TO_BUILD} \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg DRUPAL_VER=$(DRUPAL_VER) \
./

build-nc:
docker buildx build -t $(REPO):$(TAG) \
--platform=${ARCH_TO_BUILD} \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg DRUPAL_VER=$(DRUPAL_VER) \
--no-cache --pull \
./

test:
cd ./tests && IMAGE=$(REPO):$(TAG) ./run.sh

push:
docker push $(REPO):$(TAG)

shell:
docker run --rm --name $(NAME) -i -t $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash

run:
docker run --rm --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) $(CMD)

start:
docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG)

stop:
docker stop $(NAME)

logs:
docker logs $(NAME)

clean:
-docker rm -f $(NAME)

release: build push
97 changes: 97 additions & 0 deletions 10/10.4/templates/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- For how to customize PHPUnit configuration, see core/tests/README.md. -->
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
failOnWarning="true"
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
cacheResult="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<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"/>
<!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
<env name="SIMPLETEST_BASE_URL" value="http://drupal"/>
<!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/database_name#table_prefix -->
<env name="SIMPLETEST_DB" value="mysql://drupal:drupal@db/drupal"/>
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/opt/drupal/web/sites/default/files/simpletest/browser_output"/>
<!-- By default, browser tests will output links that use the base URL set
in SIMPLETEST_BASE_URL. However, if your SIMPLETEST_BASE_URL is an internal
path (such as may be the case in a virtual or Docker-based environment),
you can set the base URL used in the browser test output links to something
reachable from your host machine here. This will allow you to follow them
directly and view the output. -->
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>

<!-- Deprecation testing is managed through Symfony's PHPUnit Bridge.
The environment variable SYMFONY_DEPRECATIONS_HELPER is used to configure
the behavior of the deprecation tests.
See https://symfony.com/doc/current/components/phpunit_bridge.html#configuration
Drupal core's testing framework is setting this variable to its defaults.
Projects with their own requirements need to manage this variable
explicitly.
-->
<!-- To disable deprecation testing completely uncomment the next line. -->
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> -->
<!-- Deprecation errors can be selectively ignored by specifying a file of
regular expression patterns for exclusion.
See https://symfony.com/doc/current/components/phpunit_bridge.html#ignoring-deprecations
Uncomment the line below to specify a custom deprecations ignore file.
NOTE: it may be required to specify the full path to the file to run tests
correctly.
-->
<!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="ignoreFile=.deprecation-ignore.txt"/> -->

<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
<env name="MINK_DRIVER_CLASS" value=''/>
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS" value=''/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "goog:chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://chrome:9515"]'/>
</php>
<testsuites>
<testsuite name="unit">
<file>./core/tests/TestSuites/UnitTestSuite.php</file>
</testsuite>
<testsuite name="kernel">
<file>./core/tests/TestSuites/KernelTestSuite.php</file>
</testsuite>
<testsuite name="functional">
<file>./core/tests/TestSuites/FunctionalTestSuite.php</file>
</testsuite>
<testsuite name="functional-javascript">
<file>./core/tests/TestSuites/FunctionalJavascriptTestSuite.php</file>
</testsuite>
<testsuite name="build">
<file>./core/tests/TestSuites/BuildTestSuite.php</file>
</testsuite>
</testsuites>
<listeners>
<listener class="\Drupal\Tests\Listeners\DrupalListener">
</listener>
</listeners>
<!-- Settings for coverage reports. -->
<coverage>
<include>
<directory>./modules</directory>
</include>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
<directory>./modules/*/*/src/Tests</directory>
<directory>./modules/*/*/tests</directory>
<directory suffix=".api.php">./modules/**</directory>
</exclude>
</coverage>
</phpunit>
76 changes: 76 additions & 0 deletions 10/10.4/tests/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
schemaVersion: '2.0.0'
metadataTest:
envVars:
- key: 'DRUPAL_VER'
value: '10.4'
workdir: '/opt/drupal'
exposedPorts: ['80']
commandTests:
- name: 'Drupal Root location'
command: 'drush'
args: ['status']
expectedOutput: ['Drupal root\s+:\s+/opt/drupal/web']
- name: 'Drupal version'
command: 'drush'
args: ['status']
expectedOutput: ['Drupal version\s+:\s+10\.4\.(x|\d+)(-(alpha|beta|dev|rc))?']
- name: 'Drupal Core Dev version'
command: bash
args: ['-c', 'composer show drupal/core-dev']
expectedOutput: ['versions\s+:\s\* 10\.4\.(x|\d+)(-(alpha|beta|dev|rc))?']
- name: 'Drush location'
command: 'drush'
args: ['status']
expectedOutput: ['Drush script\s+:\s+/opt/drupal/vendor/bin/drush']
- name: 'Drush version'
command: 'drush'
args: ['status']
expectedOutput: ['Drush version\s+:\s+12\.\d\.\d']
- name: 'PHPUnit location'
command: 'which'
args: ['phpunit']
expectedOutput: ['/opt/drupal/vendor/bin/phpunit']
- name: 'PHPUnit version'
command: 'phpunit'
args: ['--version']
expectedOutput: ['^PHPUnit 9\.\d\.\d']
- name: 'PHPUnit configuration file should works'
command: 'phpunit'
args: ['-c', '/var/www/html/phpunit.xml', '--group', 'foo']
exitCode: 0
expectedOutput: [ 'No tests executed!' ]
excludedOutput: [ 'is not a writable directory.' ]
fileExistenceTests:
- name: 'Root'
path: '/'
shouldExist: true
permissions: 'drwxr-xr-x'
uid: 0
gid: 0
- name: 'PHPUnit default file'
path: '/opt/drupal/web/phpunit.xml'
shouldExist: true
- name: 'Wait-for-it script'
path: '/usr/local/bin/wait-for-it'
shouldExist: true
permissions: '-rwxr-xr-x'
uid: 0
gid: 0
- name: 'Drupal Root'
path: '/opt/drupal/web'
shouldExist: true
permissions: 'drwxr-xr-x'
uid: 0
gid: 0
- name: 'Drupal Public'
path: '/opt/drupal/web/sites/default'
shouldExist: true
permissions: 'drwxr-xr-x'
uid: 33
gid: 33
- name: 'Drupal PHPUnit Output'
path: '/opt/drupal/web/sites/default/files/simpletest/browser_output'
shouldExist: true
permissions: 'drwxr-xr-x'
uid: 33
gid: 33
33 changes: 33 additions & 0 deletions 10/10.4/tests/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e

if [[ -n "${DEBUG}" ]]; then
set -x
fi

if ! [ -x "$(command -v container-structure-test)" ]; then
echo -n "Install Google Container Structure Tests Framework for ${IMAGE} ..."

# Check install for Linux or MacOS.
if [[ $(uname -s) == Linux ]]
then
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
elif [[ $(uname -s) == Darwin ]]
then
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-darwin-amd64 && chmod +x container-structure-test-darwin-amd64 && sudo mv container-structure-test-darwin-amd64 /usr/local/bin/container-structure-test
fi
fi

if ! [ -x "$(command -v container-structure-test)" ]; then
echo 'Error: container-structure-test is not installed.' >&2
exit 1
fi

echo -n "Running tests for ${IMAGE}..."

cid="$(
docker run -d "${IMAGE}"
)"
trap "docker rm -vf ${cid} > /dev/null" EXIT

container-structure-test test --image ${IMAGE} --config config.yaml
4 changes: 4 additions & 0 deletions 11/11.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy a default template for PHPUnit testing.
COPY templates/phpunit.xml /opt/drupal/web/phpunit.xml

# Create the output directory for PHPUnit.
RUN mkdir -p /opt/drupal/web/sites/default/files/simpletest/browser_output
RUN chown www-data:www-data /opt/drupal/web/sites/default/files/simpletest/browser_output
2 changes: 1 addition & 1 deletion 11/11.0/templates/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
overridden by the value set for the "BROWSERTEST_OUTPUT_DIRECTORY"
environment variable.
-->
<parameter name="outputDirectory" value="sites/simpletest/browser_output"/>
<parameter name="outputDirectory" value="/opt/drupal/web/sites/default/files/simpletest/browser_output"/>
<!-- By default browser tests print the individual links in the test run
report. To avoid overcrowding the output in CI environments, you can
set the "verbose" parameter or the "BROWSERTEST_OUTPUT_VERBOSE"
Expand Down
3 changes: 3 additions & 0 deletions 11/11.0/tests/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ commandTests:
command: 'phpunit'
args: ['-c', '/var/www/html/phpunit.xml']
exitCode: 0
expectedOutput: [ 'No tests executed!' ]
excludedOutput: [ 'is not a writable directory.' ]
fileExistenceTests:
- name: 'Root'
path: '/'
Expand Down Expand Up @@ -70,3 +72,4 @@ fileExistenceTests:
permissions: 'drwxr-xr-x'
uid: 33
gid: 33

Loading

0 comments on commit 46b6c03

Please sign in to comment.