-
Notifications
You must be signed in to change notification settings - Fork 18
/
dependencies
executable file
·93 lines (71 loc) · 3.41 KB
/
dependencies
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
set -ex
CURRENT_DIR="$(dirname "$0")"
export CI_DIR=/home/circleci/ci
export PYTHONPATH=/tmp/st2/st2common:${PYTHONPATH}
ST2_BRANCH=${ST2_BRANCH:-master}
LINT_CONFIGS_BRANCH=${LINT_CONFIGS_BRANCH:-master}
git config --global user.name "StackStorm Exchange"
git config --global user.email "info@stackstorm.com"
# Print out environment info
python --version
pip --version
# Clone st2 repo so other scripts can reference StackStorm Python code
[[ -d /tmp/st2 ]] || git clone --depth 1 --single-branch --branch "${ST2_BRANCH}" https://github.com/StackStorm/st2.git /tmp/st2
# Clone lint-configs
[[ -d ~/ci/lint-configs ]] || git clone --depth 1 --single-branch --branch "${LINT_CONFIGS_BRANCH}" https://github.com/StackStorm/lint-configs.git ~/ci/lint-configs
# Create a directory for debian packages so we can cache it in Circle CI
sudo rm -rf /var/cache/apt/archives && sudo ln -s ~/.apt-cache /var/cache/apt/archives && mkdir -p ~/.apt-cache/partial
# Note: We can't directly install imagemagick since it results an error
# We use work-around from https://discuss.circleci.com/t/error-installing-imagemagick/2963
sudo apt-get update
sudo apt-get -y install python-dev jq gmic optipng
# Installing dependencies for st2 pip build
sudo apt-get -y install libldap2-dev libsasl2-dev
# make `gh` available for github API calls
~/ci/.circle/install_gh
# Hit github's API to keep the PAT active (without failing if it's not)
(GH_TOKEN=${MACHINE_PASSWORD} gh repo view | head -n2) || true
# This should track the pinned version of pip in st2's Makefile
# Please sync this version with .circle/Makefile and .circleci/config.yml
PIP_VERSION="20.3.3"
sudo pip install -U "pip==${PIP_VERSION}" setuptools virtualenv
virtualenv --pip "${PIP_VERSION}" ~/virtualenv
source ~/virtualenv/bin/activate
# Install StackStorm requirements
echo "Installing StackStorm requirements from /tmp/st2/requirements.txt"
~/virtualenv/bin/pip install -r "/tmp/st2/requirements.txt"
# Copy over Makefile and install StackStorm runners and register metrics drivers
echo "Installing StackStorm runners and registering metrics drivers"
if [[ -n "${ROOT_DIR}" ]]; then
PACK_REQUIREMENTS_FILE="${ROOT_DIR}/requirements.txt"
PACK_TESTS_REQUIREMENTS_FILE="${ROOT_DIR}/requirements-tests.txt"
PACK_SETUP_TESTING_ENV="${ROOT_DIR}/tests/setup_testing_env.sh"
echo "Copying Makefile to ${ROOT_DIR}"
cp ~/ci/.circle/Makefile ${ROOT_DIR}
make -C requirements-ci .install-runners
else
PACK_REQUIREMENTS_FILE="$(pwd)/requirements.txt"
PACK_TESTS_REQUIREMENTS_FILE="$(pwd)/requirements-tests.txt"
PACK_SETUP_TESTING_ENV="$(pwd)/tests/setup_testing_env.sh"
echo "Copying Makefile to $(pwd)"
cp ~/ci/.circle/Makefile .
make requirements-ci .install-runners
fi
# Install pack requirements
if [[ -f "${PACK_REQUIREMENTS_FILE}" ]]; then
echo "Installing pack requirements from ${PACK_REQUIREMENTS_FILE}"
~/virtualenv/bin/pip install -r "${PACK_REQUIREMENTS_FILE}"
fi
# Install pack tests requirements
if [[ -f "${PACK_TESTS_REQUIREMENTS_FILE}" ]]; then
echo "Installing pack tests requirements from ${PACK_TESTS_REQUIREMENTS_FILE}"
~/virtualenv/bin/pip install -r "${PACK_TESTS_REQUIREMENTS_FILE}"
fi
# Install custom pack testing enviornment
if [[ -x "${PACK_SETUP_TESTING_ENV}" ]]; then
echo "Setting up custom pack testing environment with ${PACK_SETUP_TESTING_ENV}"
"${PACK_SETUP_TESTING_ENV}"
fi
echo "Installed dependencies:"
pip list