Fallback composer installs to source in CI

This commit is contained in:
Jeppe B
2026-06-10 19:22:52 +02:00
parent 7e85c74e60
commit d605eca574
2 changed files with 39 additions and 14 deletions
+22 -11
View File
@@ -166,17 +166,28 @@ jobs:
- name: Resolve dependencies - name: Resolve dependencies
run: | run: |
set -euo pipefail set -euo pipefail
for attempt in 1 2 3; do composer_install() {
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 install_mode="$1"
exit 0 max_attempts="$2"
fi attempt=1
if [ "$attempt" -eq 3 ]; then while :; do
exit 1 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
fi return 0
sleep_seconds=$((attempt * 5)) fi
echo "composer install failed; retrying in ${sleep_seconds}s (attempt $((attempt + 1))/3)" >&2 if [ "$attempt" -ge "$max_attempts" ]; then
sleep "$sleep_seconds" return 1
done 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 - name: Verify edge gateway test files
run: > run: >
+17 -3
View File
@@ -68,6 +68,22 @@ retry_command() {
done 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() { cleanup() {
status="$?" status="$?"
collect_logs "$status" collect_logs "$status"
@@ -112,9 +128,7 @@ tar \
-C services/nginx/app -cf - . \ -C services/nginx/app -cf - . \
| docker compose $compose_files exec -T php1 tar -C /var/www/html -xf - | docker compose $compose_files exec -T php1 tar -C /var/www/html -xf -
retry_command "${PHP_CI_COMPOSER_RETRIES:-3}" \ composer_install
docker compose $compose_files exec -T php1 sh -lc \
'cd /var/www/html && composer install --no-interaction --prefer-dist --no-progress'
docker compose $compose_files exec -T php1 sh -lc \ docker compose $compose_files exec -T php1 sh -lc \
"cd /var/www/html && composer test:ci:$suite" "cd /var/www/html && composer test:ci:$suite"