Browse Source
Docker compose for testing (#9525)
Docker compose for testing (#9525)
* More ignore-patterns in eslint config So we don't have to specify them on the command line when we check codestyle locally. * Test setup for local and CI using containers It uses standalone containers for the greenmail IMAP server and the standalone browser. A testrunner image is built in the CI (for `linux/amd64` only, because Github doesn't support multi-platform building on their default runners and we don't have our own.) This setup helps to run the tests (reproduceably) also locally. Previously, on my machine, they produced varying results. It also reduces the dependencies for running the browser test. Local execution only depends on `docker compose`, no other tools (previously it required `sudo`, `java`, and some more.) The previous solution should still work, if you want it. The scripts are stored in a directory called `.ci` to hide them a little and avoid confusion with the container images from the `roundcubemail-docker` repo. * Fix UI tests by waiting for element before using it This only was a flaky problem only occurring sometimes. * Force a new IMAP connection in plugin tests, too In other code the initial connection is forced. Doing this here, too, fixes occasional problems with lost imap connections. * Make waiting for zipfile's content more robust * CI: Run tests from script on Windows, too * CI: Do start local chrome if no connect URL is given * Move compose.yml to tests/ This way it's less easy mistaken as usable for running Roundcubemail in production. * Move compose.yml to .ci/pull/9552/head

committed by
GitHub

No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 357 additions and 117 deletions
-
58.ci/compose.yaml
-
16.ci/config-test.inc.php
-
48.ci/docker-images/Dockerfile
-
14.ci/docker-images/build.sh
-
59.ci/run_browser_tests.sh
-
19.ci/run_tests.sh
-
5.eslintrc.js
-
39.github/run.sh
-
58.github/workflows/browser_tests.yml
-
48.github/workflows/docker_image.yml
-
43.github/workflows/tests.yml
-
3plugins/archive/tests/Browser/MailTest.php
-
2plugins/markasjunk/tests/Browser/MailTest.php
-
37plugins/zipdownload/tests/Browser/MailTest.php
-
11tests/Browser/Browser.php
-
14tests/Browser/TestCase.php
-
0tests/Browser/downloads/.keep
@ -0,0 +1,58 @@ |
|||
services: |
|||
mailhost: |
|||
image: docker.io/greenmail/standalone |
|||
browserhost: |
|||
image: docker.io/selenium/standalone-chromium |
|||
volumes: |
|||
- '/dev/shm:/dev/shm' |
|||
- './Browser/downloads:/downloads' |
|||
|
|||
browser_tests: |
|||
depends_on: |
|||
- mailhost |
|||
- browserhost |
|||
hostname: 'testrunner' |
|||
image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3 |
|||
volumes: |
|||
- '..:/app' |
|||
- './Browser/downloads:/downloads' |
|||
environment: |
|||
WEBDRIVER_CONNECT_URL: 'http://browserhost:4444' |
|||
SERVER_URL: 'http://testrunner:8000' |
|||
SERVER_BIND: '0.0.0.0:8000' |
|||
BROWSER_DOWNLOADS_DIR: '/downloads' |
|||
TESTRUNNER_DOWNLOADS_DIR: './Browser/downloads' |
|||
RC_CONFIG_IMAP_HOST: 'tls://mailhost:3143' |
|||
RC_CONFIG_SMTP_HOST: 'mailhost:3025' |
|||
command: |
|||
- .ci/run_browser_tests.sh |
|||
|
|||
tests: |
|||
depends_on: |
|||
- mailhost |
|||
image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3 |
|||
volumes: |
|||
- '..:/app' |
|||
command: |
|||
- .ci/run_tests.sh |
|||
|
|||
codespell: |
|||
image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3 |
|||
volumes: |
|||
- '..:/app' |
|||
command: |
|||
- vendor/bin/php-cs-fixer |
|||
- fix |
|||
- --dry-run |
|||
- --using-cache=no |
|||
- --diff |
|||
- --verbose |
|||
|
|||
codestyle: |
|||
image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3 |
|||
volumes: |
|||
- '..:/app' |
|||
command: |
|||
- npx |
|||
- eslint |
|||
- . |
@ -0,0 +1,48 @@ |
|||
ARG PHPVERSION=8.3 |
|||
FROM php:${PHPVERSION}-cli |
|||
|
|||
ENV DEBIAN_FRONTEND=noninteractive |
|||
|
|||
RUN apt-get update \ |
|||
&& apt-get install -y --no-install-recommends \ |
|||
libfreetype6-dev \ |
|||
libicu-dev \ |
|||
libjpeg62-turbo-dev \ |
|||
libldap2-dev \ |
|||
libpng-dev \ |
|||
libpq-dev \ |
|||
libsqlite3-dev \ |
|||
libzip-dev \ |
|||
libpspell-dev \ |
|||
libonig-dev \ |
|||
libldap-common \ |
|||
libenchant-2-dev \ |
|||
nodejs \ |
|||
npm \ |
|||
aspell \ |
|||
aspell-en \ |
|||
aspell-de \ |
|||
hunspell-en-us \ |
|||
git \ |
|||
&& apt-get clean |
|||
|
|||
# TODO: Do we need the multiarch-args? What for? |
|||
#RUN debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \ |
|||
RUN docker-php-ext-configure gd --with-jpeg --with-freetype \ |
|||
#&& docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch" \ |
|||
&& docker-php-ext-configure ldap \ |
|||
&& docker-php-ext-install \ |
|||
zip \ |
|||
pcntl \ |
|||
gd \ |
|||
ldap \ |
|||
intl \ |
|||
pspell \ |
|||
enchant |
|||
|
|||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer |
|||
|
|||
# Create working directory |
|||
WORKDIR /app |
|||
|
|||
VOLUME /app |
@ -0,0 +1,14 @@ |
|||
#!/bin/bash |
|||
|
|||
case "$1" in |
|||
8.1|8.3) |
|||
phpversion="$1" |
|||
;; |
|||
*) |
|||
echo "Error: first and only argument must be the wanted PHP version." |
|||
echo "Usage: $(basename $0) 8.1|8.3" |
|||
exit 1 |
|||
;; |
|||
esac |
|||
|
|||
exec docker build --build-arg "PHPVERSION=$phpversion" -f "$(realpath $(dirname $0)/Dockerfile)" -t "ghcr.io/pabzm/roundcubemail-testrunner:php$phpversion" "$(realpath $(dirname $0)/../../..)" |
@ -0,0 +1,59 @@ |
|||
#!/bin/bash -ex |
|||
|
|||
# The script is intended for use locally, as well as in the CI. |
|||
# It runs the browser-tests ("E2E" in the CI). |
|||
# It expects a running IMAP server (connection configured in |
|||
# `config-test.inc.php`, and a running Chrome/Chromium browser (connection |
|||
# hard-coded in code, overrideable via environment variables). |
|||
|
|||
# Make temp and logs writeable to everyone. |
|||
chmod 777 temp logs |
|||
|
|||
# Create downloads dir and ensure permissions (if it's set, the variable might |
|||
# be blank if tests are not run using containers). |
|||
if test -n "$TESTRUNNER_DOWNLOADS_DIR"; then |
|||
# Use sudo because in the Github action we apparently can't use a |
|||
# directory in $HOME or /tmp but another one for which we need |
|||
# superuser-rights. |
|||
install -m 777 -d "$TESTRUNNER_DOWNLOADS_DIR" |
|||
fi |
|||
|
|||
if ! test -f config/config-test.inc.php; then |
|||
cp -v .ci/config-test.inc.php config/config-test.inc.php |
|||
fi |
|||
|
|||
# Install dependencies for to remote control the browser. |
|||
composer require -n "nesbot/carbon:^2.62.1" --no-update |
|||
composer require -n "laravel/dusk:^7.9" --no-update |
|||
|
|||
if $(echo $PHP_VERSION | grep -q '^8.3'); then |
|||
# Downgrade dependencies (for PHP 8.3 only) |
|||
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress --optimize-autoloader |
|||
else |
|||
composer update --prefer-dist --no-interaction --no-progress |
|||
fi |
|||
|
|||
# Install development tools. |
|||
npm install |
|||
|
|||
# Install javascript dependencies |
|||
bin/install-jsdeps.sh |
|||
|
|||
# Compile Elastic's styles |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/styles.less > skins/elastic/styles/styles.min.css |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/print.less > skins/elastic/styles/print.min.css |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/embed.less > skins/elastic/styles/embed.min.css |
|||
|
|||
# Use minified javascript files |
|||
bin/jsshrink.sh |
|||
|
|||
# Run tests |
|||
echo "TESTS_MODE: DESKTOP" |
|||
TESTS_MODE=desktop vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga |
|||
|
|||
echo "TESTS_MODE: TABLET" |
|||
TESTS_MODE=tablet vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga-tablet |
|||
|
|||
# Mobile mode tests are unreliable on Github Actions |
|||
# echo "TESTS_MODE: PHONE" |
|||
# TESTS_MODE=phone vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga-phone |
@ -0,0 +1,19 @@ |
|||
#!/bin/bash -ex |
|||
|
|||
if ! test -f config/config-test.inc.php; then |
|||
cp -v .ci/config-test.inc.php config/config-test.inc.php |
|||
fi |
|||
|
|||
composer require "kolab/net_ldap3:~1.1.4" --no-update |
|||
|
|||
# Install dependencies, prefer highest. |
|||
composer update --prefer-dist --no-interaction --no-progress |
|||
|
|||
# Execute tests. |
|||
vendor/bin/phpunit -c tests/phpunit.xml --fail-on-warning --fail-on-risky |
|||
|
|||
# Downgrade dependencies to the lowest versions. |
|||
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress --optimize-autoloader |
|||
|
|||
# Execute tests again. |
|||
vendor/bin/phpunit -c tests/phpunit.xml --fail-on-warning --fail-on-risky |
@ -1,39 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
# The script is intended for use on Travis with Trusty distribution |
|||
# It installs in-browser tests dependencies and prepares Roundcube instance |
|||
|
|||
GMV=1.6.13 |
|||
CHROMEVERSION=$(google-chrome-stable --version | tr -cd [:digit:].) |
|||
GMARGS="-Dgreenmail.setup.all -Dgreenmail.users=test:test -Dgreenmail.startup.timeout=3000" |
|||
|
|||
# Make temp and logs writeable |
|||
sudo chmod 777 temp logs |
|||
|
|||
# Install javascript dependencies |
|||
bin/install-jsdeps.sh |
|||
|
|||
# Compile Elastic's styles |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/styles.less > skins/elastic/styles/styles.min.css |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/print.less > skins/elastic/styles/print.min.css |
|||
npx lessc --clean-css="--s1 --advanced" skins/elastic/styles/embed.less > skins/elastic/styles/embed.min.css |
|||
|
|||
# Use minified javascript files |
|||
bin/jsshrink.sh |
|||
|
|||
# Install proper WebDriver version for installed Chrome browser |
|||
php tests/Browser/install.php $CHROMEVERSION |
|||
|
|||
# GreenMail server download, setup and start |
|||
wget -q https://repo1.maven.org/maven2/com/icegreen/greenmail-standalone/$GMV/greenmail-standalone-$GMV.jar \ |
|||
&& (sudo java $GMARGS -jar greenmail-standalone-$GMV.jar &) \ |
|||
&& sleep 10 |
|||
|
|||
# Run tests |
|||
echo "TESTS_MODE: DESKTOP" \ |
|||
&& TESTS_MODE=desktop vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga \ |
|||
&& echo "TESTS_MODE: TABLET" \ |
|||
&& TESTS_MODE=tablet vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga-tablet \ |
|||
# Mobile mode tests are unreliable on Github Actions |
|||
# && echo "TESTS_MODE: PHONE" \ |
|||
# && TESTS_MODE=phone vendor/bin/phpunit -c tests/Browser/phpunit.xml --fail-on-warning --fail-on-risky --exclude-group=failsonga-phone \ |
@ -0,0 +1,48 @@ |
|||
name: roundcubemail-testrunner image |
|||
|
|||
on: |
|||
push: |
|||
paths: |
|||
- '.ci/docker-images/*' |
|||
- '.github/workflows/docker_image.yml' |
|||
|
|||
jobs: |
|||
build_and_push: |
|||
strategy: |
|||
fail-fast: false |
|||
# Set up a matrix so we can add more versions to build with in the future. |
|||
matrix: |
|||
php: ["8.3"] |
|||
|
|||
name: build and push with PHP ${{ matrix.php }} |
|||
runs-on: ubuntu-latest |
|||
# Set the permissions granted to the GITHUB_TOKEN for the actions in this job. |
|||
permissions: |
|||
contents: read |
|||
packages: write |
|||
attestations: write |
|||
id-token: write |
|||
steps: |
|||
- name: Check actor permission |
|||
uses: skjnldsv/check-actor-permission@v2 |
|||
with: |
|||
require: admin |
|||
- name: Check out the repo |
|||
uses: actions/checkout@v4 |
|||
- name: Log in to the Container registry |
|||
uses: docker/login-action@v1 |
|||
with: |
|||
registry: ghcr.io |
|||
username: ${{ github.actor }} |
|||
password: ${{ secrets.GITHUB_TOKEN }} |
|||
- name: Build and push Docker image |
|||
id: push |
|||
uses: docker/build-push-action@v2 |
|||
with: |
|||
context: . |
|||
file: ./.ci/docker-images/Dockerfile |
|||
push: true |
|||
#platforms: linux/amd64,linux/arm64 |
|||
build-args: PHPVERSION=${{ matrix.php }} |
|||
tags: "ghcr.io/roundcube/roundcubemail-testrunner:php${{ matrix.php }}" |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue