-
Notifications
You must be signed in to change notification settings - Fork 0
/
lefthook.yaml
65 lines (53 loc) · 1.7 KB
/
lefthook.yaml
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
assert_lefthook_installed: true
min_version: 1.5.5
pre-push:
parallel: true
scripts:
"validate-root-readme.sh":
runner: bash
pre-commit:
parallel: true
commands:
check-broken-link:
glob: "*.md"
run: |
command=""
if which docker 2>&1 > /dev/null; then
echo "Docker found"
command="docker"
fi
if [[ "$command" == "" ]] && which podman 2>&1 > /dev/null; then
echo "Podman found"
command="podman"
fi
if [[ "$command" == "" ]]; then
echo "No container runtime found"
exit 1
fi
files_to_scan=()
# Prefix files name with the basedir mounted in the container
for FILE in {all_files}; do
files_to_scan+=( "/files/${FILE}" )
done
"$command" run -v ${PWD}:/files:ro --rm -i ghcr.io/tcort/markdown-link-check:stable -c /files/.markdown-link-checker-config.json -q "${files_to_scan[@]}"
run-terraform-tests:
files: git --no-pager diff --name-only HEAD
glob: "terraform/modules/*/*"
run: |
modified_files=()
for FILE in {files}; do
modified_files+=( "$FILE" )
done
# Get unique modules that have been modified
IFS=$'\n' modules_to_test=$(sort <<< "${modified_files[*]}" | cut -d'/' -f1-3 | uniq)
unset IFS
# For each module, run the terraform command to run the tests
for module in $modules_to_test; do
echo "Testing $module"
terraform -chdir="$module" init -upgrade > /dev/null
if ! terraform -chdir="$module" test; then
echo "Tests failed"
exit 1
fi
echo ""
done