-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·71 lines (58 loc) · 2.79 KB
/
build.sh
File metadata and controls
executable file
·71 lines (58 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
## 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.10
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 KEYMAN_CONTAINER_NAME=keyman-website
readonly KEYMAN_CONTAINER_DESC=keyman-com-app
readonly KEYMAN_IMAGE_NAME=keyman-website
readonly HOST_KEYMAN_COM=keyman.com.localhost
source _common/keyman-local-ports.inc.sh
source _common/docker.inc.sh
################################ Main script ################################
builder_describe \
"Setup keyman.com site to run via Docker." \
configure \
clean \
build \
start \
stop \
test \
builder_parse "$@"
function test_docker_container() {
# Note: ci.yml replicates these
echo "TIER_TEST" > tier.txt
set +e;
set +o pipefail;
builder_echo blue "---- PHP unit tests"
docker exec $KEYMAN_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox"
# Lint .php files for obvious errors
builder_echo blue "---- Lint PHP files"
docker exec $KEYMAN_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l"
# NOTE: link checker runs on host rather than in docker image
# Also exclude testing locales for each link: 'lang=*'
builder_echo blue "---- Testing links"
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude '*lang=*' | 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 $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME
builder_run_action stop stop_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME
builder_run_action build build_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME $BUILDER_CONFIGURATION
builder_run_action start start_docker_container $KEYMAN_IMAGE_NAME $KEYMAN_CONTAINER_NAME $KEYMAN_CONTAINER_DESC $HOST_KEYMAN_COM $PORT_KEYMAN_COM $BUILDER_CONFIGURATION
builder_run_action test test_docker_container