-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·63 lines (49 loc) · 2.18 KB
/
build.sh
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
#!/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=v0.4
[ -f "$BOOTSTRAP" ] && source "$BOOTSTRAP" || source <(curl -fs https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh)
## END STANDARD SITE BUILD SCRIPT INCLUDE
readonly S_KEYMAN_CONTAINER_NAME=s-keyman-website
readonly S_KEYMAN_CONTAINER_DESC=s-keyman-com-app
readonly S_KEYMAN_IMAGE_NAME=s-keyman-website
readonly HOST_S_KEYMAN_COM=s.keyman.com.localhost
source _common/keyman-local-ports.inc.sh
source _common/docker.inc.sh
################################ Main script ################################
builder_describe \
"Setup s.keyman.com site to run via Docker." \
configure \
clean \
build \
start \
stop \
test \
builder_parse "$@"
function test_docker_container() {
# Note: ci.yml replicates these
# TODO: Run unit tests
#docker exec $S_KEYMAN_CONTAINER_DESC sh -c "vendor/bin/phpunit --testdox"
# Lint .php files for obvious errors
docker exec $S_KEYMAN_CONTAINER_DESC sh -c "find . -name '*.php' | grep -v '/vendor/' | xargs -n 1 -d '\\n' php -l"
# Link checker not needed. No html files to verify
# Verify static file generated
if [ ! -f ./metadata/kmwversions.json ]; then
builder_die "Failed to generate static file"
fi
}
# Custom cleanup of static file
function clean_docker_container_s() {
clean_docker_container $S_KEYMAN_IMAGE_NAME $S_KEYMAN_CONTAINER_NAME
# Cleanup static file
if [ -f ./metadata/kmwversions.json ]; then
rm ./metadata/kmwversions.json
fi
}
builder_run_action configure bootstrap_configure
builder_run_action clean clean_docker_container_s
builder_run_action stop stop_docker_container $S_KEYMAN_IMAGE_NAME $S_KEYMAN_CONTAINER_NAME
builder_run_action build build_docker_container $S_KEYMAN_IMAGE_NAME $S_KEYMAN_CONTAINER_NAME
builder_run_action start start_docker_container $S_KEYMAN_IMAGE_NAME $S_KEYMAN_CONTAINER_NAME $S_KEYMAN_CONTAINER_DESC $HOST_S_KEYMAN_COM $PORT_S_KEYMAN_COM
builder_run_action test test_docker_container