diff --git a/.github/workflows/behat-mariadb.yml b/.github/workflows/behat-mariadb.yml index 970ced3a0a..cbafac80c9 100644 --- a/.github/workflows/behat-mariadb.yml +++ b/.github/workflows/behat-mariadb.yml @@ -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 @@ -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 @@ -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: @@ -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 }} @@ -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 @@ -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 \ @@ -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: diff --git a/.github/workflows/behat-mysql.yml b/.github/workflows/behat-mysql.yml index 4e22bb4ff5..77becd4cd8 100644 --- a/.github/workflows/behat-mysql.yml +++ b/.github/workflows/behat-mysql.yml @@ -61,26 +61,52 @@ 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) }} mysql-versions: ['8.1'] + # Flat shard key so `act --matrix shard:sign` can select a single cell. + shard: [account-admin, file-notify, page-policies, sign] + include: + - shard: account-admin + paths: features/account features/admin features/bootstrap features/build + db_port: 4440 + smtp_port: 1020 + mail_ui_port: 8020 + - shard: file-notify + paths: features/file features/identify-account features/notification + db_port: 4441 + smtp_port: 1021 + mail_ui_port: 8021 + - shard: page-policies + paths: features/page features/policies features/settings + db_port: 4442 + smtp_port: 1022 + mail_ui_port: 8022 + - shard: sign + paths: features/sign + db_port: 4443 + smtp_port: 1023 + mail_ui_port: 8023 - name: MySQL ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} + name: MySQL ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} (${{ matrix.shard }}) services: mysql: image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-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 10 + options: --health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -prootpassword" --health-interval 5s --health-timeout 2s --health-retries 10 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 @@ -89,7 +115,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 @@ -106,6 +144,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: @@ -122,8 +175,8 @@ jobs: - name: Enable ONLY_FULL_GROUP_BY MySQL 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: Check composer file existence id: check_composer @@ -141,8 +194,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 @@ -151,7 +202,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 \ @@ -169,24 +220,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: diff --git a/.github/workflows/behat-pgsql.yml b/.github/workflows/behat-pgsql.yml index abced51068..f912845329 100644 --- a/.github/workflows/behat-pgsql.yml +++ b/.github/workflows/behat-pgsql.yml @@ -59,17 +59,43 @@ 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) }} + # Flat shard key so `act --matrix shard:sign` can select a single cell. + shard: [account-admin, file-notify, page-policies, sign] + include: + - shard: account-admin + paths: features/account features/admin features/bootstrap features/build + db_port: 4440 + smtp_port: 1020 + mail_ui_port: 8020 + - shard: file-notify + paths: features/file features/identify-account features/notification + db_port: 4441 + smtp_port: 1021 + mail_ui_port: 8021 + - shard: page-policies + paths: features/page features/policies features/settings + db_port: 4442 + smtp_port: 1022 + mail_ui_port: 8022 + - shard: sign + paths: features/sign + db_port: 4443 + smtp_port: 1023 + mail_ui_port: 8023 - name: PostgreSQL PHP ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} + name: PostgreSQL PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} (${{ matrix.shard }}) services: postgres: image: ghcr.io/nextcloud/continuous-integration-postgres-14: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:5432/tcp + - ${{ matrix.db_port }}:5432/tcp env: POSTGRES_USER: root POSTGRES_PASSWORD: rootpassword @@ -78,8 +104,8 @@ jobs: 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 @@ -88,7 +114,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 @@ -105,6 +143,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: @@ -135,8 +188,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 @@ -145,7 +196,7 @@ jobs: --database=pgsql \ --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 \ @@ -163,24 +214,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: diff --git a/.github/workflows/behat-sqlite.yml b/.github/workflows/behat-sqlite.yml index 3bf7c3aaff..ba353e399a 100644 --- a/.github/workflows/behat-sqlite.yml +++ b/.github/workflows/behat-sqlite.yml @@ -59,18 +59,39 @@ 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) }} + # Flat shard key so `act --matrix shard:sign` can select a single cell. + shard: [account-admin, file-notify, page-policies, sign] + include: + - shard: account-admin + paths: features/account features/admin features/bootstrap features/build + smtp_port: 1020 + mail_ui_port: 8020 + - shard: file-notify + paths: features/file features/identify-account features/notification + smtp_port: 1021 + mail_ui_port: 8021 + - shard: page-policies + paths: features/page features/policies features/settings + smtp_port: 1022 + mail_ui_port: 8022 + - shard: sign + paths: features/sign + smtp_port: 1023 + mail_ui_port: 8023 - name: SQLite PHP ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} + name: SQLite PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }} (${{ matrix.shard }}) services: mailpit: image: axllent/mailpit + # act runs the job on host networking; unique ports avoid Bind collisions locally. ports: - - 8025:8025/tcp - - 1025:1025/tcp + - ${{ matrix.mail_ui_port }}:8025/tcp + - ${{ matrix.smtp_port }}:1025/tcp steps: - name: Set app env @@ -79,7 +100,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 @@ -96,6 +129,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: @@ -126,8 +174,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 @@ -136,7 +182,7 @@ jobs: --database=sqlite \ --database-name=nextcloud \ --database-host=127.0.0.1 \ - --database-port=$DB_PORT \ + --database-port=4444 \ --database-user=root \ --database-pass=rootpassword \ --admin-user admin \ @@ -154,24 +200,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: diff --git a/tests/integration/bin/ci-setup-frankenphp-behat-server.sh b/tests/integration/bin/ci-setup-frankenphp-behat-server.sh new file mode 100755 index 0000000000..d42f94590d --- /dev/null +++ b/tests/integration/bin/ci-setup-frankenphp-behat-server.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# Install FrankenPHP and put a `php` wrapper earlier on PATH so PhpBuiltin\RunServerListener's +# `php -S` invocation becomes FrankenPHP instead of the experimental built-in server. +# Prints the wrapper bin directory (prepend to PATH). Safe to re-run. +set -euo pipefail + +DEST="${FRANKENPHP_DIR:-/tmp/libresign-frankenphp-behat}" +mkdir -p "$DEST/bin" + +ARCH="$(uname -m)" +case "$ARCH" in + x86_64|amd64) ASSET="frankenphp-linux-x86_64" ;; + aarch64|arm64) ASSET="frankenphp-linux-aarch64" ;; + *) + echo "ci-setup-frankenphp-behat-server: unsupported architecture: $ARCH" >&2 + exit 1 + ;; +esac + +VER="${FRANKENPHP_VERSION:-1.12.7}" +if [[ ! -x "$DEST/frankenphp" ]]; then + echo "Downloading FrankenPHP v${VER} (${ASSET})..." >&2 + curl -fsSL -o "$DEST/frankenphp" \ + "https://github.com/php/frankenphp/releases/download/v${VER}/${ASSET}" + chmod +x "$DEST/frankenphp" +fi + +REAL_PHP="$(command -v php)" +if [[ -z "$REAL_PHP" ]]; then + echo "ci-setup-frankenphp-behat-server: php not found on PATH" >&2 + exit 1 +fi +ln -sfn "$REAL_PHP" "$DEST/bin/php.real" + +cat >"$DEST/bin/php" <<'WRAP' +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +set -euo pipefail +if [[ "${1:-}" == "-S" ]]; then + LISTEN="${2:?php -S requires host:port}" + ROOT="." + shift 2 + while [[ $# -gt 0 ]]; do + case "$1" in + -t) + ROOT="${2:?}" + shift 2 + ;; + *) + shift + ;; + esac + done + # escapeshellarg may quote the document root + ROOT="${ROOT#\'}" + ROOT="${ROOT%\'}" + FRANKENPHP="$(cd "$(dirname "$0")/.." && pwd)/frankenphp" + # Keep argv0 looking like php -S so RunServerListener killZombies can find leftovers. + exec -a "php -S ${LISTEN}" "$FRANKENPHP" php-server --listen="$LISTEN" --root="$ROOT" +fi +exec "$(dirname "$0")/php.real" "$@" +WRAP +chmod +x "$DEST/bin/php" + +# Also match frankenphp in killZombies (idempotent). +LISTENER="" +if [[ -f vendor/libresign/behat-builtin-extension/src/RunServerListener.php ]]; then + LISTENER="vendor/libresign/behat-builtin-extension/src/RunServerListener.php" +elif [[ -f vendor/phpbuiltin/server/src/RunServerListener.php ]]; then + LISTENER="vendor/phpbuiltin/server/src/RunServerListener.php" +fi +if [[ -n "$LISTENER" ]] && grep -q 'grep "php -S ' "$LISTENER"; then + sed -i.bak 's/grep "php -S /grep -E "php -S|frankenphp php-server /' "$LISTENER" +fi + +echo "$DEST/bin" diff --git a/tests/integration/config/behat.yml b/tests/integration/config/behat.yml index 6fb644805f..a7ae5e8b96 100644 --- a/tests/integration/config/behat.yml +++ b/tests/integration/config/behat.yml @@ -16,7 +16,8 @@ default: base_url: http://mailpit:8025 PhpBuiltin\Server: runAs: www-data - workers: 10 + # Temporary experiment: workers 0 (single-process php -S). Nested same-server HTTP may deadlock. + workers: 0 jarnaiz\JUnitFormatter\JUnitFormatterExtension: filename: report.xml outputDir: '%paths.base%/../output/'