Skip to content

Commit e6e28be

Browse files
authored
BREAK: rename --no-macos to --macos-python-version (#508)
* BEHAVIOR: run MacOS tests on Python 3.10 by default
1 parent a08a3c8 commit e6e28be

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: ComPWA/actions/.github/workflows/[email protected]
3737
with:
3838
coverage-target: compwa_policy
39-
macos-python-version: "3.9"
39+
macos-python-version: "3.10"
4040
specific-pip-packages: ${{ inputs.specific-pip-packages }}
4141
secrets:
4242
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

src/compwa_policy/check_dev_files/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
from compwa_policy.utilities.executor import Executor
4545
from compwa_policy.utilities.match import git_ls_files, matches_patterns
4646
from compwa_policy.utilities.precommit import ModifiablePrecommit
47+
from compwa_policy.utilities.pyproject import PythonVersion
4748

4849
if TYPE_CHECKING:
4950
from collections.abc import Sequence
5051

5152
from compwa_policy.check_dev_files.conda import PackageManagerChoice
52-
from compwa_policy.utilities.pyproject import PythonVersion
5353

5454

5555
def main(argv: Sequence[str] | None = None) -> int: # noqa: PLR0915
@@ -58,6 +58,9 @@ def main(argv: Sequence[str] | None = None) -> int: # noqa: PLR0915
5858
doc_apt_packages = _to_list(args.doc_apt_packages)
5959
environment_variables = _get_environment_variables(args.environment_variables)
6060
is_python_repo = not args.no_python
61+
macos_python_version = (
62+
None if args.macos_python_version == "disable" else args.macos_python_version
63+
)
6164
repo_name, repo_title = _determine_repo_name_and_title(args)
6265
has_notebooks = any(
6366
matches_patterns(file, ["**/*.ipynb"]) for file in git_ls_files(untracked=True)
@@ -86,8 +89,8 @@ def main(argv: Sequence[str] | None = None) -> int: # noqa: PLR0915
8689
environment_variables=environment_variables,
8790
github_pages=args.github_pages,
8891
keep_pr_linting=args.keep_pr_linting,
92+
macos_python_version=macos_python_version,
8993
no_cd=args.no_cd,
90-
no_macos=args.no_macos,
9194
no_milestones=args.no_milestones,
9295
no_pypi=args.no_pypi,
9396
no_version_branches=args.no_version_branches,
@@ -302,10 +305,10 @@ def _create_argparse() -> ArgumentParser:
302305
type=str,
303306
)
304307
parser.add_argument(
305-
"--no-macos",
306-
action="store_true",
307-
default=False,
308-
help="Do not run test job on macOS",
308+
"--macos-python-version",
309+
choices=[*sorted(PythonVersion.__args__), "disable"], # type:ignore[attr-defined]
310+
default="3.10",
311+
help="Run the test job in MacOS on a specific Python version. Use 'disable' to not run the tests on MacOS.",
309312
)
310313
parser.add_argument(
311314
"--no-pypi",

src/compwa_policy/check_dev_files/github_workflows.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def main(
4242
environment_variables: dict[str, str],
4343
github_pages: bool,
4444
keep_pr_linting: bool,
45+
macos_python_version: PythonVersion | None,
4546
no_cd: bool,
46-
no_macos: bool,
4747
no_milestones: bool,
4848
no_pypi: bool,
4949
no_version_branches: bool,
@@ -64,7 +64,7 @@ def main(
6464
doc_apt_packages,
6565
environment_variables,
6666
github_pages,
67-
no_macos,
67+
macos_python_version,
6868
python_version,
6969
single_threaded,
7070
skip_tests,
@@ -132,7 +132,7 @@ def _update_ci_workflow( # noqa: PLR0917
132132
doc_apt_packages: list[str],
133133
environment_variables: dict[str, str],
134134
github_pages: bool,
135-
no_macos: bool,
135+
macos_python_version: PythonVersion | None,
136136
python_version: PythonVersion,
137137
single_threaded: bool,
138138
skip_tests: list[str],
@@ -145,7 +145,7 @@ def update() -> None:
145145
doc_apt_packages,
146146
environment_variables,
147147
github_pages,
148-
no_macos,
148+
macos_python_version,
149149
python_version,
150150
single_threaded,
151151
skip_tests,
@@ -181,7 +181,7 @@ def _get_ci_workflow( # noqa: PLR0917
181181
doc_apt_packages: list[str],
182182
environment_variables: dict[str, str],
183183
github_pages: bool,
184-
no_macos: bool,
184+
macos_python_version: PythonVersion | None,
185185
python_version: PythonVersion,
186186
single_threaded: bool,
187187
skip_tests: list[str],
@@ -191,7 +191,9 @@ def _get_ci_workflow( # noqa: PLR0917
191191
config = yaml.load(path)
192192
__update_env_section(config, environment_variables)
193193
__update_doc_section(config, doc_apt_packages, python_version, github_pages)
194-
__update_pytest_section(config, no_macos, single_threaded, skip_tests, test_extras)
194+
__update_pytest_section(
195+
config, macos_python_version, single_threaded, skip_tests, test_extras
196+
)
195197
__update_style_section(config, python_version, precommit)
196198
return yaml, config
197199

@@ -245,7 +247,7 @@ def __is_remove_style_job(precommit: Precommit) -> bool:
245247

246248
def __update_pytest_section(
247249
config: CommentedMap,
248-
no_macos: bool,
250+
macos_python_version: PythonVersion | None,
249251
single_threaded: bool,
250252
skip_tests: list[str],
251253
test_extras: list[str],
@@ -263,8 +265,10 @@ def __update_pytest_section(
263265
"CODECOV_TOKEN": "${{ secrets.CODECOV_TOKEN }}",
264266
}
265267
config["jobs"]["pytest"]["secrets"] = secrets
266-
if not no_macos:
267-
with_section["macos-python-version"] = DoubleQuotedScalarString("3.9")
268+
if macos_python_version is not None:
269+
with_section["macos-python-version"] = DoubleQuotedScalarString(
270+
macos_python_version
271+
)
268272
if skip_tests:
269273
with_section["skipped-python-versions"] = " ".join(skip_tests)
270274
if single_threaded:

0 commit comments

Comments
 (0)