Skip to content

feat: shared site testing script and move to linkinator#97

Merged
mcdurdin merged 2 commits into
mainfrom
feat/linkinator-and-central-test-script
Jun 16, 2026
Merged

feat: shared site testing script and move to linkinator#97
mcdurdin merged 2 commits into
mainfrom
feat/linkinator-and-central-test-script

Conversation

@mcdurdin

Copy link
Copy Markdown
Member

Relates-to: keymanapp/keyman.com#788
Test-bot: skip

@mcdurdin mcdurdin requested a review from ermshiperete June 15, 2026 08:40
@keymanapp-test-bot

Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

@github-actions github-actions Bot added the feat label Jun 15, 2026
@keymanapp-test-bot keymanapp-test-bot Bot added this to the A19S31 milestone Jun 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Keyman Jun 15, 2026
@mcdurdin mcdurdin force-pushed the feat/linkinator-and-central-test-script branch from 741832a to c855186 Compare June 15, 2026 08:54
@mcdurdin mcdurdin force-pushed the feat/linkinator-and-central-test-script branch from c855186 to df4837e Compare June 15, 2026 08:59
Comment thread _common/docker.inc.sh Outdated
local CONTAINER_PORT="$2"
local TEST_PATH="$3"
shift 3
local SKIP_PATHS=("$*")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local SKIP_PATHS=("$*")
local SKIP_PATHS=("$@")

Comment thread _common/tests.inc.sh Outdated
shift 2
local skipPaths skip skipParams=()
if [[ $# -gt 1 ]]; then
skipPaths=("$*")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
skipPaths=("$*")
skipPaths=("$@")

Comment thread _common/docker.inc.sh Outdated
local LINK_RESULT
echo "TIER_TEST" > tier.txt

# from commands.inc.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which commands.inc.sh ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Left behind from a refactor

Comment thread _common/tests.inc.sh
@@ -0,0 +1,93 @@
# shellcheck shell=bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# shellcheck shell=bash
# shellcheck shell=bash
# Keyman is copyright (C) SIL Global. MIT License.

Comment thread _common/docker.inc.sh Outdated
@@ -1,5 +1,7 @@
# Common docker functions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Common docker functions.
# shellcheck shell=bash
# Keyman is copyright (C) SIL Global. MIT License.
#
# Common docker functions.

Comment thread _common/tests.inc.sh
#
function do_test_unit_tests() {
local CONTAINER="$1"
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}"
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[@]}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use ${x[@]} here because that will quote at the wrong level -- it needs to remain inside the quotes for the parameter following sh -c.

Comment thread _common/docker.inc.sh Outdated
shift 3
local SKIP_PATHS=("$*")

local LINK_RESULT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be initialized, otherwise we return uninitialized value if we don't do link checks.

Suggested change
local LINK_RESULT
local LINK_RESULT=0

Comment thread _common/tests.inc.sh Outdated
local testPath="$2"
shift 2
local skipPaths skip skipParams=()
if [[ $# -gt 1 ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $# -gt 1 ]]; then
if [[ $# -ge 1 ]]; then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, bingo, if I have do_test_links a b "$*" rather than do_test_links a b "$@", then I end up with a spurious blank parameter...

$* vs $@ is such an annoying distinction 😁

Comment thread _common/tests.inc.sh Outdated
#
function do_test_print_container_error_logs() {
local CONTAINER="$1"
if docker container logs "${CONTAINER}" --since "${TEST_START_TIME}" 2>&1 | grep -q 'php7'; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some check somewhere that we're still running the expected PHP version that outputs php7?

Makes me a bit nervous that PHP gets upgraded and we forget to upgrade this string which then causes silent failure (or rather non-failure) of this function.

@mcdurdin mcdurdin Jun 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested against PHP 8 and the version number has been removed from the string. Have gone with the following (tested) string which works with PHP 7 and 8 running through Apache:

'\[php7?:(error|warn|notice)\]'

The format of messages may of course change again at any time in the future but we can only do so much...

Comment thread _common/docker.inc.sh
local SKIP_PATHS=("$*")

local LINK_RESULT
echo "TIER_TEST" > tier.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of tier.txt ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to specify the tier across server and script contexts consistently (as env vars may not be available in http server context). See:

# Get the site BUILDER_TIER and use that to determine builder script environment
if [[ ! -z ${KEYMANHOSTS_TIER+x} ]]; then
BUILDER_TIER="${KEYMANHOSTS_TIER}"
elif [[ -f "$(dirname "$THIS_SCRIPT")/tier.txt" ]]; then
BUILDER_TIER=$(cat "$(dirname "$THIS_SCRIPT")/tier.txt")
else
BUILDER_TIER=TIER_DEVELOPMENT
fi

if(isset($env['KEYMANHOSTS_TIER']) && in_array($env['KEYMANHOSTS_TIER'],
[KeymanHosts::TIER_DEVELOPMENT, KeymanHosts::TIER_STAGING,
KeymanHosts::TIER_PRODUCTION, KeymanHosts::TIER_TEST])) {
$this->tier = $env['KEYMANHOSTS_TIER'];
} else if(file_exists(__DIR__ . '/../tier.txt')) {
$this->tier = trim(file_get_contents(__DIR__ . '/../tier.txt'));
} else {
$this->tier = KeymanHosts::TIER_DEVELOPMENT;
}

Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>

@mcdurdin mcdurdin left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed review! I think I've addressed all the code changes.

Comment thread _common/docker.inc.sh
local SKIP_PATHS=("$*")

local LINK_RESULT
echo "TIER_TEST" > tier.txt

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to specify the tier across server and script contexts consistently (as env vars may not be available in http server context). See:

# Get the site BUILDER_TIER and use that to determine builder script environment
if [[ ! -z ${KEYMANHOSTS_TIER+x} ]]; then
BUILDER_TIER="${KEYMANHOSTS_TIER}"
elif [[ -f "$(dirname "$THIS_SCRIPT")/tier.txt" ]]; then
BUILDER_TIER=$(cat "$(dirname "$THIS_SCRIPT")/tier.txt")
else
BUILDER_TIER=TIER_DEVELOPMENT
fi

if(isset($env['KEYMANHOSTS_TIER']) && in_array($env['KEYMANHOSTS_TIER'],
[KeymanHosts::TIER_DEVELOPMENT, KeymanHosts::TIER_STAGING,
KeymanHosts::TIER_PRODUCTION, KeymanHosts::TIER_TEST])) {
$this->tier = $env['KEYMANHOSTS_TIER'];
} else if(file_exists(__DIR__ . '/../tier.txt')) {
$this->tier = trim(file_get_contents(__DIR__ . '/../tier.txt'));
} else {
$this->tier = KeymanHosts::TIER_DEVELOPMENT;
}

Comment thread _common/docker.inc.sh Outdated
local LINK_RESULT
echo "TIER_TEST" > tier.txt

# from commands.inc.sh

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Left behind from a refactor

Comment thread _common/tests.inc.sh
#
function do_test_unit_tests() {
local CONTAINER="$1"
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can use ${x[@]} here because that will quote at the wrong level -- it needs to remain inside the quotes for the parameter following sh -c.

Comment thread _common/tests.inc.sh Outdated
local testPath="$2"
shift 2
local skipPaths skip skipParams=()
if [[ $# -gt 1 ]]; then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, bingo, if I have do_test_links a b "$*" rather than do_test_links a b "$@", then I end up with a spurious blank parameter...

$* vs $@ is such an annoying distinction 😁

Comment thread _common/tests.inc.sh Outdated
#
function do_test_print_container_error_logs() {
local CONTAINER="$1"
if docker container logs "${CONTAINER}" --since "${TEST_START_TIME}" 2>&1 | grep -q 'php7'; then

@mcdurdin mcdurdin Jun 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested against PHP 8 and the version number has been removed from the string. Have gone with the following (tested) string which works with PHP 7 and 8 running through Apache:

'\[php7?:(error|warn|notice)\]'

The format of messages may of course change again at any time in the future but we can only do so much...

@mcdurdin mcdurdin merged commit 1998f79 into main Jun 16, 2026
3 checks passed
@mcdurdin mcdurdin deleted the feat/linkinator-and-central-test-script branch June 16, 2026 13:26
@github-project-automation github-project-automation Bot moved this from Todo to Done in Keyman Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants