aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Pirhonen <xxc3ncoredxx@gmail.com>2023-03-29 23:53:51 -0500
committerSam James <sam@gentoo.org>2023-04-07 10:49:59 +0100
commit9dca151ad11df75a1842afd2bee9bad9c9ee0c37 (patch)
treefd8c9e06d3b6928b5c3a929d0a65ecb1649122d0 /.builds
parentci: run black on sourcehut (diff)
downloadportage-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.yml23
-rwxr-xr-x.builds/setup-python.sh23
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