From a98e0a7140612d5025c87945a11d902d006fe03a Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 18 Nov 2026 01:37:33 +0100 Subject: [PATCH] chore: check install.py against installer/ in CI validate.yml and pr_checks.py run build_installer.py --check after the lint, vermin holds installer/ to 3.8 beside install.py, mypy and ruff read the package, and both workflows trigger on installer/**. CONTRIBUTING says where installer changes go. --- .github/workflows/deploy-site.yml | 1 + .github/workflows/validate.yml | 17 ++++++++++---- CONTRIBUTING.md | 39 +++++++++++++++++++------------ pyproject.toml | 13 +++++++---- scripts/generate_readme.py | 8 +++++++ scripts/pr_checks.py | 5 ++-- 6 files changed, 57 insertions(+), 26 deletions(-) diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index a34ef59ae..343ac6550 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -93,6 +93,7 @@ on: # The site serves install.sh and install.ps1 pinned to install.py # of the commit it is built from (scripts/sitebootstrap.py). - "install.py" + - "installer/**" - "install.sh" - "install.ps1" # The handheld launchers it serves are built from ports/ at the same diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 0a360a027..52ff0068f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -13,8 +13,10 @@ on: - "scripts/**" - "tests/**" # The bootstraps pin install.py's SHA-256 and a test enforces the pin, - # so editing one without the other has to fail the PR. + # so editing one without the other has to fail the PR. install.py is + # built from installer/, and a step fails when the two differ. - "install.py" + - "installer/**" - "install.sh" - "install.ps1" # The handheld port bundles install.py and its tests read both. @@ -49,6 +51,7 @@ on: - "scripts/**" - "tests/**" - "install.py" + - "installer/**" - "install.sh" - "install.ps1" - "ports/**" @@ -187,6 +190,11 @@ jobs: pip install "ruff==0.17.3" ruff check --output-format=github . + # install.py is generated from the installer/ package: an edit made to + # one side only fails here. + - name: Check that install.py is the one installer/ builds + run: python scripts/build_installer.py --check + # A profile written from a clone can cite lines that do not hold the value # it declares, and schemas and tests pass it. Each profile a change adds is # confronted with its upstream, both roads into main. An edited profile is @@ -248,7 +256,8 @@ jobs: # markdown: the site validation test renders a wiki line to prove the # heading guard's premise, and skipped on every run without it. pyte # reads the installer's full screen back in its end-to-end tests, - # hypothesis fuzzes its key decoder, and vermin holds install.py to 3.8. + # hypothesis fuzzes its key decoder, and vermin holds install.py and its + # installer/ source to 3.8. # setuptools reads pyproject.toml for the packaging guard, and uv builds # the PyPI package the way a release builds it. - name: Install dependencies @@ -259,8 +268,8 @@ jobs: - name: Install the screen tests' dependency for Python 3.8 run: python3.8 -m pip install "pyte==0.8.2" - - name: Hold install.py to Python 3.8 - run: vermin --no-tips -t=3.8- --violations install.py + - name: Hold the installer to Python 3.8 + run: vermin --no-tips -t=3.8- --violations install.py installer # The handheld launchers' test runs shellcheck and fails under CI # without it. The Ubuntu image ships it: this names it if one stops. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d087b830..7ec8cf5a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,14 @@ Full walkthrough: [adding a platform](https://abdess.github.io/retrobios/wiki/ad Full walkthrough: [profiling guide](https://abdess.github.io/retrobios/wiki/profiling/). +## Change the installer + +`install.py` is built from the `installer/` package, one module per concern: +edit the module, then run `python scripts/build_installer.py` and +`python scripts/pin_installer.py`. CI fails when `install.py` is not the file +the package builds. [Changing the installer](https://abdess.github.io/retrobios/wiki/installer/#changing-the-installer) +lists what else a change rewrites. + ## File conventions - `bios/Manufacturer/Console/filename` for canonical files @@ -83,21 +91,22 @@ python scripts/pr_checks.py does, and names at the end each check that failed or could not run: ```bash -python scripts/validate_pr.py --changed # the BIOS files the branch adds -python scripts/validate_schemas.py --source-only # profiles and platform files -mypy # no type error in install.py and scripts/ -ruff check . # the lint rules of pyproject.toml -python scripts/profile_sync.py --added --strict # each profile the branch adds -vermin --no-tips -t=3.8- --violations install.py # install.py stays on Python 3.8 -shellcheck --version # the launcher test runs shellcheck -python scripts/export_native.py --all --refresh-cache # files the exporter tests compare with -python scripts/refresh_data_dirs.py # data directories the pack-building tests read -python scripts/generate_site.py # the pages the site tests read -npm ci --prefix website # the site's packages, Node 24 -npm run build --prefix website # the built site -python scripts/run_tests.py --jobs 4 # the suite, one process per module -python3.8 -m unittest tests.test_install_tui # the full screen on the installer's floor -python scripts/validate_site.py --site-dir website/dist # links and page budgets +python scripts/validate_pr.py --changed # the BIOS files the branch adds +python scripts/validate_schemas.py --source-only # profiles and platform files +mypy # no type error in install.py, installer/ and scripts/ +ruff check . # the lint rules of pyproject.toml +python scripts/build_installer.py --check # install.py is the one installer/ builds +python scripts/profile_sync.py --added --strict # each profile the branch adds +vermin --no-tips -t=3.8- --violations install.py installer # the installer stays on Python 3.8 +shellcheck --version # the launcher test runs shellcheck +python scripts/export_native.py --all --refresh-cache # files the exporter tests compare with +python scripts/refresh_data_dirs.py # data directories the pack-building tests read +python scripts/generate_site.py # the pages the site tests read +npm ci --prefix website # the site's packages, Node 24 +npm run build --prefix website # the built site +python scripts/run_tests.py --jobs 4 # the suite, one process per module +python3.8 -m unittest tests.test_install_tui # the full screen on the installer's floor +python scripts/validate_site.py --site-dir website/dist # links and page budgets ``` The versions are the ones CI pins. Three tools come from the system, not from diff --git a/pyproject.toml b/pyproject.toml index ee472e36a..c85d808b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ version = "1.0.0" description = "BIOS collection manager for retrogaming platforms" # install.py is the only entry point a user runs before cloning, and both # bootstraps accept 3.8, so the floor stays where the bootstraps put it. That -# floor covers install.py alone: the build scripts under scripts/ need 3.9 +# floor covers install.py and its installer/ source: the build scripts need 3.9 # (common.py, which every build script imports, checks it), and CI runs the # test suite on 3.12. requires-python = ">=3.8" @@ -33,7 +33,7 @@ dev = [ "jsonschema[format-nongpl]>=4.23", "markdown>=3.7", # The installer's full-screen tests: pyte reads the screen back, - # hypothesis fuzzes the key decoder, vermin holds install.py to 3.8. + # hypothesis fuzzes the key decoder, vermin holds the installer to 3.8. "pyte>=0.8.2", "hypothesis>=6.100", "vermin>=1.9", @@ -59,8 +59,10 @@ Repository = "https://github.com/Abdess/retrobios" # has installed: yaml, jsonschema and the rest read as Any everywhere. The # code carries no type error and CI fails on any. [tool.mypy] -files = ["install.py", "scripts"] -# The oldest target mypy 2 checks against. install.py's own floor, 3.8, is +# installer/ is the source of install.py and both are checked: the modules one +# by one, and the file they are joined into, which is the one people run. +files = ["install.py", "installer", "scripts"] +# The oldest target mypy 2 checks against. The installer's own floor, 3.8, is # held by vermin (pr_checks.py, validate.yml). python_version = "3.10" explicit_package_bases = true @@ -81,7 +83,7 @@ extend-exclude = ["bios", "tmp", "website", ".cache", "dist", "data"] select = ["E", "F", "W", "B", "C90", "SIM", "PERF", "UP", "RET", "PIE", "PLR09", "PLW1510", "RUF100"] ignore = [ "E501", # long lines are wrapped by hand where it reads better - "UP006", "UP007", "UP035", "UP045", # install.py keeps 3.8 spellings + "UP006", "UP007", "UP035", "UP045", # the installer keeps 3.8 spellings "UP036", # the runtime floor guards (sys.version_info < (3, 9)) are the point "SIM300", # an ALL_CAPS name is not always a constant (_SYSTEM_ROOT) "SIM108", # a ternary is not always clearer than an if block @@ -104,5 +106,6 @@ max-returns = 10 [tool.ruff.lint.per-file-ignores] "install.py" = ["UP"] +"installer/*.py" = ["UP"] # Shell fixtures inside string literals keep the tabs the real files have. "tests/test_launchers_*.py" = ["E101"] diff --git a/scripts/generate_readme.py b/scripts/generate_readme.py index f33464d75..67c04a97b 100644 --- a/scripts/generate_readme.py +++ b/scripts/generate_readme.py @@ -910,6 +910,14 @@ Full walkthrough: [adding a platform]({link("wiki/adding-a-platform")}). Full walkthrough: [profiling guide]({link("wiki/profiling")}). +## Change the installer + +`install.py` is built from the `installer/` package, one module per concern: +edit the module, then run `python scripts/build_installer.py` and +`python scripts/pin_installer.py`. CI fails when `install.py` is not the file +the package builds. [Changing the installer]({link("wiki/installer")}#changing-the-installer) +lists what else a change rewrites. + ## File conventions - `bios/Manufacturer/Console/filename` for canonical files diff --git a/scripts/pr_checks.py b/scripts/pr_checks.py index efa6deb12..7e8ba5ce5 100644 --- a/scripts/pr_checks.py +++ b/scripts/pr_checks.py @@ -40,12 +40,13 @@ class Step: STEPS: tuple[Step, ...] = ( Step("python scripts/validate_pr.py --changed", "the BIOS files the branch adds"), Step("python scripts/validate_schemas.py --source-only", "profiles and platform files"), - Step("mypy", "no type error in install.py and scripts/", needs="mypy", + Step("mypy", "no type error in install.py, installer/ and scripts/", needs="mypy", provider='pip install -e ".[dev]"'), Step("ruff check .", "the lint rules of pyproject.toml", needs="ruff", provider='pip install -e ".[dev]"'), + Step("python scripts/build_installer.py --check", "install.py is the one installer/ builds"), Step("python scripts/profile_sync.py --added --strict", "each profile the branch adds"), - Step("vermin --no-tips -t=3.8- --violations install.py", "install.py stays on Python 3.8", + Step("vermin --no-tips -t=3.8- --violations install.py installer", "the installer stays on Python 3.8", needs="vermin", provider="the pip line of CONTRIBUTING.md"), Step("shellcheck --version", "the launcher test runs shellcheck", needs="shellcheck", provider="the shellcheck package"),