From 36e2e8a32dbd96d087ee0b7a4ae41d140bd154c5 Mon Sep 17 00:00:00 2001 From: deadc0de6 <8973919+deadc0de6@users.noreply.github.com.> Date: Tue, 30 Dec 2025 17:17:19 +0100 Subject: [PATCH] more python versions support --- .github/workflows/pypi-release.yml | 2 +- .github/workflows/testing.yml | 4 +- .gitignore | 4 ++ pyproject.toml | 4 ++ scripts/check-syntax.sh | 7 ++- tests.sh | 84 ++++++++++++++++++++++-------- 6 files changed, 79 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 9c56bd5..cc54793 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install Tools diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8bcf355..5c9933e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -2,10 +2,10 @@ name: tests on: [push, pull_request, workflow_dispatch] jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 4c898ba..eea1d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ build/ tags env venv +.venv +.venv* +.env +.env* .pytest_cache .mypy_cache diff --git a/pyproject.toml b/pyproject.toml index c9a9a4b..25dbed2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,11 +11,15 @@ license = 'GPL-3.0' requires-python = ">=3" classifiers = [ 'Development Status :: 5 - Production/Stable', + 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', ] keywords = ['dotfiles', 'jinja2'] dependencies = [ diff --git a/scripts/check-syntax.sh b/scripts/check-syntax.sh index e97be17..35b07f3 100755 --- a/scripts/check-syntax.sh +++ b/scripts/check-syntax.sh @@ -117,7 +117,12 @@ done # check other python scripts echo "-----------------------------------------" echo "checking other python scripts with pylint" -find . -name "*.py" -not -path "./dotdrop/*" -not -regex "\./\.?v?env/.*" | while read -r script; do +find . \ + -path "./dotdrop" -prune -o \ + -path "./.venv" -prune -o \ + -path "./venv" -prune -o \ + -path "./build" -prune -o \ + -name "*.py" -print | while read -r script; do echo "checking ${script}" pylint -sn \ --disable=W0012 \ diff --git a/tests.sh b/tests.sh index 330a8db..07845b4 100755 --- a/tests.sh +++ b/tests.sh @@ -5,6 +5,38 @@ # stop on first error set -eu -o errtrace -o pipefail +MULTI_PYTHON="" # set to test multi python envs +PYTHON_VERSIONS=("3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12" "3.13" "3.14") + +test() +{ + echo "=> python version:" + python3 --version + + # test syntax + echo "checking syntax..." + "${cur}"/scripts/check-syntax.sh + + # unittest + echo "unittest..." + "${cur}"/scripts/check-unittests.sh + + # tests-ng + if [ -n "${in_cicd}" ]; then + # in CI/CD + export DOTDROP_WORKERS=1 + echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..." + "${cur}"/scripts/check-tests-ng.sh + + export DOTDROP_WORKERS=4 + echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..." + "${cur}"/scripts/check-tests-ng.sh + else + echo "tests-ng..." + "${cur}"/scripts/check-tests-ng.sh + fi +} + cur=$(cd "$(dirname "${0}")" && pwd) in_cicd="${GITHUB_WORKFLOW:-}" @@ -24,32 +56,40 @@ if [ "${dotdrop_version}" != "${man_version}" ]; then fi echo "current dotdrop version ${dotdrop_version}" -echo "=> python version:" -python3 --version - -# test syntax -echo "checking syntax..." -"${cur}"/scripts/check-syntax.sh - -# unittest -echo "unittest..." -"${cur}"/scripts/check-unittests.sh - -# tests-ng if [ -n "${in_cicd}" ]; then - # in CI/CD - export DOTDROP_WORKERS=1 - echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..." - "${cur}"/scripts/check-tests-ng.sh - - export DOTDROP_WORKERS=4 - echo "tests-ng with ${DOTDROP_WORKERS} worker(s)..." - "${cur}"/scripts/check-tests-ng.sh + test else - echo "tests-ng..." - "${cur}"/scripts/check-tests-ng.sh + if [ -n "${MULTI_PYTHON}" ]; then + if ! hash pyenv &>/dev/null; then + echo "install pyenv" + exit 1 + fi + + eval "$(pyenv init -)" + for PY in "${PYTHON_VERSIONS[@]}"; do + echo "============== python ${PY} ==============" + pyenv install -s "${PY}" + pyenv shell "${PY}" + python -m venv ".venv" + source ".venv/bin/activate" + pip install pip --upgrade + pip install -r requirements.txt + pip install -r tests-requirements.txt + test + deactivate + done + else + python3 -m venv ".venv" + source ".venv/bin/activate" + pip install pip --upgrade + pip install -r requirements.txt + pip install -r tests-requirements.txt + test + deactivate + fi fi + # merge coverage coverage combine coverages/* coverage xml