Skip to content

Run the test matrix nightly and turn warnings into errors - #1382

Merged
serhii73 merged 2 commits into
masterfrom
fix-1374-ci-drift
Sep 9, 2026
Merged

serhii73 merged 2 commits into
masterfrom
fix-1374-ci-drift

Conversation

@serhii73

@serhii73 serhii73 commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1374.

Daily schedule

A new Nightly workflow runs the existing Build matrix at 04:17 UTC every day. It calls main.yml through workflow_call, so there is one copy of the matrix, and the legs it runs are the legs pull requests run.

The schedule deliberately lives in its own file. GitHub disables a workflow that has a schedule after 60 days without repository activity, and a disabled workflow answers none of its triggers — so a schedule: added to main.yml would put pull request and push CI behind the same inactivity switch. Master has had 67- and 72-day push gaps in the last 14 months, so that is not hypothetical. With the split, an inactivity disable can only ever silence the nightly.

Daily rather than weekly, because a fixed-weekday cron lands on the 31st of a month roughly once a year (10–12 times in 11 years, with gaps up to 609 days) — the issue's "4 months out of 12" is optimistic by about 4x. 04:17 is off the top of the hour, which GitHub names as a high-load window, and early enough in the UTC day that the Pacific/Auckland (UTC+13) and Pacific/Fiji (UTC+12) legs stay on the same calendar date as the rest of the matrix — otherwise a month-end failure would reproduce on 9 legs and not on the other 2.

A failure reaches a human: the report job files one issue per outage, titled The nightly build is failing, and stays quiet until it is closed. The tracking issue is identified by a dedicated nightly-failure label (created idempotently by the job, alongside Type: Maintenance), so retitling it to record the cause does not defeat the dedupe. The job fires on failure or cancelled (a leg that hangs until GitHub kills it is a failure too), on master only, so a dispatch on a work branch can neither file a report nor mask the real one — a dispatch on master exercises the whole path. It uses the preinstalled gh rather than a third-party action, on the grounds that this repo's demonstrated failure mode is action drift. Rationale for filing an issue rather than relying on GitHub's email: the email goes to whichever single person last edited the cron and depends on their personal notification settings, whereas the CIFuzz deprecation annotation below has been on every run since June and nobody has acted on it.

Coverage is uploaded only on push and pull_request: a nightly run, scheduled or dispatched, re-tests a commit that already has a report, so a second upload only re-notifies Codecov for the same SHA. The Nightly token is scoped to contents: read at the workflow level, which the called matrix inherits.

Warnings as errors

pytest.ini gains filterwarnings = error. The suite's own code emits nothing; the three exemptions after error are environmental, not code:

  • tzlocal's two UserWarnings on a host with no or stale time zone configuration (Can not find any timezone configuration, Timezone offset does not match system offset). CI never sees them because main.yml always sets TZ, which takes the code path that skips both — but for a contributor running bare pytest in a container without /etc/localtime, or for nixpkgs' sandbox, they fire inside get_localzone() on every call and fail most of the suite (tests/test_date_parser.py: 484 of 540 failed in the review's reproduction).
  • pytest.PytestCacheWarning in a read-only checkout (docker run -v $PWD:/src:ro, a checkout owned by another user): reproduced — a fully green run exits 1 with the plain error filter and exits 0 with the exemption.

Measured cost, locally, before committing to it — identical pass counts and exit codes with and without the strict setting, and -W always shows the suite emits zero warnings:

leg interpreter / deps result
py 3.11 + current deps 24234 passed, 16 skipped, 1 xfailed
all 3.11 + current deps + calendars,langdetect, with --cov 24344 passed, 18 skipped, 1 xfailed
all 3.14 + current deps + extras 24344 passed, 18 skipped, 1 xfailed
new py leg 3.10 + current deps 24209 passed, 21 skipped, 1 xfailed
min-all 3.10 + the pinned floor versions 24344 passed, 18 skipped, 1 xfailed
docs sphinx-build -W build succeeded

Three things worth a reviewer's attention:

  1. Placement. The issue left "committed pytest.ini vs CI-only" open. This puts it in pytest.ini, because CONTRIBUTING.rst documents bare pytest as the contributor loop, and a strict setting that only tox sees would mean the documented command does not surface the failure. The blast radius is narrower than the issue assumed: pytest.ini is not in the sdist, so sdist-based packagers (including the openSUSE flow behind Tests fail after 2025-12-31 #1286) inherit nothing; nixpkgs builds from the GitHub tree and does inherit it, and its escape hatch is one line (pytestFlagsArray = [ "-W" "default" ]). If you would rather keep the committed config packager-neutral, the CI-only variant is pytest -W error ... in tox's [testenv] commands and I am happy to switch it.
  2. tzlocal==0.2. The one dependency in the pinned matrix that emits a warning. Its invalid string escapes are a compile-time warning, which an error filter turns into a SyntaxError at import — 20 collection errors, 0 tests run. It is invisible on CI only because pip byte-compiles at install time and absorbs the warning; it comes back under pip --no-compile, PYTHONDONTWRITEBYTECODE=1, or a uv-based install. Rather than leave that accidentally green, [testenv:min] sets PYTEST_ADDOPTS = -W "ignore:invalid escape sequence" (inherited by min-all), so the base command line stays single-sourced in [testenv]. No category on the filter: it is a DeprecationWarning up to 3.11 and a SyntaxWarning from 3.12 on. Verified: cold bytecode + the ignore → the suite passes, and an unrelated DeprecationWarning still fails the run. The module-scoped form (ignore::DeprecationWarning:tzlocal.unix) does not work here — compile-time warnings are attributed to the importing module.
  3. Two hardening items the strict setting implies. The benchmark env ignores pytest-codspeed's own measurement-hook RuntimeWarnings, so a runner glitch cannot turn a red CodSpeed check into a false signal (it was warned-but-green before this PR). And ruff now lints W605: pip's byte-compilation absorbs an invalid-escape warning in dateparser's own code before pytest can see it, so the linter is the only CI leg that can catch that class. The repo is already clean under it.

CONTRIBUTING.rst documents the behaviour and what to do when an upstream release turns the suite red: pytest -W default to see it, fix it if it is ours, otherwise a narrow ignore: after error (the last matching filter wins).

Python 3.10 leg

One matrix row. 3.10 is advertised in pyproject.toml but has only been tested against the oldest permitted dependency versions since #1296 moved min/min-all onto it and consumed the bare row.

One correction to the issue's rationale: it is not true that "3.10 only ever exercises the pytz-localzone path while 3.11+ exercise zoneinfo". Nothing in dateparser branches on the interpreter version; the split comes from the tzlocal==0.2 pin in [testenv:min]. On 3.10 with current tzlocal, get_localzone() returns a zoneinfo.ZoneInfo exactly as it does on 3.11+. So this leg tests 3.10 against current dependencies, and pytz-path coverage stays with min/min-all either way.

CodeQL action

github/codeql-action/upload-sarif@v2 → @v4 in cifuzz.yml. Not v3, as the deprecation message suggests: v3 emits its own core.error telling you to move to v4, so v3 would leave the acceptance criterion unmet. v4 is the current major (v4.37.9, node24) and takes the same sarif_file/checkout_path inputs, so it is a drop-in.

Not in this PR

  • actions/checkout@v3 and actions/setup-python@v5 produce a Node-20 deprecation warning annotation on every Build run today (codecov/codecov-action@v5 contributes a third through its bundled github-script). Same class of drift, but four major bumps with their own behavioural risk; happy to do it as a follow-up, or here if you prefer one sweep.
  • No dependabot.yml. A github-actions ecosystem entry would have caught the CodeQL v2 drift automatically; it would also open PRs against every stale pin above at once, so it seemed like its own decision.
  • A pre-release interpreter leg (Test failures with Python 3.14.0b1 #1272 class) — explicitly out of scope in the issue.
  • HISTORY.rst is untouched, per the repo's convention that release PRs own it.

Verifying after merge

  1. gh workflow run nightly.yml on master to exercise the scheduled path end-to-end (a dispatch failure files the tracking issue too, so the reporting is testable without waiting for a red night).
  2. Confirm the CIFuzz run on this PR carries no failure-level annotation.
  3. The daily run itself first proves out the morning after merge.

The report job's three branches (nothing open → files; already open → no-op; listing fails → still files, since a duplicate is cheaper than silence) were dry-run against a stubbed gh. Both workflow files validate against the SchemaStore GitHub-workflow schema, and pre-commit (ruff incl. W605, ruff-format) passes over every tracked file.

The second commit addresses a /code-review pass and the CodeQL missing-workflow-permissions alert on the first: token scoping, the three environmental exemptions, the tzlocal filter's category and placement, the CodSpeed guard, the codecov trigger set, the report job's gating/dedupe/resilience, and W605.

🤖 Generated with Claude Code

CI only ran on push and pull request, so breakage that arrives without a
commit -- a dependency release, a tz database update, the calendar rolling
over -- stayed invisible until someone happened to push. Master saw CI on
41 distinct days in the last 13 months, twice going more than two months
without a run, which is how #1286 reached a downstream packager first.

A new Nightly workflow calls the existing Build matrix daily at 04:17 UTC
and files one tracking issue per outage, since GitHub's own notification
goes to a single person. The schedule lives in its own workflow because
GitHub disables a workflow that has a schedule after 60 days without
repository activity, and a disabled workflow answers none of its triggers:
keeping the cron out of main.yml means an inactivity disable can never take
pull request runs down with it.

pytest.ini turns warnings into errors. The suite emits none today on 3.10
through 3.14, with and without the calendars and langdetect extras, against
both current dependencies and the min pins, so the exemption list starts
empty. The exception is the tzlocal 0.2 pin in the min environments, whose
invalid string escapes become an import-time SyntaxError under an error
filter whenever the installer does not byte-compile, so tox ignores that
one message for those two environments.

The matrix gains a plain 3.10 leg: 3.10 is a supported interpreter that was
only ever tested against the oldest permitted dependency versions, since
the Python bump in #1296 consumed the bare 3.10 row.

CIFuzz uploads SARIF with github/codeql-action/upload-sarif@v4. v2 has been
emitting a failure-level annotation on every run, and v3 emits one of its
own, so v4 is what actually clears it.

Fixes #1374

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread .github/workflows/nightly.yml Fixed
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (f766cee) to head (18f352b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1382   +/-   ##
=======================================
  Coverage   97.18%   97.18%           
=======================================
  Files         236      236           
  Lines        3057     3057           
=======================================
  Hits         2971     2971           
  Misses         86       86           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing fix-1374-ci-drift (18f352b) with master (f766cee)

Open in CodSpeed

Scope the Nightly token to contents: read at the workflow level, which the
called matrix inherits; the report job asks for issues: write itself
(CodeQL actions/missing-workflow-permissions).

Exempt three environmental warnings from the error filter: tzlocal's two
UserWarnings on a host with no or stale time zone configuration, which CI
never sees because it always sets TZ but which fail most of the suite for
a contributor in a bare container or in nixpkgs' sandbox, and pytest's
PytestCacheWarning in a read-only checkout, which turned a green run into
exit 1.

Drop the DeprecationWarning category from the tzlocal 0.2 escape filter,
since CPython 3.12+ emits it as a SyntaxWarning, and carry it through
PYTEST_ADDOPTS instead of a copied command line so min and min-all keep
following [testenv] commands. Ignore pytest-codspeed's measurement-hook
RuntimeWarnings in the benchmark env, so a runner glitch cannot turn
CodSpeed red.

Upload coverage only on push and pull_request, so a dispatched Nightly
does not re-upload master's report. Gate the report job on master and on
failure or cancelled, key the tracking issue on a dedicated
nightly-failure label so retitling it does not defeat the dedupe, and let
a transient listing failure fall through to filing rather than aborting.

Lint W605 with ruff: pip's byte-compilation absorbs an invalid-escape
warning before pytest can see it, so the linter is the only leg that can.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@serhii73
serhii73 merged commit 6114c90 into master Sep 9, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI only runs on push/PR, so dependency, calendar and toolchain drift reaches users first

3 participants