Skip to content

Commit 5c7810f

Browse files
authored
Merge pull request #346 from keymanapp/chore/linkinator
chore: linkinator
2 parents c2271ff + f2b1b11 commit 5c7810f

4 files changed

Lines changed: 87 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,90 @@ on: [pull_request]
55
jobs:
66
build-test:
77
runs-on: ubuntu-latest
8+
env:
9+
KEYMANHOSTS_TIER: TIER_TEST
10+
CONTAINER_DESC: api-keyman-com-app
11+
CONTAINER_PORT: 8058
812

913
steps:
1014
- name: Checkout
1115
uses: actions/checkout@v6.0.2
1216

17+
# Build the docker image and create link to vendor/ dependencies
1318
- name: Build the Docker image
1419
shell: bash
1520
run: |
1621
echo "TIER_TEST" > tier.txt
17-
./build.sh build start
22+
./build.sh configure build start --debug
1823
env:
1924
fail-fast: true
2025

21-
- name: Run tests
26+
#
27+
# Run tests -- these step definitions are NEARLY identical across:
28+
# help.keyman.com, keyman.com, keymanweb.com, api.keyman.com
29+
#
30+
# No differences on this site
31+
#
32+
- name: Test setup
2233
shell: bash
2334
run: |
24-
./build.sh test
35+
source ./_common/tests.inc.sh
36+
set -e
37+
do_test_record_start_time
38+
echo "TEST_START_TIME=${TEST_START_TIME}" >> "$GITHUB_ENV"
2539
40+
- name: PHP test
41+
if: ${{ !cancelled() }}
42+
shell: bash
43+
run: |
44+
source ./_common/tests.inc.sh
45+
set -e
46+
do_test_unit_tests "$CONTAINER_DESC"
47+
48+
- name: Lint
49+
if: ${{ !cancelled() }}
50+
shell: bash
51+
run: |
52+
source ./_common/tests.inc.sh
53+
set -e
54+
do_test_lint "$CONTAINER_DESC"
55+
56+
- name: Check broken links
57+
if: ${{ !cancelled() }}
58+
shell: bash
59+
run: |
60+
source ./_common/tests.inc.sh
61+
set -e
62+
do_test_links "http://localhost:${CONTAINER_PORT}" /
63+
64+
# We split the reporting of broken links into a separate step for ease of
65+
# viewing because the broken links are otherwise hidden in a sea of good
66+
# links in a very long report
67+
68+
- name: Report on broken links
69+
if: ${{ !cancelled() }}
70+
run: |
71+
source ./_common/tests.inc.sh
72+
set -e
73+
do_test_print_link_report
74+
75+
- name: Check PHP errors
76+
if: ${{ !cancelled() }}
77+
shell: bash
78+
run: |
79+
source ./_common/tests.inc.sh
80+
set -e
81+
do_test_print_container_error_logs "$CONTAINER_DESC"
82+
83+
- name: Verify .bootstrap-required-version
84+
if: ${{ !cancelled() }}
85+
shell: bash
86+
run: |
87+
# We want to avoid merging a bootstrap version that is not based on a published tag
88+
# in the shared-sites repo. We will do this with a heuristic based on the normal
89+
# shape of the tags, which is `v#.#.#`. Any other shape we will assume is a test
90+
# branch.
91+
cat resources/.bootstrap-required-version | grep -qP '^v\d+\.\d+\.\d+$' || (
92+
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?"
93+
exit 1
94+
)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ vendor*
55
/node_modules/
66
.vscode/
77

8+
linkinator-results.json
9+
810
# Shared files are bootstrapped:
911
resources/bootstrap.inc.sh
1012
resources/.bootstrap-version

build.sh

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
## START STANDARD SITE BUILD SCRIPT INCLUDE
33
readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
44
readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh"
5-
readonly BOOTSTRAP_VERSION=v1.0.14
5+
BOOTSTRAP_VERSION="$(cat "$(dirname "THIS_SCRIPT")/resources/.bootstrap-required-version")" || exit 1
6+
readonly BOOTSTRAP_VERSION
67
if ! [ -f "$BOOTSTRAP" ] || ! source "$BOOTSTRAP"; then
78
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
89
source "$BOOTSTRAP.tmp"
@@ -32,6 +33,7 @@ builder_describe \
3233
"start" \
3334
"stop" \
3435
"test" \
36+
"info" \
3537
"--rebuild-test-fixtures Rebuild the test fixtures from live data" \
3638
"--no-unit-test" \
3739
"--no-lint" \
@@ -41,34 +43,6 @@ builder_describe \
4143

4244
builder_parse "$@"
4345

44-
function test_docker_container() {
45-
echo "TIER_TEST" > tier.txt
46-
# Note: ci.yml replicates these
47-
48-
if builder_has_option --rebuild-test-fixtures; then
49-
touch rebuild-test-fixtures.txt
50-
fi
51-
52-
if ! builder_has_option --no-unit-test; then
53-
# Run unit tests
54-
# shellcheck disable=SC2154
55-
docker exec $API_KEYMAN_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}"
56-
fi
57-
58-
if ! builder_has_option --no-lint; then
59-
# Lint .php files for obvious errors
60-
docker exec $API_KEYMAN_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l"
61-
fi
62-
63-
if ! builder_has_option --no-link-check; then
64-
# Check all internal links
65-
# NOTE: link checker runs on host rather than in docker image
66-
npx broken-link-checker http://localhost:8058 --ordered --recursive --host-requests 10 -e --filter-level 3
67-
fi
68-
69-
rm tier.txt
70-
}
71-
7246
builder_run_action configure bootstrap_configure
7347

7448
builder_run_action clean:db clean_docker_container $API_KEYMAN_DB_IMAGE_NAME $API_KEYMAN_DB_CONTAINER_NAME
@@ -203,4 +177,12 @@ function start_docker_container_app() {
203177
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
204178
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
205179

206-
builder_run_action test:app test_docker_container
180+
builder_run_action test:app test_docker_container $API_KEYMAN_CONTAINER_DESC $PORT_API_KEYMAN_COM /
181+
182+
do_info() {
183+
echo "BUILDER_TIER: $BUILDER_TIER"
184+
echo "KEYMAN_VERSION_ENVIRONMENT: $KEYMAN_VERSION_ENVIRONMENT"
185+
}
186+
187+
builder_run_action info do_info
188+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.0.14

0 commit comments

Comments
 (0)