Skip to content

fix: unblock CI (codecov GPG flakiness + py21cmfast 4.2 struct rename) - #116

Open
steven-murray wants to merge 2 commits into
mainfrom
fix/ci-codecov-and-21cmfast-struct
Open

fix: unblock CI (codecov GPG flakiness + py21cmfast 4.2 struct rename)#116
steven-murray wants to merge 2 commits into
mainfrom
fix/ci-codecov-and-21cmfast-struct

Conversation

@steven-murray

@steven-murray steven-murray commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

Nearly every job in the Testing matrix on main is currently red (only macos-latest, 3.11 passes). This is pre-existing breakage on main, unrelated to the two open Dependabot PRs (#114, #115) that happen to inherit it. Two independent causes:

  • All ubuntu-latest jobs: codecov/codecov-action@v6.0.0's uploader intermittently fails GPG signature verification because of an upstream key-hosting problem (see GPG public key import returns invalid OpenPGP data, blocking Codecov uploads codecov/codecov-action#1955, where a keyserver 404 body gets piped into gpg as if it were key material). Because fail_ci_if_error: true, this flaky third-party step fails the whole job even when all tests pass. Set it to false.
  • python 3.12/3.13 jobs on both OSes: tests/test_simulators/test_py21cmfast/test_lightcones.py's mock-cache fixture accesses o.struct.primitive_fields. py21cmfast 4.2 renamed that property to _struct (confirmed against upstream source between v4.1.1 and v4.2 tags of 21cmfast/21cmFAST). Since pyproject.toml pins 21cmFAST>=4.0.0b (floating), pip resolves 4.1.1 on some Python versions and 4.2 on others in CI right now, so the fixture needs to support both attribute names rather than hard-switching to the new one.

Test plan

Generated with Claude Code

Summary by Sourcery

Unblock the CI test matrix by relaxing a flaky Codecov upload step and updating tests to be compatible with multiple py21cmfast versions.

Bug Fixes:

  • Allow the py21cmfast lightcones test fixture to work with both the old struct and new _struct attribute names to avoid version-dependent failures.

CI:

  • Configure Codecov uploads to not fail the entire CI job when the uploader intermittently errors due to external GPG key-hosting issues.

Tests:

  • Adjust the py21cmfast lightcones mock cache output to access primitive fields via whichever struct attribute is available, ensuring tests pass across supported py21cmfast versions.

Two independent, pre-existing breakages on main (unrelated to any
dependency bump) were failing nearly every Testing matrix job:

- codecov/codecov-action@v6.0.0's uploader intermittently fails GPG
  signature verification because of an upstream key-hosting issue
  (codecov/codecov-action#1955), which then fails the whole ubuntu-latest
  job because fail_ci_if_error was true. Set it to false so a flaky
  third-party upload doesn't fail the test job.

- py21cmfast 4.2 renamed the internal `struct` property on output objects
  to `_struct`. Since tuesday's pyproject.toml pins 21cmFAST>=4.0.0b
  (floating), pip resolves 4.1.1 on some Python versions and 4.2 on
  others, so the mock-cache test fixture now supports both attribute
  names.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR stabilizes the CI test matrix by relaxing Codecov failure handling in the GitHub Actions workflow and updating a py21cmfast test fixture to be compatible with both pre-4.2 and 4.2+ struct attribute names.

File-Level Changes

Change Details Files
Prevent flaky Codecov GPG verification failures from failing otherwise-successful CI test jobs.
  • Updated Codecov upload step configuration so CI does not fail when the uploader encounters GPG signature verification issues.
  • Documented in workflow comments that the failure mode is due to upstream key-hosting problems and that only the coverage upload, not the tests themselves, should be allowed to fail.
.github/workflows/tests.yaml
Make the py21cmfast lightcone test fixture compatible with both struct and _struct attribute naming across 21cmFAST versions.
  • Introduced a compatibility shim that selects o._struct when present, otherwise falls back to o.struct in the mock cache output helper.
  • Updated primitive field iteration in the fixture to use the resolved struct object rather than assuming a single attribute name.
tests/test_simulators/test_py21cmfast/test_lightcones.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@steven-murray steven-murray added type: ci Updates to CI (GH actions, RTD, etc.) type: bug Something isn't working labels Aug 2, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Instead of relying on a runtime hasattr check for o._struct vs o.struct, consider centralizing this version-dependent logic (e.g., helper function or compatibility layer) so that future py21cmfast struct changes are easier to manage and test.
  • Relaxing fail_ci_if_error to false for Codecov avoids flakiness but may hide real upload issues; consider scoping this change (e.g., to affected OS/Python versions) or adding a separate monitoring step so upload failures remain visible.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of relying on a runtime hasattr check for `o._struct` vs `o.struct`, consider centralizing this version-dependent logic (e.g., helper function or compatibility layer) so that future py21cmfast struct changes are easier to manage and test.
- Relaxing `fail_ci_if_error` to false for Codecov avoids flakiness but may hide real upload issues; consider scoping this change (e.g., to affected OS/Python versions) or adding a separate monitoring step so upload failures remain visible.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.75%. Comparing base (5b6b2c8) to head (4ea407f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #116   +/-   ##
=======================================
  Coverage   85.75%   85.75%           
=======================================
  Files          12       12           
  Lines         772      772           
  Branches      189      189           
=======================================
  Hits          662      662           
  Misses         46       46           
  Partials       64       64           
Flag Coverage Δ
unittests 85.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working type: ci Updates to CI (GH actions, RTD, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant