Repository navigation
ci: check pull requests for new lint findings and new test failures - #1447
Closed
srikoushik wants to merge 1 commit into
Closed
srikoushik wants to merge 1 commit into
srikoushik wants to merge 1 commit into
Conversation
Nothing runs on pull requests today, and dev already has 38 failing tests and 137 ruff findings, so a new problem is hard to spot by eye. core-stack-org#1419 and core-stack-org#1420 show the cost: a repeated dict key (ruff F601) and then a regression that an existing test caught, both merged unnoticed. Add a "Checks" workflow for pull requests into dev and main. Each job compares the pull request with its target branch and fails only on what the pull request adds, so existing problems don't block anyone and no list of known failures has to be maintained: - lint: ruff 0.17.3 with bug-catching rules only (syntax errors, repeated dict keys, redefinitions, undefined names), counted per file and rule; - tests: runs in the published ghcr.io/core-stack-org/core-stack-backend image with a Postgres service, generates migrations the way database-init.sh does, runs `manage.py check`, then the suite on both branches, and fails if a test fails only on the pull request. Settings get placeholder values and a throwaway Fernet key; no secrets are needed. The workflow only reports a status; whether it blocks merging is a branch-protection setting for the maintainers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@amanodt could you review this when you get a chance? It adds PR checks that fail only on what a PR adds (new ruff findings of bug-catching kinds, a newly broken |
This was referenced Nov 4, 2026
Contributor
Author
|
Closing for now; I'll come back to this later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1446
Summary
Adds a "Checks" workflow that runs on every pull request into
devandmain. It fails only on problems the pull request adds: new lint findings of a bug-catching kind, a newly brokenmanage.py check, or newly failing tests. Existing problems ondevdon't block anyone, and there's no list of known failures to maintain.Size: 3 new files (workflow plus two small scripts); no application code changes.
Problem
Nothing checks pull requests today.
devalready has 38 failing test entries and 137 ruff findings of the kinds below, so a new problem is hard to see by eye. #1419 and #1420 show the cost: a repeated dict key (ruff F601) and then a regression an existing test caught, both merged unnoticed (#1432).Root cause
No CI for pull requests: the only workflows publish the Docker image and run Copilot's review.
Fix
.github/workflows/checks.yml, two jobs, each comparing the PR with its target branch:ruff0.17.3, rulesE9,F63,F7,F82,F601,F811(syntax errors, repeated dict keys, redefinitions, undefined names), notebooks excludedinstallation/environment.yml(mamba-org/setup-micromamba, cached); apostgres:16service; migrations generated the waydatabase-init.shdoes; thenmanage.py checkand the suite on both branchescheckpasses on the target branch but not on the PR, or a test fails only on the PRScripts:
.github/scripts/no_new_ruff_findings.py.github/scripts/no_new_test_failures.shSettings:
CELERY_TASK_ALWAYS_EAGER=True: CI has no broker or workers. With eager mode off, 76 tests wait on broker retries, which took the suite from 15 s to about 8 minutes.Why build the environment rather than use the published image: the image is only rebuilt when
environment.ymlchanges onmain. Building from the PR'senvironment.ymltests exactly what each branch declares, so a missing dependency shows up straight away. It's cached, so later runs take about 30 s to set up.Tests
New checks; no new unit tests. Trialled on the fork (
fplaunchpad/core-stack-backend), with a base branch identical todev@bd8fbcd0, and locally with deliberate breakages:devitself can't run its suite (see below)devvsdevlayer_generation_in_order.py:302: F601F821 Undefined nameparse_boolbrokenParseBoolTests.test_valuesmanage.py checkbrokenVerification
actionlinton the workflowshellcheckon the shell scriptblack,flake8on the Python scriptbanditon the Python scriptsubprocess), a false positive: fixed argument list, no shell, the only input is the ruff pathactions/checkout@v6,mamba-org/setup-micromamba@v3, taken from the current official docsEvidence
What CI found on
devtoday: the app can't start fromenvironment.ymlpyogrio,rasterstatsands2sphereare imported by modules loaded at startup (swb3_local.py,farm_boundaries/fetch_raw.py), but none is inenvironment.yml, ondev,stagingormain. Fresh installs fromenvironment.yml(the Docker image,install.sh) therefore can't start. A fix adding them is ready on a branch, and I'll raise it as a separate issue and PR. Until it lands, the test job passes with this warning; once it lands, the full comparison runs.With the dependency fix: the full comparison
Security and performance
permissions: contents: read; no secrets.pull_request, so PRs from forks get a read-only token. First-time contributors' runs need a maintainer's approval, as GitHub sets by default.actions/checkoutandmamba-org/setup-micromamba.Risk and rollback
Related
environment.ymldependency fix (separate PR); fixing the 36 existing failures.Reviewer checklist
🤖 Generated with Claude Code