From d605eca5740d86942dca3cfae68fffea2c4b5de7 Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Wed, 10 Jun 2026 19:22:52 +0200 Subject: [PATCH] Fallback composer installs to source in CI --- .github/workflows/tests.yml | 33 ++++++++++++++++++++++----------- scripts/php-ci-test.sh | 20 +++++++++++++++++--- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1de35923..526e843f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -166,17 +166,28 @@ jobs: - name: Resolve dependencies run: | set -euo pipefail - for attempt in 1 2 3; do - if docker compose -f docker-compose.yml -f .github/docker-compose.ci.yml exec -T php1 sh -lc "cd /var/www/html && composer install --no-interaction --prefer-dist --no-progress"; then - exit 0 - fi - if [ "$attempt" -eq 3 ]; then - exit 1 - fi - sleep_seconds=$((attempt * 5)) - echo "composer install failed; retrying in ${sleep_seconds}s (attempt $((attempt + 1))/3)" >&2 - sleep "$sleep_seconds" - done + composer_install() { + install_mode="$1" + max_attempts="$2" + attempt=1 + while :; do + if docker compose -f docker-compose.yml -f .github/docker-compose.ci.yml exec -T php1 sh -lc "cd /var/www/html && composer install --no-interaction ${install_mode} --no-progress"; then + return 0 + fi + if [ "$attempt" -ge "$max_attempts" ]; then + return 1 + fi + sleep_seconds=$((attempt * 5)) + echo "composer install ${install_mode} failed; retrying in ${sleep_seconds}s (attempt $((attempt + 1))/${max_attempts})" >&2 + sleep "$sleep_seconds" + attempt=$((attempt + 1)) + done + } + + composer_install --prefer-dist 3 || { + echo "Composer dist install failed; retrying with --prefer-source." >&2 + composer_install --prefer-source 2 + } - name: Verify edge gateway test files run: > diff --git a/scripts/php-ci-test.sh b/scripts/php-ci-test.sh index e3438efe..a6cac1dc 100644 --- a/scripts/php-ci-test.sh +++ b/scripts/php-ci-test.sh @@ -68,6 +68,22 @@ retry_command() { done } +composer_install() { + dist_attempts="${PHP_CI_COMPOSER_RETRIES:-3}" + source_attempts="${PHP_CI_COMPOSER_SOURCE_RETRIES:-2}" + + if retry_command "$dist_attempts" \ + docker compose $compose_files exec -T php1 sh -lc \ + 'cd /var/www/html && composer install --no-interaction --prefer-dist --no-progress'; then + return 0 + fi + + echo "Composer dist install failed after ${dist_attempts} attempts; retrying with --prefer-source." >&2 + retry_command "$source_attempts" \ + docker compose $compose_files exec -T php1 sh -lc \ + 'cd /var/www/html && composer install --no-interaction --prefer-source --no-progress' +} + cleanup() { status="$?" collect_logs "$status" @@ -112,9 +128,7 @@ tar \ -C services/nginx/app -cf - . \ | docker compose $compose_files exec -T php1 tar -C /var/www/html -xf - -retry_command "${PHP_CI_COMPOSER_RETRIES:-3}" \ - docker compose $compose_files exec -T php1 sh -lc \ - 'cd /var/www/html && composer install --no-interaction --prefer-dist --no-progress' +composer_install docker compose $compose_files exec -T php1 sh -lc \ "cd /var/www/html && composer test:ci:$suite"