Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 164 additions & 17 deletions .github/workflows/behat-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,81 @@ jobs:
if: needs.changes.outputs.src != 'false'

strategy:
fail-fast: false
matrix:
php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
mariadb-versions: ['10.6', '10.11']
# Flat shard key so `act --matrix shard:sign` can select a single cell.
shard: [account-admin, file-notify, page-policies, sign]
include:
# Unique host ports per (shard, mariadb) so act matrix cells do not collide.
- shard: account-admin
mariadb-versions: '10.6'
paths: features/account features/admin features/bootstrap features/build
db_port: 4440
smtp_port: 1020
mail_ui_port: 8020
- shard: file-notify
mariadb-versions: '10.6'
paths: features/file features/identify-account features/notification
db_port: 4441
smtp_port: 1021
mail_ui_port: 8021
- shard: page-policies
mariadb-versions: '10.6'
paths: features/page features/policies features/settings
db_port: 4442
smtp_port: 1022
mail_ui_port: 8022
- shard: sign
mariadb-versions: '10.6'
paths: features/sign
db_port: 4443
smtp_port: 1023
mail_ui_port: 8023
- shard: account-admin
mariadb-versions: '10.11'
paths: features/account features/admin features/bootstrap features/build
db_port: 4450
smtp_port: 1030
mail_ui_port: 8030
- shard: file-notify
mariadb-versions: '10.11'
paths: features/file features/identify-account features/notification
db_port: 4451
smtp_port: 1031
mail_ui_port: 8031
- shard: page-policies
mariadb-versions: '10.11'
paths: features/page features/policies features/settings
db_port: 4452
smtp_port: 1032
mail_ui_port: 8032
- shard: sign
mariadb-versions: '10.11'
paths: features/sign
db_port: 4453
smtp_port: 1033
mail_ui_port: 8033

name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
name: MariaDB ${{ matrix.mariadb-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} (${{ matrix.shard }})

services:
mariadb:
image: ghcr.io/nextcloud/continuous-integration-mariadb-${{ matrix.mariadb-versions }}:latest
# act runs the job on host networking, so services must be reached via 127.0.0.1.
# Unique matrix.db_port avoids Bind collisions when act expands the matrix locally.
ports:
- 4444:3306/tcp
- ${{ matrix.db_port }}:3306/tcp
env:
MYSQL_ROOT_PASSWORD: rootpassword
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
options: --health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -prootpassword" --health-interval 5s --health-timeout 2s --health-retries 5
mailpit:
image: axllent/mailpit
ports:
- 8025:8025/tcp
- 1025:1025/tcp
- ${{ matrix.mail_ui_port }}:8025/tcp
- ${{ matrix.smtp_port }}:1025/tcp

steps:
- name: Set app env
Expand All @@ -85,7 +140,19 @@ jobs:
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

- name: Install system dependencies
run: sudo apt update && sudo apt install poppler-utils
run: |
# Ubuntu mirrors occasionally mid-sync under act ("unexpected size"); retry a few times.
for attempt in 1 2 3 4 5; do
if sudo apt-get update; then
break
fi
echo "apt-get update failed (attempt ${attempt}/5); waiting before retry..."
sleep $((attempt * 5))
if [ "$attempt" -eq 5 ]; then
exit 1
fi
done
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y poppler-utils procps

- name: Checkout server
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -102,6 +169,21 @@ jobs:
submodules: true
path: apps/${{ env.APP_NAME }}

# act often copies the worktree without initializing gitlinks; composer classmap needs 3rdparty/composer.
- name: Ensure LibreSign 3rdparty is present
working-directory: apps/${{ env.APP_NAME }}
run: |
if [ -d 3rdparty/composer ]; then
echo "3rdparty already present"
exit 0
fi
THIRDPARTY_SHA="$(git rev-parse HEAD:3rdparty 2>/dev/null || true)"
rm -rf 3rdparty
git clone https://github.com/LibreSign/3rdparty.git 3rdparty
if [ -n "$THIRDPARTY_SHA" ]; then
git -C 3rdparty checkout --force "$THIRDPARTY_SHA"
fi

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
with:
Expand All @@ -118,8 +200,8 @@ jobs:

- name: Enable ONLY_FULL_GROUP_BY MariaDB option
run: |
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P ${{ matrix.db_port }} -u root -prootpassword
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P ${{ matrix.db_port }} -u root -prootpassword

- name: Set up dependencies
working-directory: apps/${{ env.APP_NAME }}
Expand All @@ -129,8 +211,6 @@ jobs:
composer --working-dir=tests/integration install

- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
sudo echo "127.0.0.1 mailpit" | sudo tee -a /etc/hosts
mkdir data
Expand All @@ -139,7 +219,7 @@ jobs:
--database=mysql \
--database-name=nextcloud \
--database-host=127.0.0.1 \
--database-port=$DB_PORT \
--database-port=${{ matrix.db_port }} \
--database-user=root \
--database-pass=rootpassword \
--admin-user admin \
Expand All @@ -157,24 +237,91 @@ jobs:
./occ app:enable --force guests
./occ config:system:set allow_local_remote_servers --value true --type boolean
./occ config:system:set auth.bruteforce.protection.enabled --value false --type boolean
./occ config:system:set mail_smtphost --value mailpit
./occ config:system:set mail_smtpport --value 1025 --type integer
# SMTP: GHA reaches the service on container port 1025; act (host network) uses the published host port.
./occ config:system:set mail_smtpmode --value smtp
./occ config:system:set mail_sendmailmode --value smtp
./occ config:system:set mail_smtpauth --value false --type boolean
./occ config:system:set mail_from_address --value noreply
./occ config:system:set mail_domain --value example.com
if [ "${ACT}" = "true" ]; then
./occ config:system:set mail_smtphost --value 127.0.0.1
./occ config:system:set mail_smtpport --value ${{ matrix.smtp_port }} --type integer
else
./occ config:system:set mail_smtphost --value mailpit
./occ config:system:set mail_smtpport --value 1025 --type integer
fi
./occ config:system:set ratelimit.protection.enabled --value false --type boolean
./occ config:app:set dav enableDefaultContact --value false --type boolean
# Keep Host header and server bind on IPv4; localhost can resolve to ::1 only under Docker/act.
./occ config:system:set trusted_domains 0 --value=localhost
./occ config:system:set trusted_domains 1 --value=127.0.0.1
./occ config:system:set overwrite.cli.url --value=http://127.0.0.1

- name: Run behat
working-directory: apps/${{ env.APP_NAME }}/tests/integration
env:
BEHAT_ROOT_DIR: ../../../../
BEHAT_WORKERS: "0"
# Force IPv4 so server bind and Guzzle/cURL agree (avoids localhost → ::1 mismatch).
BEHAT_HOST: "127.0.0.1"
run: |
export BEHAT_RUN_AS=runner
export BEHAT_VERBOSE="$RUNNER_DEBUG"
vendor/bin/behat -f junit -f pretty --colors
# Replace PhpBuiltin's php -S with FrankenPHP for this Behat job only.
WRAP_BIN="$(./bin/ci-setup-frankenphp-behat-server.sh)"
export PATH="$WRAP_BIN:$PATH"
hash -r 2>/dev/null || true
# act images often lack procps and a runner user; RunServerListener needs both.
# FeatureContext also requires the Behat process UID to match BEHAT_RUN_AS / file owner.
if [ "${ACT}" = "true" ]; then
id -u runner >/dev/null 2>&1 || useradd -m -s /bin/bash runner
NC_ROOT="$(cd ../../../.. && pwd)"
chown -R runner:runner "$NC_ROOT"
# Under act (host networking) Mailpit is published on matrix.mail_ui_port, not :8025.
sed -i.bak "s|base_url: http://mailpit:8025|base_url: http://127.0.0.1:${{ matrix.mail_ui_port }}|" config/behat.yml
echo "Mailpit API preflight:"
curl -fsS "http://127.0.0.1:${{ matrix.mail_ui_port }}/api/v1/info" || {
echo "Mailpit UI not reachable on 127.0.0.1:${{ matrix.mail_ui_port }}"
exit 1
}
echo "Mailpit SMTP preflight:"
timeout 3 bash -c "echo >/dev/tcp/127.0.0.1/${{ matrix.smtp_port }}" || {
echo "Mailpit SMTP not reachable on 127.0.0.1:${{ matrix.smtp_port }}"
exit 1
}
# shellcheck disable=SC2086
# Drop GITHUB_ACTIONS so RunServerListener does not wrap the server start in sudo
# (behat already runs as runner; act's runner user has no passwordless sudo).
runuser -u runner -- env -u GITHUB_ACTIONS \
BEHAT_RUN_AS=runner \
BEHAT_ROOT_DIR=../../../../ \
BEHAT_HOST=127.0.0.1 \
BEHAT_WORKERS=0 \
BEHAT_VERBOSE=1 \
HOME=/home/runner \
PATH="$PATH" \
vendor/bin/behat -f junit -f pretty --colors -v ${{ matrix.paths }}
else
export BEHAT_RUN_AS=runner
export BEHAT_HOST=127.0.0.1
export BEHAT_VERBOSE="$RUNNER_DEBUG"
# shellcheck disable=SC2086
vendor/bin/behat -f junit -f pretty --colors ${{ matrix.paths }}
fi

- name: Print logs
if: always()
run: |
cat data/nextcloud.log
echo "=== Behat web server processes ==="
if command -v ps >/dev/null 2>&1; then
ps aux | grep -E '[p]hp -S|[f]rankenphp' || echo "No Behat web server process"
else
echo "ps not installed (Install system dependencies may have failed earlier)"
fi
echo "=== nextcloud.log (tail) ==="
if [ -f data/nextcloud.log ]; then
tail -n 80 data/nextcloud.log
else
echo "No nextcloud.log yet"
fi

summary:
permissions:
Expand Down
Loading
Loading