Skip to content

Add local pre-commit Codecov YAML validator - #269

Merged
medley56 merged 6 commits into
mainfrom
copilot/create-local-pre-commit-hook
Aug 7, 2026
Merged

Add local pre-commit Codecov YAML validator#269
medley56 merged 6 commits into
mainfrom
copilot/create-local-pre-commit-hook

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • Test coverage is present for new code
  • The changelog.md has been updated if necessary
  • Mark deprecated code with deprecation warnings
  • Dependency spec updated if necessary

Summary

Replaces the removed third-party Codecov config hook with a local pre-commit hook that validates codecov.yml against Codecov’s validation API. The hook is defined under repo: local, so it is eligible to run in pre-commit CI as part of normal hook execution.

  • Hook registration

    • Adds validate-codecov-yaml to .pre-commit-config.yaml
    • Scopes execution to ^codecov\.yml$
    • Uses language: python and entry: python scripts/check_codecov_yaml.py
  • Validator implementation

    • Adds scripts/check_codecov_yaml.py
    • POSTs YAML bytes to https://codecov.io/validate
    • Accepts pre-commit filename args and returns non-zero on HTTP/network/validation failures
  • Example

    - repo: local
      hooks:
        - id: validate-codecov-yaml
          name: validate codecov.yml
          entry: python scripts/check_codecov_yaml.py
          language: python
          files: ^codecov\.yml$

Copilot AI changed the title Add local pre-commit hook to validate codecov.yml Add local pre-commit Codecov YAML validator Aug 7, 2026
Copilot AI requested a review from medley56 August 7, 2026 01:53
@medley56
medley56 marked this pull request as ready for review August 7, 2026 01:55
Copilot AI lite review requested due to automatic review settings August 7, 2026 01:55
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.92%. Comparing base (86e4f0a) to head (6c7dfef).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #269   +/-   ##
=======================================
  Coverage   94.92%   94.92%           
=======================================
  Files          48       48           
  Lines        3904     3904           
=======================================
  Hits         3706     3706           
  Misses        198      198           

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

@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@copilot the validation hook script wasn't able to reach the codecov validation endpoint. Double check your implementation against the documentation for codecov. Are we using the endpoint correctly?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a local pre-commit hook to validate codecov.yml by posting it to Codecov’s /validate endpoint, replacing a removed third-party hook and keeping config validation within the repo’s normal pre-commit execution.

Changes:

  • Added scripts/check_codecov_yaml.py validator that POSTs YAML contents to https://codecov.io/validate and returns non-zero on failure.
  • Registered a new local pre-commit hook validate-codecov-yaml scoped to ^codecov\.yml$ in .pre-commit-config.yaml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/check_codecov_yaml.py Implements the Codecov YAML validation CLI used by pre-commit.
.pre-commit-config.yaml Registers the new local hook to run only for codecov.yml.

Comment thread scripts/check_codecov_yaml.py
Comment thread scripts/check_codecov_yaml.py

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the validation hook script wasn't able to reach the codecov validation endpoint. Double check your implementation against the documentation for codecov. Are we using the endpoint correctly?

Addressed in e7ec905. I verified the validator still targets Codecov’s documented endpoint (https://codecov.io/validate) but switched the implementation to urllib.request.urlopen so it sends a full URL request, follows redirects, respects proxy settings, and uses a timeout. I also added unit tests covering request construction, HTTP validation errors, network errors, and file read failures.

Copilot AI requested a review from medley56 August 7, 2026 02:03

@medley56 medley56 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not need a unit test suite for this. I'm glad you checked that it works but the real test is that it runs as part of CI! Remove the unit test suite.

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

We do not need a unit test suite for this. I'm glad you checked that it works but the real test is that it runs as part of CI! Remove the unit test suite.

Done in 927e409 — I removed the Codecov validator unit test file from tests/unit so CI remains the validation path for this hook.

@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@copilot The new hook is erroring in pre commit CI. The run log url is https://results.pre-commit.ci/run/github/612253190/1786068713.Yr21VbDoSMmwyrgfN-8WQA

Examine the logs and determine what is going wrong. It looks like possibly there is some incompatibility with pre commit CI in the hook script. Read the pre commit documentation if it's helpful.

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot The new hook is erroring in pre commit CI. The run log url is https://results.pre-commit.ci/run/github/612253190/1786068713.Yr21VbDoSMmwyrgfN-8WQA

Examine the logs and determine what is goin...

Root cause is pre-commit.ci compatibility: this hook makes a live network call to https://codecov.io/validate, and pre-commit.ci runs hooks in a restricted environment where that outbound request fails. I fixed this in df85525 by skipping validate-codecov-yaml under the ci.skip section in .pre-commit-config.yaml, so pre-commit.ci no longer runs the network-dependent hook.

Copilot AI requested a review from medley56 August 7, 2026 02:28
Copilot AI and others added 5 commits August 6, 2026 20:29
Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>
Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>
Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>
Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>
Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>
@medley56
medley56 force-pushed the copilot/create-local-pre-commit-hook branch from df85525 to 5e02e81 Compare August 7, 2026 02:29
@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@copilot Why did pre commit CI try to run the new hook? I thought we were skipping it now. Did it run from an old commit hash or something?

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Why did pre commit CI try to run the new hook? I thought we were skipping it now. Did it run from an old commit hash or something?

Yes — that run URL is from an older commit before the skip landed. pre-commit.ci runs per commit SHA, so the historical run still shows the hook execution/failure for that earlier SHA. The current head (5e02e81) includes ci.skip: [validate-codecov-yaml], so that hook is skipped on new pre-commit.ci runs.

Copilot AI requested a review from medley56 August 7, 2026 02:54
@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@copilot I need you to trigger pre commit CI again. I think you can do it via a comment on the PR.

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot I need you to trigger pre commit CI again. I think you can do it via a comment on the PR.

@pre-commit-ci run

Copilot AI requested a review from medley56 August 7, 2026 02:58
@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@pre-commit-ci run

1 similar comment
@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@pre-commit-ci run

@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

pre-commit.ci run

@medley56

medley56 commented Aug 7, 2026

Copy link
Copy Markdown
Member

@copilot The problem now is that ruff is failing on the new hook script. Examine the latest pre-commit.ci run logs and fix whatever ruff is complaining about in the new script.

Co-authored-by: medley56 <7018964+medley56@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot The problem now is that ruff is failing on the new hook script. Examine the latest pre-commit.ci run logs and fix whatever ruff is complaining about in the new script.

Fixed in 6c7dfef. Ruff was flagging S310 on urllib.request.Request(...) in the new hook script. I removed the intermediate Request object and call urlopen directly with the constant Codecov URL and timeout; ruff-format and ruff-check now pass locally for scripts/check_codecov_yaml.py.

@medley56
medley56 merged commit 6de220f into main Aug 7, 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.

3 participants