summaryrefslogtreecommitdiffstats
path: root/tools/test-setup.sh
blob: 79dbcc800268d64a9e8215cd1ad7608ff6b972d1 (plain)
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
#!/bin/bash
# This tool is used to setup the environment for running the tests. Its name
# name and location is based on Zuul CI, which can automatically run it.
set -euo pipefail

# User specific environment
# shellcheck disable=SC2076
if ! [[ "$PATH" =~ "$HOME/.local/bin" ]]
then
    PATH="$HOME/.local/bin:$PATH"
fi

if [ -f "/usr/bin/apt-get" ]; then
    if [ ! -f "/var/cache/apt/pkgcache.bin" ]; then
        sudo apt-get update  # mandatory or other apt-get commands fail
    fi
    # avoid outdated ansible and pipx
    sudo apt-get remove -y ansible pipx || true
    # cspell:disable-next-line
    sudo apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \
        curl gcc git python3-venv python3-pip python3-dev libyaml-dev
    # Some of these might be needed for compiling packages that do not yet
    # a binary for current platform, like pyyaml on py311
    # pip3 install -v --no-binary :all: --user pyyaml
fi

# Log some useful info in case of unexpected failures:
uname
python3 --version