mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-06-10 00:27:01 +00:00
Enable running playwright tests locally
They now are running via a docker compose setup, which can be executed via ./php/tests/run.sh locally, and also gets called from the github workflow. Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
FROM docker.io/library/composer:latest
|
||||||
|
|
||||||
|
RUN pecl bundle -d /usr/src/php/ext apcu \
|
||||||
|
&& docker-php-ext-install apcu
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
# This setup expects that you run the services via profiles!
|
||||||
|
# Usage: docker compose --profile local-code up
|
||||||
|
# or: docker compose --profile code-from-image up
|
||||||
|
|
||||||
|
name: nextcloud-aio
|
||||||
|
services:
|
||||||
|
composer:
|
||||||
|
image: localhost/composer:latest
|
||||||
|
build: Containers/composer
|
||||||
|
pull_policy: never
|
||||||
|
volumes:
|
||||||
|
- ..:/app
|
||||||
|
working_dir: /app
|
||||||
|
command: |-
|
||||||
|
bash -c '
|
||||||
|
test -d ./data && rm -r ./data
|
||||||
|
test -d ./session && rm -r ./session
|
||||||
|
composer install --no-dev
|
||||||
|
composer clear-cache
|
||||||
|
'
|
||||||
|
app-base:
|
||||||
|
image: ghcr.io/nextcloud-releases/all-in-one:develop${ARM64_SUFFIX-}
|
||||||
|
pull_policy: always # Always pull so we don't risk to run into the "Update for mastercontainer" page.
|
||||||
|
init: true
|
||||||
|
restart: always
|
||||||
|
network_mode: bridge
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
- backup_vol:/mnt/test
|
||||||
|
profiles:
|
||||||
|
- none
|
||||||
|
environment:
|
||||||
|
SKIP_DOMAIN_VALIDATION: ${SKIP_DOMAIN_VALIDATION-true}
|
||||||
|
APACHE_PORT: 11000
|
||||||
|
entrypoint: bash /start.sh
|
||||||
|
|
||||||
|
app-code-from-image:
|
||||||
|
extends: app-base
|
||||||
|
container_name: nextcloud-aio-mastercontainer
|
||||||
|
profiles:
|
||||||
|
- code-from-image
|
||||||
|
|
||||||
|
app-local-code:
|
||||||
|
extends: app-base
|
||||||
|
container_name: nextcloud-aio-mastercontainer
|
||||||
|
depends_on:
|
||||||
|
composer:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
volumes:
|
||||||
|
- ..:/var/www/docker-aio/php
|
||||||
|
- ../../Containers/mastercontainer/internal.Caddyfile:/internal.Caddyfile
|
||||||
|
- ../../Containers/mastercontainer/headers.Caddyfile:/headers.Caddyfile
|
||||||
|
- ../../Containers/mastercontainer/start.sh:/start.sh
|
||||||
|
profiles:
|
||||||
|
- local-code
|
||||||
|
|
||||||
|
test-runner-base:
|
||||||
|
image: mcr.microsoft.com/playwright:v1.56.1
|
||||||
|
volumes:
|
||||||
|
- ..:/app
|
||||||
|
working_dir: /app
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
ports:
|
||||||
|
- '9323:9323' # to view test reports
|
||||||
|
profiles:
|
||||||
|
- none
|
||||||
|
environment:
|
||||||
|
BASE_URL: "https://host.docker.internal:8080"
|
||||||
|
DEBUG: "pw:api"
|
||||||
|
command: |-
|
||||||
|
bash -c "
|
||||||
|
cd tests
|
||||||
|
# Install dependencies
|
||||||
|
npm ci
|
||||||
|
# Run the initial setup tests
|
||||||
|
npx playwright test "${TESTS_FILE-}"
|
||||||
|
exit $?
|
||||||
|
"
|
||||||
|
|
||||||
|
test-runner-code-from-image:
|
||||||
|
extends: test-runner-base
|
||||||
|
container_name: test-runner
|
||||||
|
profiles:
|
||||||
|
- code-from-image
|
||||||
|
depends_on:
|
||||||
|
app:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
|
||||||
|
test-runner-local-code:
|
||||||
|
extends: test-runner-base
|
||||||
|
container_name: test-runner
|
||||||
|
profiles:
|
||||||
|
- local-code
|
||||||
|
depends_on:
|
||||||
|
app-local-code:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
nextcloud_aio_mastercontainer:
|
||||||
|
name: nextcloud_aio_mastercontainer
|
||||||
|
backup_vol:
|
||||||
|
|
||||||
Executable
+62
@@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ "$1" = -* ]]; then
|
||||||
|
echo "Usage $(basename $0) [PLAYWRIGHT_TESTS_FILE]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $(dirname $0)/../..
|
||||||
|
|
||||||
|
DOCO="docker compose -f ./php/tests/compose.yaml"
|
||||||
|
|
||||||
|
if [[ $(uname -m) = 'arm64' ]]; then
|
||||||
|
export ARM64_SUFFIX='-arm64'
|
||||||
|
fi
|
||||||
|
|
||||||
|
run_tests() {
|
||||||
|
export TESTS_FILE="$1"
|
||||||
|
export SKIP_DOMAIN_VALIDATION
|
||||||
|
|
||||||
|
if [[ -n "$TEST_CODE_FROM_IMAGE" ]]; then
|
||||||
|
profile="code-from-image"
|
||||||
|
else
|
||||||
|
profile="local-code"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up old containers and volumes
|
||||||
|
docker container rm --force nextcloud-aio-{mastercontainer,apache,notify-push,nextcloud,redis,database,domaincheck,whiteboard,imaginary,talk,collabora,borgbackup} > /dev/null 2>&1
|
||||||
|
docker volume rm nextcloud_aio_{mastercontainer,apache,database,database_dump,nextcloud,nextcloud_data,redis,backup_cache,elasticsearch} > /dev/null 2>&1
|
||||||
|
$DOCO --profile $profile down -v
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo -e "\n 📣 Running playwright tests for ${TESTS_FILE}\n"
|
||||||
|
if ! $DOCO --profile $profile run --remove-orphans test-runner-$profile; then
|
||||||
|
for container in nextcloud-aio-{mastercontainer,borgbackup}; do
|
||||||
|
if docker container list --format="{{ .Names }}" | grep -q "$container"; then
|
||||||
|
echo -e "\n 📣 Log output from container ${container}:\n"
|
||||||
|
docker logs nextcloud-aio-mastercontainer
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
if [[ ! -f "$1" ]]; then
|
||||||
|
echo "Error: file '$1' does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Not using coreutil's `realpath --relative-to` here since that is not available on BSD/mac systems.
|
||||||
|
fullpath="$(realpath "$1")"
|
||||||
|
prefix="$(realpath ./php/tests)"
|
||||||
|
relpath="${fullpath#"$prefix"/}"
|
||||||
|
|
||||||
|
: ${SKIP_DOMAIN_VALIDATION:-false}
|
||||||
|
run_tests "$relpath"
|
||||||
|
else
|
||||||
|
SKIP_DOMAIN_VALIDATION=true
|
||||||
|
run_tests tests/initial-setup.spec.js
|
||||||
|
sleep 1
|
||||||
|
SKIP_DOMAIN_VALIDATION=false
|
||||||
|
run_tests tests/restore-instance.spec.js
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user