-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-lint
More file actions
executable file
·42 lines (33 loc) · 846 Bytes
/
Copy pathrun-lint
File metadata and controls
executable file
·42 lines (33 loc) · 846 Bytes
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
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}/ansible"
export PATH="${PATH}:$(python3 -m site --user-base)/bin"
export PYTHONUNBUFFERED=1
GITHUB_FORMAT=false
SARIF_FILE="${SCRIPT_DIR}/ansible-lint.sarif"
for arg in "$@"; do
case "$arg" in
--github-format)
GITHUB_FORMAT=true
;;
esac
done
EXIT_CODE=0
run_yamllint() {
if [[ "${GITHUB_FORMAT}" == "true" ]]; then
yamllint --format github . || return $?
else
yamllint . || return $?
fi
}
run_ansible_lint() {
if [[ "${GITHUB_FORMAT}" == "true" ]]; then
ansible-lint -f sarif > "${SARIF_FILE}" || return $?
else
ansible-lint || return $?
fi
}
run_yamllint || EXIT_CODE=$?
run_ansible_lint || EXIT_CODE=$?
exit "${EXIT_CODE}"