diff --git a/.github/scripts/convergence.py b/.github/scripts/convergence.py index 30cd3ca..f3f1b64 100644 --- a/.github/scripts/convergence.py +++ b/.github/scripts/convergence.py @@ -4,7 +4,7 @@ # # This file is part of PyHOPE # -# Copyright (c) 2024 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck # # PyHOPE is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software diff --git a/.github/scripts/python_versions.py b/.github/scripts/python_versions.py new file mode 100644 index 0000000..704c204 --- /dev/null +++ b/.github/scripts/python_versions.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of PyHOPE +# +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# +# PyHOPE is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# PyHOPE is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# PyHOPE. If not, see . + +# ================================================================================================================================== +# Continuous Integration/Continuous Deployment +# ================================================================================================================================== +# ---------------------------------------------------------------------------------------------------------------------------------- +# Standard libraries +# ---------------------------------------------------------------------------------------------------------------------------------- +import json +import re +import subprocess +import urllib.request +from pathlib import Path +from typing import Final +# ---------------------------------------------------------------------------------------------------------------------------------- +# Third-party libraries +# ---------------------------------------------------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------------------------------------------------- +# Local imports +# ---------------------------------------------------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------------------------------------------------- +# Local definitions +# ---------------------------------------------------------------------------------------------------------------------------------- +groot: Final[Path] = Path(subprocess.check_output(['git', 'rev-parse', '--show-toplevel'], text=True).strip()) +files: Final[tuple[Path, ...]] = (Path(groot / '.github/workflows/ci.yml'), + Path(groot / '.gitlab-ci.yml')) +# ================================================================================================================================== + + +def update_python() -> None: + versions = {} + url = ('https://hub.docker.com/v2/repositories/library/python/tags?name=slim-trixie&page_size=100&ordering=last_updated') + + while url: + req = urllib.request.Request(url, headers={'User-Agent': 'pyhope-ci-script'}) + with urllib.request.urlopen(req, timeout=30) as response: + data = json.loads(response.read().decode('utf-8')) + + for result in data.get('results', []): + tag = result.get('name', '') + match = re.match(r'^3\.(\d+)\.(\d+)-slim-trixie$', tag) + if match: + minor, patch = int(match.group(1)), int(match.group(2)) + key = f'3.{minor}' + if key not in versions or patch > versions[key]['patch']: + versions[key] = {'patch': patch, 'full': tag} + + url = data.get('next') + + print(f'Detected latest Python versions: { {k: v["full"] for k, v in versions.items()} }') + + for path in files: + if not path.exists(): + print(f'Skipping {path}: file not found.') + continue + + content = path.read_text(encoding='utf-8') + + for key, info in versions.items(): + minor = key.split('.')[1] # '3.11' -> '11' + patch = info['patch'] + content = re.sub(rf'(3\.{minor}\.)\d+(-slim-trixie)', rf'\g<1>{patch}\g<2>', content) + content = re.sub(rf'(PYTHON3{minor}_VERSION:\s*3\.{minor}\.)\d+(-trixie)', rf'\g<1>{patch}\g<2>', content) + + path.write_text(content, encoding='utf-8') + print(f'Successfully updated {path}') + + +if __name__ == '__main__': + update_python() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fa35e6..51c4d62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ # # This file is part of PyHOPE # -# Copyright (c) 2024 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck # # PyHOPE is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software @@ -54,9 +54,9 @@ env: # Define the Python version # PYTHON311_VERSION: 3.11.17-slim-trixie # PYTHON312_VERSION: 3.12.15-slim-trixie - # PYTHON313_VERSION: 3.13.16-slim-trixie - # PYTHON314_VERSION: 3.14.8-slim-trixie - # PYTHON315_VERSION: 3.15.0-slim-trixie + # PYTHON313_VERSION: 3.13.17-slim-trixie + # PYTHON314_VERSION: 3.14.9-slim-trixie + # PYTHON315_VERSION: 3.15.1-slim-trixie jobs: # ---------------------------------------------------------------------------------------------------------------------------------------------------- @@ -66,7 +66,7 @@ jobs: name: Lint / ruff runs-on: ubuntu-latest container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: - uses: actions/checkout@v7 # with: @@ -86,7 +86,7 @@ jobs: name: Lint / ty runs-on: ubuntu-latest container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: # Git LFS requires git - name: Run Install Git LFS @@ -111,7 +111,7 @@ jobs: name: Lint / vulture runs-on: ubuntu-latest container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: - uses: actions/checkout@v7 # with: @@ -183,9 +183,9 @@ jobs: include: - { python-version: "3.11", image: "python:3.11.17-slim-trixie" } - { python-version: "3.12", image: "python:3.12.15-slim-trixie" } - - { python-version: "3.13", image: "python:3.13.16-slim-trixie" } - - { python-version: "3.14", image: "python:3.14.8-slim-trixie" } - - { python-version: "3.15", image: "python:3.15.0-slim-trixie" } + - { python-version: "3.13", image: "python:3.13.17-slim-trixie" } + - { python-version: "3.14", image: "python:3.14.9-slim-trixie" } + - { python-version: "3.15", image: "python:3.15.1-slim-trixie" } container: image: ${{ matrix.image }} steps: @@ -217,7 +217,7 @@ jobs: runs-on: ubuntu-latest needs: [compatibility] container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: # Git LFS requires git - name: Install Git LFS @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest needs: [compatibility] container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: # Git LFS requires git - name: Install Git LFS @@ -378,7 +378,7 @@ jobs: runs-on: ubuntu-latest needs: [examples, healthcheck] container: - image: python:3.15.0-slim-trixie + image: python:3.15.1-slim-trixie steps: - uses: actions/checkout@v7 # with: diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 68395e1..09f1d39 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -4,7 +4,7 @@ # # This file is part of PyHOPE # -# Copyright (c) 2024 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck # # PyHOPE is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software diff --git a/.github/workflows/python-versions.yml b/.github/workflows/python-versions.yml new file mode 100644 index 0000000..dd1a662 --- /dev/null +++ b/.github/workflows/python-versions.yml @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of PyHOPE +# +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# +# PyHOPE is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# PyHOPE is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# PyHOPE. If not, see . + +# ================================================================================================================================== +# Continuous Integration/Continuous Deployment +# ================================================================================================================================== + +# Workflow for continuous integration (CI) +name: Python Versions + +on: + # Runs on weekly schedule + schedule: + - cron: '0 0 * * 1' + # Allows running this workflow manually from the Actions tab + workflow_dispatch: + +# Permissions +permissions: + contents: write + pull-requests: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued +concurrency: + group: update-python-versions + cancel-in-progress: true + +# ---------------------------------------------------------------------------------------------------------------------------------------------------- +# Update Python versions +# ---------------------------------------------------------------------------------------------------------------------------------------------------- +jobs: + update: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + # Prepare the image + - uses: actions/checkout@v7 + - uses: actions/setup-python@v7 + with: + python-version: '3.x' + + # Run the update script + - name: Update Python versions + run: python3 .github/scripts/python_versions.py + + # Create pull request + - name: Create Pull Request + uses: peter-evans/create-pull-request@v8 + with: + add-paths: | + .github/workflows/ci.yml + .gitlab-ci.yml + commit-message: 'CI/CD: Update Python versions' + title: 'CI/CD: Update Python versions' + body: 'Automated update of the Python base images to the latest patch releases.' + branch: cicd.python.autoupdate + delete-branch: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0d7bcb..0f8aaa4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ # # This file is part of PyHOPE # -# Copyright (c) 2024 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck +# Copyright (c) 2024 - 2026 Numerics Research Group, University of Stuttgart, Prof. Andrea Beck # # PyHOPE is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71a3dc1..976970c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,9 +32,9 @@ variables: # Define the Python version PYTHON311_VERSION: 3.11.17-trixie PYTHON312_VERSION: 3.12.15-trixie - PYTHON313_VERSION: 3.13.16-trixie - PYTHON314_VERSION: 3.14.8-trixie - PYTHON315_VERSION: 3.15.0-trixie + PYTHON313_VERSION: 3.13.17-trixie + PYTHON314_VERSION: 3.14.9-trixie + PYTHON315_VERSION: 3.15.1-trixie # Official language image. Look for the different tagged releases at: # > https://hub.docker.com/r/library/python/tags diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2f898f..a1f877f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ minimum_pre_commit_version: 4.5.1 repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version - rev: v0.17.1 + rev: v0.17.2 hooks: # Run the linter - id: ruff @@ -27,7 +27,7 @@ repos: - repo: https://github.com/astral-sh/ty-pre-commit # Ty version - rev: v0.0.89 + rev: v0.0.91 hooks: # Run the type checker - id: ty