From 5b678eb8b7a3e4913a2a4684075e8d5abb20efc9 Mon Sep 17 00:00:00 2001 From: Dwight Gunning Date: Sun, 22 Nov 2026 21:10:32 -0500 Subject: [PATCH] ci(regression): measure the lane's coverage nightly instead of on every push Push runs of the regression lane on main took 25-37 min with --cov (the last nine completed runs) against 12-19 min for the same tests on a pull request without it. A push run's job is to say quickly whether main is red; the coverage number can wait for the night. Push runs now use the pull-request command, without --cov, and skip the Codecov upload. The schedule moves from weekly (Sunday) to nightly, at 08:00 UTC, an hour after python-hatch-workflow.yml's nightly run, and that run and manual dispatches keep coverage and the upload. codecov.yml (new; everything else stays at Codecov's defaults) turns on carryforward for the `regression` flag, so a commit with no regression upload reuses the last one instead of dropping this lane's lines from its total. Codecov's validator accepts the file. The 65% floor is unaffected: Combine Coverage in python-hatch-workflow.yml enforces it from the fast, network and slow lanes. Pull requests are unaffected too; they already ran without coverage. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/regression-tests.yml | 29 ++++++++++++++++---------- codecov.yml | 11 ++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/regression-tests.yml b/.github/workflows/regression-tests.yml index a37fd3d14..7a4fbce71 100644 --- a/.github/workflows/regression-tests.yml +++ b/.github/workflows/regression-tests.yml @@ -6,9 +6,11 @@ name: Regression Tests on: # Manual trigger workflow_dispatch: - # Run weekly on Sundays + # Nightly, an hour after python-hatch-workflow.yml's full run. This is the + # run that measures the lane's coverage for Codecov; pushes to main skip it + # (see "Run regression tests" below). schedule: - - cron: '0 8 * * 0' + - cron: '0 8 * * *' # PRE-MERGE GATE. The required context is the `Regression gate` job at the end # of this file, never the `regression` job itself. @@ -207,12 +209,16 @@ jobs: # tests and the few marked neither fast nor network. - name: Run regression tests run: | - # No coverage on pull requests: the Codecov upload below skips them, so - # it would be computed and thrown away (edgartools-07lk.26 step B). - if [ "${{ github.event_name }}" = "pull_request" ]; then - pytest -rs -m 'regression and not fast' --enable-cache - else + # Coverage only on the nightly and manual runs. It roughly doubles the + # lane: push runs on main took 25-37 min with it (November 2026) against + # 12-19 min for the same tests on a pull request without it, and a push + # run's job is to say quickly whether main is red. Codecov carries the + # `regression` flag forward between nightly uploads (codecov.yml), so + # commits in between keep this lane's lines in their total. + if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then pytest -rs --cov --cov-report=xml -m 'regression and not fast' --enable-cache + else + pytest -rs -m 'regression and not fast' --enable-cache fi # `always()`: a run that failed still warmed the cache, and the next one @@ -224,12 +230,13 @@ jobs: path: ${{ github.workspace }}/.edgar-data/_tcache key: edgar-tcache-regression-${{ github.run_id }} - # Not on pull requests. Codecov posts its own commit statuses, and a partial - # `regression`-flag upload from an advisory lane would put a red check on a - # pull request that this workflow is explicitly not allowed to influence. + # Only from the runs that measured coverage: the nightly and manual ones. + # Never on pull requests: Codecov posts its own commit statuses, and a + # partial `regression`-flag upload would put a red check on a pull request + # that only the `Regression gate` job may decide. - name: Upload coverage reports uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 - if: matrix.python-version == '3.12' && github.event_name != 'pull_request' + if: matrix.python-version == '3.12' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') with: files: coverage.xml fail_ci_if_error: false diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..26a3b4556 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +# Codecov settings. Anything not set here keeps Codecov's defaults. +# +# The regression lane (.github/workflows/regression-tests.yml) uploads coverage +# under the `regression` flag only from its nightly and manual runs; pushes to +# main skip coverage to finish in half the time. Carryforward reuses the last +# `regression` upload for commits that have none, so their totals do not dip +# by this lane's lines between nightly runs. +flag_management: + individual_flags: + - name: regression + carryforward: true