From 296c6753961bcb041d13569f9b9a3f76cc2fe453 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 28 Nov 2025 08:41:03 +0700 Subject: [PATCH 1/3] chore: Update build.sh test --- .gitignore | 7 +++++++ Dockerfile | 11 ++++++++++- README.md | 12 +++++++++++- build.sh | 23 ++++++++++++++++++++--- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3240d1467..f2cf45a10 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,13 @@ **/.DS_Store .idea/ cdn/deploy + +tier.txt + +# unit test artifacts +blc.log +.phpunit.result.cache + vendor* .vscode/ node_modules/ diff --git a/Dockerfile b/Dockerfile index 74e621d7a..26194db8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ # syntax=docker/dockerfile:1 + +ARG BUILDER_CONFIGURATION="release" FROM php:7.4-apache@sha256:c9d7e608f73832673479770d66aacc8100011ec751d1905ff63fae3fe2e0ca6d AS composer-builder # Install Zip to use composer @@ -15,7 +17,14 @@ RUN composer self-update USER www-data WORKDIR /composer COPY composer.* /composer/ -RUN composer install +# Consume the build argment +ARG BUILDER_CONFIGURATION +RUN if [ "$BUILDER_CONFIGURATION" = "debug" ]; then \ + # composer install --dev deprecated + COMPOSER_NO_DEV=0 composer install ; \ + else \ + COMPOSER_NO_DEV=1 composer install ; \ + fi # Site FROM php:7.4-apache@sha256:c9d7e608f73832673479770d66aacc8100011ec751d1905ff63fae3fe2e0ca6d diff --git a/README.md b/README.md index 5bd0ec156..c46e1395e 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ shell, and from this folder, run: ./build.sh build ``` +If you'll be running tests locally, the Docker image will need to be built with dev dependencies: + +```sh +./build.sh build --debug +``` + #### Start the Docker container To start up the website, in bash, run: @@ -101,7 +107,11 @@ In bash, run: #### Running tests -To check for broken links and .php file conformance, when the site is running, +When the site is running, the test action will do the following: +* PHP unit tests +* Check .php file conformance +* Check for internal broken links + in bash, run: ```sh diff --git a/build.sh b/build.sh index d17bbf8cc..48324c322 100755 --- a/build.sh +++ b/build.sh @@ -31,21 +31,38 @@ builder_parse "$@" function test_docker_container() { # Note: ci.yml replicates these - # Run unit tests + echo "TIER_TEST" > tier.txt + set +e; + set +o pipefail; + + builder_echo blue "---- PHP unit tests" docker exec $HELP_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox" # Lint .php files for obvious errors + builder_echo blue "---- Lint PHP files" docker exec $HELP_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l" # Check all internal links # NOTE: link checker runs on host rather than in docker image - npx broken-link-checker http://localhost:8055 --ordered --recursive --host-requests 10 -e --filter-level 3 + builder_echo blue "---- Testing links" + npx broken-link-checker http://localhost:8055 --recursive --ordered ---host-requests 50 -e --filter-level 3 | tee blc.log + local BLC_RESULT=${PIPESTATUS[0]} + echo ---------------------------------------------------------------------- + echo Link check summary + echo ---------------------------------------------------------------------- + cat blc.log | \ + grep -E "BROKEN|Getting links from" | \ + grep -B 1 "BROKEN"; + + builder_echo blue "Done checking links" + rm tier.txt + return "${BLC_RESULT}" } builder_run_action configure bootstrap_configure builder_run_action clean clean_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME builder_run_action stop stop_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME -builder_run_action build build_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME +builder_run_action build build_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME $BUILDER_CONFIGURATION builder_run_action start start_docker_container $HELP_IMAGE_NAME $HELP_CONTAINER_NAME $HELP_CONTAINER_DESC $HOST_HELP_KEYMAN_COM $PORT_HELP_KEYMAN_COM $BUILDER_CONFIGURATION builder_run_action test test_docker_container From e1d7c3403cb3bbc0119c63f236cbd3af9ff6072f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 28 Nov 2025 09:54:31 +0700 Subject: [PATCH 2/3] fix: Update GHA --- .github/workflows/ci.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 619efd194..c883c5442 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: shell: bash run: | echo "TIER_TEST" > tier.txt - ./build.sh configure build start + ./build.sh configure build start --debug env: fail-fast: true @@ -37,13 +37,21 @@ jobs: - name: Check broken links shell: bash + continue-on-error: false run: | - set +e; - set +o pipefail; - npx broken-link-checker http://localhost:8055 --ordered --recursive --requests 50 --host-requests 50 -e --filter-level 3 | \ + set +e + set +o pipefail + npx broken-link-checker http://localhost:8055 --ordered --recursive --requests 50 --host-requests 50 -e --filter-level 3 | tee blc.log + echo "BLC_RESULT=${PIPESTATUS[0]}" >> "$GITHUB_ENV" + + - name: Report on broken links + run: | + set +e + set +o pipefail + cat blc.log | \ grep -E "BROKEN|Getting links from" | \ - grep -B 1 "BROKEN" - exit ${PIPESTATUS[0]} + grep -B 1 "BROKEN"; + exit "${BLC_RESULT}" - name: Check PHP errors shell: bash From 378e5d3021dbe360b6afb02ef748e46cafe1b2a8 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 28 Nov 2025 13:19:31 +0700 Subject: [PATCH 3/3] cleanup link checker flags --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c883c5442..083eab2c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: run: | set +e set +o pipefail - npx broken-link-checker http://localhost:8055 --ordered --recursive --requests 50 --host-requests 50 -e --filter-level 3 | tee blc.log + npx broken-link-checker http://localhost:8055 --ordered --recursive --host-requests 50 -e --filter-level 3 | tee blc.log echo "BLC_RESULT=${PIPESTATUS[0]}" >> "$GITHUB_ENV" - name: Report on broken links