From 6725567d81bec478e3797eca040c06873a23c4f7 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Sun, 15 Feb 2026 04:43:33 +0100 Subject: [PATCH] maint: improve bootstrap resilience Make the bootstrap initialization more resilient to errors. Some minor maintenance tweaks also included. Relates-to: keymanapp/shared-sites#90 Test-bot: skip --- .gitattributes | 5 +++-- .gitignore | 4 +++- build.sh | 30 ++++++++++++++++++++++-------- tools/2020/ReleaseSchedule.php | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.gitattributes b/.gitattributes index ab02d70..4622295 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ -Dockerfile text eol=lf -*.sh eol=lf +Dockerfile text eol=lf +*.Dockerfile text eol=lf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index e31141d..0ffcaa0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,9 @@ vendor* # Shared files are bootstrapped: resources/bootstrap.inc.sh resources/.bootstrap-version +resources/.bootstrap-registry _common/ # State files -_control/debug \ No newline at end of file +_control/debug +_control/release diff --git a/build.sh b/build.sh index e083433..d266ed3 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,11 @@ readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh" readonly BOOTSTRAP_VERSION=v1.0.10 -[ -f "$BOOTSTRAP" ] && source "$BOOTSTRAP" || source <(curl -fs https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh) +if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then + curl -H "Cache-Control: no-cache" --fail --silent --show-error -w "curl: Finished attempt to download %{url}" "https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh" -o "$BOOTSTRAP.tmp" || exit 1 + source "$BOOTSTRAP.tmp" + rm -f "$BOOTSTRAP.tmp" +fi ## END STANDARD SITE BUILD SCRIPT INCLUDE readonly API_KEYMAN_DB_CONTAINER_NAME=api-keyman-com-db @@ -29,6 +33,9 @@ builder_describe \ "stop" \ "test" \ "--rebuild-test-fixtures Rebuild the test fixtures from live data" \ + "--no-unit-test" \ + "--no-lint" \ + "--no-link-check" \ ":db Build the database" \ ":app Build the site" @@ -42,15 +49,22 @@ function test_docker_container() { touch rebuild-test-fixtures.txt fi - # Run unit tests - docker exec $API_KEYMAN_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox" + if ! builder_has_option --no-unit-test; then + # Run unit tests + # shellcheck disable=SC2154 + docker exec $API_KEYMAN_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}" + fi - # Lint .php files for obvious errors - docker exec $API_KEYMAN_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l" + if ! builder_has_option --no-lint; then + # Lint .php files for obvious errors + docker exec $API_KEYMAN_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l" + fi - # Check all internal links - # NOTE: link checker runs on host rather than in docker image - npx broken-link-checker http://localhost:8058 --ordered --recursive --host-requests 10 -e --filter-level 3 + if ! builder_has_option --no-link-check; then + # Check all internal links + # NOTE: link checker runs on host rather than in docker image + npx broken-link-checker http://localhost:8058 --ordered --recursive --host-requests 10 -e --filter-level 3 + fi rm tier.txt } diff --git a/tools/2020/ReleaseSchedule.php b/tools/2020/ReleaseSchedule.php index 9942174..309e531 100644 --- a/tools/2020/ReleaseSchedule.php +++ b/tools/2020/ReleaseSchedule.php @@ -42,6 +42,7 @@ public static function DoesRequestMeetSchedule(string $releaseDate, int $current foreach($schedule as $days => $minutes) { if($interval->days <= $days) { + // TODO: spread this test across the hour rather than just 'first x minutes of the hour' return $currentTime['minutes'] < $minutes; } }