-
Notifications
You must be signed in to change notification settings - Fork 1
/
script
executable file
·73 lines (62 loc) · 2.05 KB
/
script
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
72
73
#!/bin/bash
set -e
die() { echo -e "\e[1m$*\e[0m" >&2; exit 1; }
[ "$(dirname "$(realpath "$(which "$0")")")" == "$(pwd)" ] || die "$0 Must run from own directory"
image=docker.pkg.github.com/svenssonaxel/diff-format/diff-format-tester:latest
docker-run() {
if [ -t 1 ]; then
docker run -it "$@"
else
docker run "$@"
fi
}
build-container() {
docker build -t $image docker
}
run-basic-tests() {
docker-run -v "$(pwd):/home/user/diff-format:ro" -w /home/user/diff-format/tests $image ./run-tests
}
run-all-tests() {
docker-run -v "$(pwd):/home/user/diff-format:ro" -w /home/user/diff-format/tests -e RUNALLTESTS=yes $image ./run-tests
}
lint-scripts() {
docker-run -v "$(pwd):/home/user/diff-format" -w /home/user/diff-format $image shellcheck script implementations/git/* make-img/check-img
}
check-img() {
docker-run -v "$(pwd):/home/user/diff-format:ro" -w /home/user/diff-format/make-img $image ./check-img
}
build-and-validate() {
build-container
run-basic-tests
run-all-tests
lint-scripts
check-img
}
update-img() {
rm -rf img/
docker-run -v "$(pwd):/home/user/diff-format" -w /home/user/diff-format/make-img $image make -j
}
CMD="$1"
case "$CMD" in
build-container|run-basic-tests|run-all-tests|lint-scripts|check-img|build-and-validate|update-img)
$CMD
;;
*)
if [[ -z "$CMD" ]]; then
cat <<EOF
Usage:
./script build-container # Build container for running tests
./script run-basic-tests # Use container to run the basic test suite
./script run-all-tests # Use container to run all tests
./script lint-scripts # Use container to lint shell scripts
./script check-img # Use container to check that img/ is up to date
./script build-and-validate # Run all of the above in order
./script update-img # Use container to update img/
EOF
exit 0
else
echo "Unknown command: $CMD"
exit 1
fi
;;
esac