From a25162e999e8f4d15d30b7a41d103a8f1cbf303f Mon Sep 17 00:00:00 2001 From: Scott Converse Date: Thu, 19 Nov 2026 20:44:44 -0700 Subject: [PATCH 1/3] ci: run full component Python suite on Windows --- .github/scripts/prepare-windows-test-db.ps1 | 56 +++++++++++++++++++++ .github/workflows/windows-contracts.yml | 30 ++++++++--- docs/WINDOWS-CI.md | 7 +++ 3 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 .github/scripts/prepare-windows-test-db.ps1 create mode 100644 docs/WINDOWS-CI.md diff --git a/.github/scripts/prepare-windows-test-db.ps1 b/.github/scripts/prepare-windows-test-db.ps1 new file mode 100644 index 0000000..8f63486 --- /dev/null +++ b/.github/scripts/prepare-windows-test-db.ps1 @@ -0,0 +1,56 @@ +param([switch]$WithVector, [switch]$WithPostgis) +$ErrorActionPreference = 'Stop' +$pgroot = $env:PGROOT +if (-not $pgroot) { $pgroot = 'C:\Program Files\PostgreSQL\17' } +$pgbin = Join-Path $pgroot 'bin' +if (-not (Test-Path (Join-Path $pgbin 'initdb.exe'))) { throw 'Hosted Windows PostgreSQL 17 tools are missing.' } +if ($WithVector) { + $vector = Join-Path $env:RUNNER_TEMP 'townlight-test-pgvector' + git clone --depth 1 --branch v0.8.2 https://github.com/pgvector/pgvector.git $vector + if ($LASTEXITCODE -ne 0) { throw 'pgvector source checkout failed.' } + $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' + $vs = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + $devcmd = Join-Path $vs 'Common7\Tools\VsDevCmd.bat' + if (-not (Test-Path $devcmd)) { throw 'Hosted MSVC build tools are missing.' } + Push-Location $vector + try { + $command = 'call "' + $devcmd + '" -arch=x64 -host_arch=x64 >nul && set "PGROOT=' + $pgroot + '" && nmake /F Makefile.win && nmake /F Makefile.win install' + & cmd.exe /d /s /c $command + if ($LASTEXITCODE -ne 0) { throw 'Windows pgvector build/install failed.' } + } finally { Pop-Location } +} +if ($WithPostgis) { + $archive = Join-Path $env:RUNNER_TEMP 'postgis.zip' + Invoke-WebRequest -Uri 'https://download.osgeo.org/postgis/windows/pg17/archive/postgis-bundle-pg17-3.6.2x64.zip' -OutFile $archive + if ((Get-FileHash -LiteralPath $archive -Algorithm SHA256).Hash.ToLowerInvariant() -ne '7ba180ee2a352987b9a2f194673652c59483b55852295ccf401dceccd8765425') { throw 'PostGIS hash mismatch.' } + $unpack = Join-Path $env:RUNNER_TEMP 'postgis' + Expand-Archive -LiteralPath $archive -DestinationPath $unpack + $bundle = Join-Path $unpack 'postgis-bundle-pg17-3.6.2x64' + foreach ($name in @('bin','lib','share')) { + Get-ChildItem -LiteralPath (Join-Path $bundle $name) -Force | Copy-Item -Destination (Join-Path $pgroot $name) -Recurse -Force + } +} +"PGBIN=$pgbin" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 +$cluster = Join-Path $env:RUNNER_TEMP 'townlight-test-pg' +$password = [Guid]::NewGuid().ToString('N') +Write-Output "::add-mask::$password" +$pwfile = Join-Path $env:RUNNER_TEMP 'townlight-test-pg-password' +[IO.File]::WriteAllText($pwfile, $password) +try { + & "$pgbin\initdb.exe" -D $cluster -U postgres --auth=scram-sha-256 --pwfile=$pwfile --encoding=UTF8 + if ($LASTEXITCODE -ne 0) { throw 'Private test cluster initialization failed.' } +} finally { Remove-Item -LiteralPath $pwfile -Force } +& "$pgbin\pg_ctl.exe" -D $cluster -l (Join-Path $env:RUNNER_TEMP 'townlight-test-pg.log') -o '-h 127.0.0.1 -p 55439' -w start +if ($LASTEXITCODE -ne 0) { throw 'Private loopback test cluster failed to start.' } +$env:PGPASSWORD = $password +& "$pgbin\createdb.exe" -h 127.0.0.1 -p 55439 -U postgres planning_p1p2_test +if ($LASTEXITCODE -ne 0) { throw 'Private test database creation failed.' } +"DATABASE_URL=postgresql+asyncpg://postgres:$password@127.0.0.1:55439/postgres" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 +"PLANNING_TEST_DATABASE_URL=postgresql+psycopg2://postgres:$password@127.0.0.1:55439/planning_p1p2_test" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 + +foreach ($name in @('townlight_meetings_windows_test','townlight_zoning_test')) { + & "$pgbin/createdb.exe" -h 127.0.0.1 -p 55439 -U postgres $name + if ($LASTEXITCODE -ne 0) { throw "Could not create $name" } +} +"TOWNLIGHT_MEETINGS_TEST_DATABASE_URL=postgresql+psycopg2://postgres:$password@127.0.0.1:55439/townlight_meetings_windows_test" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 +"TOWNLIGHT_ZONING_TEST_DATABASE_URL=postgresql+psycopg2://postgres:$password@127.0.0.1:55439/townlight_zoning_test" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 diff --git a/.github/workflows/windows-contracts.yml b/.github/workflows/windows-contracts.yml index 164d53c..67c4bd7 100644 --- a/.github/workflows/windows-contracts.yml +++ b/.github/workflows/windows-contracts.yml @@ -1,17 +1,17 @@ name: Windows component contracts on: pull_request: - paths: ["**/*.py", "**/pyproject.toml", ".github/workflows/windows-contracts.yml"] - push: - paths: ["**/*.py", "**/pyproject.toml", ".github/workflows/windows-contracts.yml"] - branches: [main] + paths: ["**/*.py", "**/*.toml", "**/*.sql", "**/*.json", "**/*.ini", "**/*.cfg", "**/*.ps1", "**/*.sh", "**/*.yaml", "**/*.yml", "**/requirements*.txt", "**/*.lock"] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true permissions: contents: read jobs: windows-contracts: runs-on: windows-latest - timeout-minutes: 20 + timeout-minutes: 45 defaults: run: working-directory: . @@ -20,12 +20,18 @@ jobs: - uses: actions/setup-python@v6 with: python-version: '3.13' + cache: pip + cache-dependency-path: '**/pyproject.toml' - name: Install pinned shared Core run: python -m pip install git+https://github.com/townlight/core.git@3021821bf9a92c790a399ad12aed821d65b09105 - name: Install component and test tools run: python -m pip install -e ".[dev]" pytest - - name: Run existing Windows contracts - run: python -X utf8 -m pytest tests/test_runtime_foundation.py tests/test_milestone_3_parcel_lookup.py tests/test_milestone_4_use_dimensional_rules.py -q --junitxml=windows-contracts.xml + - name: Prepare isolated Windows PostgreSQL fixture + working-directory: . + shell: pwsh + run: ./.github/scripts/prepare-windows-test-db.ps1 -WithVector -WithPostgis + - name: Run full Python suite on Windows + run: python -X utf8 -m pytest tests -q -ra --junitxml=windows-contracts.xml - name: Preserve results if: always() uses: actions/upload-artifact@v4 @@ -33,3 +39,13 @@ jobs: name: windows-contract-results path: ./windows-contracts.xml retention-days: 7 + - name: Stop owned test database + if: always() + working-directory: . + shell: pwsh + run: | + $cluster = Join-Path $env:RUNNER_TEMP 'townlight-test-pg' + if (Test-Path (Join-Path $cluster 'postmaster.pid')) { + & "$env:PGBIN/pg_ctl.exe" -D $cluster -m fast -w stop + if ($LASTEXITCODE -ne 0) { throw 'Owned test database did not stop.' } + } diff --git a/docs/WINDOWS-CI.md b/docs/WINDOWS-CI.md new file mode 100644 index 0000000..2bbc0e4 --- /dev/null +++ b/docs/WINDOWS-CI.md @@ -0,0 +1,7 @@ +# Windows component testing + +The Windows component workflow collects and runs the full Python tests directory. +SQL, configuration, dependency and script changes trigger the job alongside Python changes. +JUnit results retain exact passes, failures and explicit platform/dependency skips. +The existing hosted database/browser checks remain; component tests do not establish signed MSI installed acceptance. +The obsolete manual release-preflight workflow is preserved under docs/history/retired-workflows-2026-11, not used to describe current release readiness. From bf926e1370688960e52cc0d79472045a5863eef0 Mon Sep 17 00:00:00 2001 From: Scott Converse Date: Thu, 19 Nov 2026 20:47:45 -0700 Subject: [PATCH 2/3] ci: add scoped security scanning and maintainer ownership --- .github/CODEOWNERS | 2 ++ .github/dependabot.yml | 12 ++++++++++++ .github/workflows/codeql.yml | 30 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5494be9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Maintainer ownership; existing repository review rules are unchanged. +* @scottconverse diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e958cb7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 +- package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..537c4a9 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,30 @@ +name: CodeQL +'on': + pull_request: + paths: + - '**/*.py' + - '**/*.js' + - '**/*.ts' + - '**/*.tsx' + - '**/*.jsx' + - '**/pyproject.toml' + - '**/package*.json' + - .github/workflows/codeql.yml + workflow_dispatch: null +permissions: + contents: read + security-events: write +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + analyze: + runs-on: windows-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v5 + - uses: github/codeql-action/init@v4 + with: + languages: python + build-mode: none + - uses: github/codeql-action/analyze@v4 From 4520616b7d794e1d682cdc9cf475b4e0ac3102ef Mon Sep 17 00:00:00 2001 From: Scott Converse Date: Thu, 19 Nov 2026 20:51:20 -0700 Subject: [PATCH 3/3] test: exercise PostgreSQL contracts on native Windows fixtures --- .github/workflows/windows-contracts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/windows-contracts.yml b/.github/workflows/windows-contracts.yml index 67c4bd7..255719b 100644 --- a/.github/workflows/windows-contracts.yml +++ b/.github/workflows/windows-contracts.yml @@ -30,6 +30,12 @@ jobs: working-directory: . shell: pwsh run: ./.github/scripts/prepare-windows-test-db.ps1 -WithVector -WithPostgis + - name: Migrate isolated geographic test database + shell: pwsh + run: | + $env:DATABASE_URL = $env:TOWNLIGHT_ZONING_TEST_DATABASE_URL + python -m alembic -c townlight_zoning/migrations/alembic.ini upgrade head + if ($LASTEXITCODE -ne 0) { throw 'Zoning fixture migration failed.' } - name: Run full Python suite on Windows run: python -X utf8 -m pytest tests -q -ra --junitxml=windows-contracts.xml - name: Preserve results