aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2022-09-16 18:09:32 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-10-17 14:46:40 +0100
commit89c1f4bafb51dbbed705b6960810d90825318b13 (patch)
tree34b6f88a3342421d79ba6dea60e50ab28752c5d0 /docker
parent3083f7ee68ce08147db08fca2474e5f4712fc8d7 (diff)
downloadmlia-89c1f4bafb51dbbed705b6960810d90825318b13.tar.gz
MLIA-646 Add environment to setup pre-commit hooks
- Add new environment 'lint_setup' to set up the pre-commit hooks used by the environment 'lint' without running the actual tests. - Add docker file for linting and testing to the project root. - Add helper script 'install_python_versions.sh' for docker creation. Change-Id: I5f264df72a72d7a118ab798eddcf0febd4e1125b
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/install_python_versions.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/docker/install_python_versions.sh b/docker/install_python_versions.sh
new file mode 100755
index 0000000..c3cd976
--- /dev/null
+++ b/docker/install_python_versions.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+
+set -e
+set -u
+set -o pipefail
+
+# Set one or multiple python versions through pyenv to be available globally
+function set_python_global_versions() {
+ py_versions=$1
+ parsed_versions=""
+
+ # Find correct parsed subversion for each provided version
+ for i in $(echo "$py_versions" | tr ";" "\n")
+ do
+ parsed_versions+=$(pyenv versions | grep "$i")
+ parsed_versions+=" "
+ done
+ # Set global versions
+ echo "$parsed_versions" | xargs pyenv global
+}
+
+# Install all python versions provided as parameter using pyenv
+# if the --set-all-global flag is set, make all installed versions
+# available globally.
+py_versions=$1
+parameters=$2
+for i in $(echo "$py_versions" | tr ";" "\n")
+do
+ pyenv install "$i":latest
+done
+
+if [ "$parameters" == "--set-all-global" ]; then
+ set_python_global_versions "$1"
+fi