Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 88 additions & 0 deletions .github/scripts/python_versions.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

# ==================================================================================================================================
# 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()
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
# ----------------------------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/python-versions.yml
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

# ==================================================================================================================================
# 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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading