commit: 9dca151ad11df75a1842afd2bee9bad9c9ee0c37 Author: Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com> AuthorDate: Thu Mar 30 04:53:51 2023 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Apr 7 09:49:59 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9dca151a
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 <AT> gmail.com> Signed-off-by: Sam James <sam <AT> gentoo.org> .builds/lint.yml | 23 +++++++++++++++++------ .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 <xxc3ncore...@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 <xxc3ncore...@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