From 2862238ee53fbe6ffc076192891f185336f36147 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 2 Aug 2024 07:40:14 +0200 Subject: [PATCH] Allow extended exclude and disable patterns. --- .github/workflows/Parameters.yml | 28 ++++++++++++++++++++++----- pyproject.toml | 2 +- tests/python_jobs.py | 33 ++++++++++++++++++++++++++------ tests/requirements.txt | 2 +- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Parameters.yml b/.github/workflows/Parameters.yml index 37bec94..c1f40ae 100644 --- a/.github/workflows/Parameters.yml +++ b/.github/workflows/Parameters.yml @@ -203,26 +203,44 @@ jobs: for disable in disabled: print(f"- {disable}") + def match(combination: str, pattern: str) -> bool: + system, version = combination.split(":") + sys, ver = pattern.split(":") + + if sys == "*": + return (ver == "*") or (version == ver) + elif system == sys: + return (ver == "*") or (version == ver) + else: + return False + + def notIn(combination: str, patterns: Iterable[str]) -> bool: + for pattern in patterns: + if match(combination, pattern): + return False + + return True + combinations = [ (system, version) for system in systems if system in data["sys"] for version in versions if version in data["python"] - and f"{system}:{version}" not in excludes - and f"{system}:{version}" not in disabled + and notIn(f"{system}:{version}", excludes) + and notIn(f"{system}:{version}", disabled) ] + [ (system, currentMSYS2Version) for system in systems if system in data["runtime"] - and f"{system}:{currentMSYS2Version}" not in excludes - and f"{system}:{currentMSYS2Version}" not in disabled + and notIn(f"{system}:{currentMSYS2Version}", excludes) + and notIn(f"{system}:{currentMSYS2Version}", disabled) ] + [ (system, version) for system, version in includes if system in data["sys"] and version in data["python"] - and f"{system}:{version}" not in disabled + and notIn(f"{system}:{version}", disabled) ] print(f"Combinations ({len(combinations)}):") for system, version in combinations: diff --git a/pyproject.toml b/pyproject.toml index 63ef1c4..44b24c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools ~= 71.1", + "setuptools ~= 72.1", "wheel ~= 0.43", "pyTooling ~= 6.5" ] diff --git a/tests/python_jobs.py b/tests/python_jobs.py index ac8e2c7..36e892e 100644 --- a/tests/python_jobs.py +++ b/tests/python_jobs.py @@ -2,10 +2,11 @@ from json import dumps as json_dumps from os import getenv from pathlib import Path from textwrap import dedent +from typing import Iterable name = "example".strip() python_version = "3.12".strip() -systems = "ubuntu windows macos mingw64 ucrt64".strip() +systems = "ubuntu windows macos-arm mingw64 ucrt64".strip() versions = "3.8 3.9 3.10 3.11 3.12".strip() include_list = "".strip() exclude_list = "".strip() @@ -93,26 +94,46 @@ print(f"disabled ({len(disabled)}):") for disable in disabled: print(f"- {disable}") + +def match(combination: str, pattern: str) -> bool: + system, version = combination.split(":") + sys, ver = pattern.split(":") + + if sys == "*": + return (ver == "*") or (version == ver) + elif system == sys: + return (ver == "*") or (version == ver) + else: + return False + + +def notIn(combination: str, patterns: Iterable[str]) -> bool: + for pattern in patterns: + if match(combination, pattern): + return False + + return True + combinations = [ (system, version) for system in systems if system in data["sys"] for version in versions if version in data["python"] - and f"{system}:{version}" not in excludes - and f"{system}:{version}" not in disabled + and notIn(f"{system}:{version}", excludes) + and notIn(f"{system}:{version}", disabled) ] + [ (system, currentMSYS2Version) for system in systems if system in data["runtime"] - and f"{system}:{currentMSYS2Version}" not in excludes - and f"{system}:{currentMSYS2Version}" not in disabled + and notIn(f"{system}:{currentMSYS2Version}", excludes) + and notIn(f"{system}:{currentMSYS2Version}", disabled) ] + [ (system, version) for system, version in includes if system in data["sys"] and version in data["python"] - and f"{system}:{version}" not in disabled + and notIn(f"{system}:{version}", disabled) ] print(f"Combinations ({len(combinations)}):") for system, version in combinations: diff --git a/tests/requirements.txt b/tests/requirements.txt index ea876b3..b7fdbd9 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -8,6 +8,6 @@ pytest ~= 8.3 pytest-cov ~= 5.0 # Static Type Checking -mypy ~= 1.10 +mypy ~= 1.11 typing_extensions ~= 4.12 lxml ~= 5.2