forked from seapath/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-lint.sh
executable file
·72 lines (66 loc) · 1.43 KB
/
ansible-lint.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
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Copyright (C) 2023, RTE (http://www.rte-france.com)
# SPDX-License-Identifier: Apache-2.0
#
# This script download the sources of a specific pull request,
# then configure and launch ansible-lint on it
set -e
die() {
echo "linter internal failure : $@" 1>&2
exit 1
}
# Standard help message
usage()
{
cat <<EOF
This script is the launcher for the ansible-linter on SEAPATH ansible.
It is separated in two functions in order to display logs properly.
They should be called one after another.
USAGE:
./launch.sh <init|lint>
EOF
}
# Download and prepare the pull request sources
initialization() {
if ! type -p cqfd > /dev/null; then
die "cqfd not found"
fi
# Get sources
git clone -q https://github.com/seapath/ansible
cd ansible
git fetch -q origin ${GITHUB_REF}
git checkout -q FETCH_HEAD
echo "Pull request sources downloaded succesfully"
if [ ! -f ansible-lint.conf ] ; then
echo "No ansible-lint available. Skipping linting."
exit 0
fi
# Prepare ansible repository
cqfd init
cqfd -b prepare
echo "Sources prepared succesfully"
}
# Launch ansible-lint
ansible_lint() {
cd ansible
if [ ! -f ansible-lint.conf ] ; then
echo "No ansible-lint available. Skipping linting."
exit 0
fi
cqfd -b ansible-lint
}
case "$1" in
init)
initialization
exit 0
;;
lint)
ansible_lint
exit 0
;;
*)
usage
die "Unknown command"
;;
esac