From 86fbccf0887fa1d8d228f66fc39f8a3e1fa4025b Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Mon, 15 Jun 2026 11:14:02 +0200 Subject: [PATCH 1/2] chore: linkinator Based-on: keymanapp/keyman.com#788 Test-bot: skip --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++-- .gitignore | 2 ++ build.sh | 41 +++++++------------------- 3 files changed, 72 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8c7960..62bde0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,21 +5,77 @@ on: [pull_request] jobs: build-test: runs-on: ubuntu-latest + env: + KEYMANHOSTS_TIER: TIER_TEST + CONTAINER_DESC: api-keyman-com-app + CONTAINER_PORT: 8058 steps: - name: Checkout uses: actions/checkout@v6.0.2 + # Build the docker image and create link to vendor/ dependencies - name: Build the Docker image shell: bash run: | echo "TIER_TEST" > tier.txt - ./build.sh build start + ./build.sh configure build start --debug env: fail-fast: true - - name: Run tests + # + # Run tests -- these step definitions are NEARLY identical across: + # help.keyman.com, keyman.com, keymanweb.com, api.keyman.com + # + # No differences on this site + # + - name: Test setup shell: bash run: | - ./build.sh test + source ./_common/tests.inc.sh + set -e + do_test_record_start_time + echo "TEST_START_TIME=${TEST_START_TIME}" >> "$GITHUB_ENV" + - name: PHP test + if: ${{ !cancelled() }} + shell: bash + run: | + source ./_common/tests.inc.sh + set -e + do_test_unit_tests "$CONTAINER_DESC" + + - name: Lint + if: ${{ !cancelled() }} + shell: bash + run: | + source ./_common/tests.inc.sh + set -e + do_test_lint "$CONTAINER_DESC" + + - name: Check broken links + if: ${{ !cancelled() }} + shell: bash + run: | + source ./_common/tests.inc.sh + set -e + do_test_links "http://localhost:${CONTAINER_PORT}" / + + # We split the reporting of broken links into a separate step for ease of + # viewing because the broken links are otherwise hidden in a sea of good + # links in a very long report + + - name: Report on broken links + if: ${{ !cancelled() }} + run: | + source ./_common/tests.inc.sh + set -e + do_test_print_link_report + + - name: Check PHP errors + if: ${{ !cancelled() }} + shell: bash + run: | + source ./_common/tests.inc.sh + set -e + do_test_print_container_error_logs "$CONTAINER_DESC" diff --git a/.gitignore b/.gitignore index 0ffcaa0..d664bb0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ vendor* /node_modules/ .vscode/ +linkinator-results.json + # Shared files are bootstrapped: resources/bootstrap.inc.sh resources/.bootstrap-version diff --git a/build.sh b/build.sh index 2b91749..de81039 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ ## START STANDARD SITE BUILD SCRIPT INCLUDE readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh" -readonly BOOTSTRAP_VERSION=v1.0.13 +readonly BOOTSTRAP_VERSION=feat/linkinator-and-central-test-script 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" @@ -32,6 +32,7 @@ builder_describe \ "start" \ "stop" \ "test" \ + "info" \ "--rebuild-test-fixtures Rebuild the test fixtures from live data" \ "--no-unit-test" \ "--no-lint" \ @@ -41,34 +42,6 @@ builder_describe \ builder_parse "$@" -function test_docker_container() { - echo "TIER_TEST" > tier.txt - # Note: ci.yml replicates these - - if builder_has_option --rebuild-test-fixtures; then - touch rebuild-test-fixtures.txt - fi - - 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 - - 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 - - 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 -} - builder_run_action configure bootstrap_configure builder_run_action clean:db clean_docker_container $API_KEYMAN_DB_IMAGE_NAME $API_KEYMAN_DB_CONTAINER_NAME @@ -203,4 +176,12 @@ function start_docker_container_app() { builder_run_action start:db start_docker_container_db $API_KEYMAN_DB_IMAGE_NAME $API_KEYMAN_DB_CONTAINER_NAME $API_KEYMAN_DB_CONTAINER_DESC $PORT_API_KEYMAN_COM_DB builder_run_action start:app start_docker_container_app $API_KEYMAN_IMAGE_NAME $API_KEYMAN_CONTAINER_NAME $API_KEYMAN_CONTAINER_DESC $HOST_API_KEYMAN_COM $PORT_API_KEYMAN_COM -builder_run_action test:app test_docker_container +builder_run_action test:app test_docker_container $API_KEYMAN_CONTAINER_DESC $PORT_API_KEYMAN_COM / + +do_info() { + echo "BUILDER_TIER: $BUILDER_TIER" + echo "KEYMAN_VERSION_ENVIRONMENT: $KEYMAN_VERSION_ENVIRONMENT" +} + +builder_run_action info do_info + From f75402c9c2f869e1a62111fc4e61d2448c203b4a Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Tue, 16 Jun 2026 15:02:35 +0200 Subject: [PATCH 2/2] chore: verify bootstrap version format before merge Relates-to: keymanapp/keyman.com#794 Test-bot: skip --- .github/workflows/ci.yml | 13 +++++++++++++ build.sh | 3 ++- resources/.bootstrap-required-version | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 resources/.bootstrap-required-version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62bde0b..a372a70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,3 +79,16 @@ jobs: source ./_common/tests.inc.sh set -e do_test_print_container_error_logs "$CONTAINER_DESC" + + - name: Verify .bootstrap-required-version + if: ${{ !cancelled() }} + shell: bash + run: | + # We want to avoid merging a bootstrap version that is not based on a published tag + # in the shared-sites repo. We will do this with a heuristic based on the normal + # shape of the tags, which is `v#.#.#`. Any other shape we will assume is a test + # branch. + cat resources/.bootstrap-required-version | grep -qP '^v\d+\.\d+\.\d+$' || ( + echo "::error file=resources/.bootstrap-required-version,line=1,col=1::This branch cannot be merged, because resources/.bootstrap-required-version references \`$(cat resources/.bootstrap-required-version)\`, which does not appear to be a published tag -- is it a test branch?" + exit 1 + ) diff --git a/build.sh b/build.sh index de81039..1297e72 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,8 @@ ## START STANDARD SITE BUILD SCRIPT INCLUDE readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh" -readonly BOOTSTRAP_VERSION=feat/linkinator-and-central-test-script +BOOTSTRAP_VERSION="$(cat "$(dirname "THIS_SCRIPT")/resources/.bootstrap-required-version")" || exit 1 +readonly BOOTSTRAP_VERSION 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" diff --git a/resources/.bootstrap-required-version b/resources/.bootstrap-required-version new file mode 100644 index 0000000..eca15ab --- /dev/null +++ b/resources/.bootstrap-required-version @@ -0,0 +1 @@ +v1.0.14 \ No newline at end of file