diff options
author | 2023-03-29 23:53:51 -0500 | |
---|---|---|
committer | 2023-04-07 10:49:59 +0100 | |
commit | 9dca151ad11df75a1842afd2bee9bad9c9ee0c37 (patch) | |
tree | fd8c9e06d3b6928b5c3a929d0a65ecb1649122d0 /.builds | |
parent | ci: run black on sourcehut (diff) | |
download | portage-9dca151ad11df75a1842afd2bee9bad9c9ee0c37.tar.gz portage-9dca151ad11df75a1842afd2bee9bad9c9ee0c37.tar.bz2 portage-9dca151ad11df75a1842afd2bee9bad9c9ee0c37.zip |
ci: NIH actions/setup-python for sourcehut
Use the deadsnakes PPA and PYTHON_VERSIONS env var to control which
version of python get installed. Use a separate setup-python script in
.builds/ to avoid duplicate code. And having to remember to update it in
more than one place for changes.
Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to '.builds')
-rw-r--r-- | .builds/lint.yml | 23 | ||||
-rwxr-xr-x | .builds/setup-python.sh | 23 |
2 files changed, 40 insertions, 6 deletions
diff --git a/.builds/lint.yml b/.builds/lint.yml index a294a3ad6..675fde757 100644 --- a/.builds/lint.yml +++ b/.builds/lint.yml @@ -1,15 +1,25 @@ # Maintainer: Oskari Pirhonen <xxc3ncoredxx@gmail.com> -image: ubuntu/lts +image: ubuntu/jammy shell: true +repositories: + # For more versions than just the default python3 + deadsnakes: https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy main "BA6932366A755776" +environment: + PYTHON_VERSIONS: + - '3.7' + - '3.8' + - '3.9' + - '3.10' + - '3.11' tasks: - - setup-lint-env: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends python-is-python3 python3-venv - python -m venv .venv + - setup-python: | + portage/.builds/setup-python.sh "${PYTHON_VERSIONS[@]}" + + - setup-black: | source .venv/bin/activate - pip install --upgrade pip pip install black + deactivate - black: | source .venv/bin/activate @@ -18,3 +28,4 @@ tasks: xargs grep -l '#!/usr/bin/env python' | \ tr '\n' ' ')" black --check --diff --color . $STRAGGLERS + deactivate diff --git a/.builds/setup-python.sh b/.builds/setup-python.sh new file mode 100755 index 000000000..be113ce8e --- /dev/null +++ b/.builds/setup-python.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Maintainer: Oskari Pirhonen <xxc3ncoredxx@gmail.com> + +set -ex + +install_versions=( "${@/#/python}" ) + +sudo apt-get install -y --no-install-recommends \ + python-is-python3 \ + "${install_versions[@]}" \ + "${install_versions[@]/%/-venv}" + +for py in "${@}"; do + "python$py" -m venv ".venv-$py" + source ".venv-$py/bin/activate" + pip install --upgrade pip + deactivate +done + +python -m venv .venv +source .venv/bin/activate +pip install --upgrade pip +deactivate |