-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
682 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# https://github.com/docker-library/drupal/blob/master/10.0-rc/php8.1/apache-buster/Dockerfile | ||
FROM drupal:10.0-rc-php8.1 | ||
|
||
LABEL maintainer="dev-drupal.com" | ||
LABEL org.label-schema.schema-version="1.0" | ||
LABEL org.label-schema.name="gitlab-ci-drupal/drupal-ci-images" | ||
LABEL org.label-schema.description="Drupal CI images for project https://gitlab.com/mog33/gitlab-ci-drupal" | ||
LABEL org.label-schema.url="https://mog33.gitlab.io/gitlab-ci-drupal" | ||
LABEL org.label-schema.vcs-url="https://gitlab.com/gitlab-ci-drupal/drupal-ci-images" | ||
LABEL org.label-schema.vendor="dev-drupal.com" | ||
|
||
# Install needed programs. | ||
RUN apt-get update && apt-get install --no-install-recommends -y \ | ||
apt-transport-https \ | ||
bc \ | ||
ca-certificates \ | ||
curl \ | ||
gettext-base \ | ||
git \ | ||
gnupg2 \ | ||
jq \ | ||
software-properties-common \ | ||
ssh \ | ||
sudo \ | ||
unzip \ | ||
vim \ | ||
xsltproc \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
#================== | ||
# Install Nodejs, Yarn. | ||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \ | ||
&& curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ | ||
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ | ||
&& apt-get update && apt-get install --no-install-recommends -y \ | ||
nodejs \ | ||
yarn \ | ||
# Required for Drush sql commands. | ||
mariadb-client \ | ||
postgresql-client \ | ||
# Install PHP extensions. | ||
libicu-dev \ | ||
imagemagick \ | ||
libmagickwand-dev \ | ||
libnss3-dev \ | ||
libssl-dev \ | ||
libxslt-dev \ | ||
# https://github.com/mlocati/docker-php-extension-installer | ||
&& docker-php-ext-install intl xsl mysqli bcmath calendar sockets pcntl opcache exif ftp \ | ||
&& pecl channel-update pecl.php.net && pecl install imagick xdebug \ | ||
&& docker-php-ext-enable imagick xdebug \ | ||
# Cleanup. | ||
&& docker-php-source delete \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
#================== | ||
# Install composer third party. | ||
RUN /usr/local/bin/composer selfupdate | ||
COPY --chown=www-data:www-data composer.json /var/www/.composer/composer.json | ||
|
||
USER www-data | ||
|
||
# Manage Composer. | ||
WORKDIR /var/www/.composer | ||
|
||
# Install our tools, see composer.json | ||
RUN COMPOSER_MEMORY_LIMIT=-1 composer install -n \ | ||
&& composer clear-cache | ||
|
||
WORKDIR /opt/drupal | ||
|
||
USER root | ||
|
||
#================== | ||
# Install Drupal core:dev, Drush for a module. | ||
# @todo remove phpspec/prophecy-phpunit when Drupal 9 is deprecated. | ||
RUN COMPOSER_MEMORY_LIMIT=-1 \ | ||
composer require -n --dev --working-dir="/opt/drupal" \ | ||
"drupal/core-dev:10.0.x-dev" "drush/drush:^11" "phpspec/prophecy-phpunit:^2" \ | ||
&& composer clear-cache | ||
|
||
#================== | ||
# Include testing code. | ||
COPY --chown=www-data:www-data ./tests/ /tests/ | ||
|
||
#================== | ||
# Manage final tasks. | ||
RUN chmod 777 /var/www \ | ||
&& chown -R www-data:www-data /var/www \ | ||
# Symlink composer downloaded binaries. | ||
&& ln -sf /var/www/.composer/vendor/bin/* /usr/local/bin \ | ||
# Phpunit 9+ cache. | ||
&& chown www-data:www-data /opt/drupal/web/core \ | ||
# Tests scripts. | ||
&& chmod +x /tests/*.sh \ | ||
# Fix Php performances. | ||
&& mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ | ||
&& sed -i "s#memory_limit = 128M#memory_limit = 4G#g" /usr/local/etc/php/php.ini \ | ||
&& sed -i "s#max_execution_time = 30#max_execution_time = 90#g" /usr/local/etc/php/php.ini \ | ||
&& sed -i "s#;max_input_nesting_level = 64#max_input_nesting_level = 512#g" /usr/local/etc/php/php.ini \ | ||
# Convenient alias for root and www-data. | ||
&& echo "alias ls='ls --color=auto -lAh'" >> /root/.bashrc \ | ||
&& echo "alias l='ls --color=auto -lAh'" >> /root/.bashrc \ | ||
&& echo "alias dr='drush --root=/opt/drupal/web'" >> /root/.bashrc \ | ||
&& cp /root/.bashrc /var/www/.bashrc \ | ||
&& chown www-data:www-data /var/www/.bashrc | ||
|
||
#================== | ||
# Stay as root becasue it's a ci image. | ||
# For obvious security reason, this image is NOT meant to be used by any production system. | ||
# USER www-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "mog33/drupal8ci", | ||
"description": "Packages for CI with Drupal 10.0-rc for https://gitlab.com/mog33/drupal8ci.", | ||
"type": "project", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"edgedesign/phpqa": "^1.25", | ||
"consolidation/robo": "^3", | ||
"drupal/coder": "^8.3", | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7", | ||
"phpstan/phpstan": "^1.4", | ||
"phpstan/extension-installer": "^1.1", | ||
"phpstan/phpstan-deprecation-rules": "^1.0", | ||
"mglaman/phpstan-drupal": "^1.1", | ||
"php-parallel-lint/php-parallel-lint": "^1.3" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"phpstan/extension-installer": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
_install_packages() { | ||
|
||
if ! [ -x "$(command -v python3)" ]; then | ||
if [ -f "/etc/alpine-release" ]; then | ||
apk add --no-cache --no-progress --quiet python3 | ||
else | ||
apt update && apt install -y python3 | ||
fi | ||
fi | ||
|
||
if ! [ -x "$(command -v pip3)" ]; then | ||
# https://pip.pypa.io/en/stable/installing/ | ||
curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py | ||
python3 get-pip.py --quiet | ||
fi | ||
|
||
if [ -f "/etc/alpine-release" ]; then | ||
# nettoolsis needed for infratest 'socket' using netstat. | ||
# default one on Alpine (busybox) is a limited versions. | ||
apk add --no-cache --no-progress --quiet net-tools | ||
fi | ||
} | ||
|
||
_install_testinfra() { | ||
if ! [ -x "$(command -v pytest)" ]; then | ||
# https://github.com/pytest-dev/pytest-testinfra | ||
pip3 install pytest-testinfra --quiet | ||
fi | ||
} | ||
|
||
_main() { | ||
echo -e "[notice] Install packages for tests..." | ||
_install_packages | ||
_install_testinfra | ||
echo -e "[notice] Done!" | ||
} | ||
|
||
# Call `_main` after everything has been defined. | ||
_main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
console_output_style = classic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
testinfra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
def test_composer(host): | ||
assert host.check_output('composer -V').startswith('Composer version 2') | ||
assert host.file("/var/www/.composer/composer.json").exists | ||
|
||
@pytest.mark.parametrize("bin", [ | ||
("parallel-lint"), | ||
("pdepend"), | ||
("phpcs"), | ||
("phploc"), | ||
("phpmd"), | ||
("phpmetrics"), | ||
("phpqa"), | ||
("phpstan"), | ||
("robo"), | ||
]) | ||
def test_composer_bin(host, bin): | ||
''' Test bin exist ''' | ||
assert host.file("/var/www/.composer/vendor/bin/" + bin).exists | ||
assert host.file("/usr/local/bin/" + bin).is_symlink | ||
assert host.file("/usr/local/bin/" + bin).mode == 0o777 | ||
|
||
def test_phpcs_standard(host): | ||
'''' Test phpcs standards ''' | ||
assert host.check_output('phpcs -i').__contains__('Drupal') | ||
assert host.check_output('phpcs -i').__contains__('DrupalPractice') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
|
||
def test_drush(host): | ||
''' Test drush exist ''' | ||
assert host.file("/opt/drupal/vendor/bin/drush").exists | ||
assert host.file("/opt/drupal/vendor/bin/drush").mode == 0o755 | ||
assert host.check_output("drush --version").startswith("Drush Commandline Tool") | ||
assert host.check_output("drush --root=/opt/drupal/web status --field=drupal-version").startswith("10.0-rc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
@pytest.mark.parametrize("name", [ | ||
("bash"), | ||
("bc"), | ||
("curl"), | ||
("git"), | ||
("jq"), | ||
("gettext-base"), | ||
("ssh"), | ||
("xsltproc"), | ||
("mariadb-client"), | ||
("postgresql-client"), | ||
("nodejs"), | ||
("yarn"), | ||
]) | ||
def test_packages_installed(host, name): | ||
''' Test a minimum of required packages ''' | ||
pkg = host.package(name) | ||
assert pkg.is_installed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
@pytest.mark.parametrize("folder", [ | ||
("/opt/drupal/web/core"), | ||
("/opt/drupal/web/modules"), | ||
("/opt/drupal/web/themes"), | ||
("/opt/drupal/web/sites"), | ||
("/var/www"), | ||
]) | ||
def test_permissions(host, folder): | ||
''' Test folder permissions ''' | ||
assert host.file(folder).user == "www-data" | ||
assert host.file(folder).group == "www-data" |
Oops, something went wrong.