/
before_install.sh.j2
executable file
·70 lines (56 loc) · 1.97 KB
/
before_install.sh.j2
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
#!/usr/bin/env bash
{% include 'header.j2' %}
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../../..
set -mveuo pipefail
if [ "${GITHUB_REF##refs/heads/}" = "${GITHUB_REF}" ]
then
BRANCH_BUILD=0
else
BRANCH_BUILD=1
BRANCH="${GITHUB_REF##refs/heads/}"
fi
if [ "${GITHUB_REF##refs/tags/}" = "${GITHUB_REF}" ]
then
TAG_BUILD=0
else
TAG_BUILD=1
BRANCH="${GITHUB_REF##refs/tags/}"
fi
COMMIT_MSG=$(git log --format=%B --no-merges -1)
export COMMIT_MSG
COMPONENT_VERSION=$(sed -ne "s/\s*version.*=.*['\"]\(.*\)['\"][\s,]*/\1/p" setup.py)
mkdir .ci/ansible/vars || true
echo "---" > .ci/ansible/vars/main.yaml
echo "legacy_component_name: {{ plugin_name | snake }}" >> .ci/ansible/vars/main.yaml
echo "component_name: {{ plugin_app_label }}" >> .ci/ansible/vars/main.yaml
echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml
export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh
if [ -f $PRE_BEFORE_INSTALL ]; then
source $PRE_BEFORE_INSTALL
fi
if [[ -n $(echo -e $COMMIT_MSG | grep -P "Required PR:.*") ]]; then
echo "The Required PR mechanism has been removed. Consider adding a scm requirement to requirements.txt."
exit 1
fi
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "{{ plugin_default_branch }}" ]
then
echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml
fi
for i in {1..3}
do
ansible-galaxy collection install "amazon.aws:1.5.0" && s=0 && break || s=$? && sleep 3
done
if [[ $s -gt 0 ]]
then
echo "Failed to install amazon.aws"
exit $s
fi
if [[ "$TEST" = "lowerbounds" ]]; then
python3 .ci/scripts/calc_deps_lowerbounds.py > lowerbounds_constraints.txt
sed -i 's/\[.*\]//g' lowerbounds_constraints.txt
fi
if [ -f $POST_BEFORE_INSTALL ]; then
source $POST_BEFORE_INSTALL
fi