Skip to content

Enforce endDate >= startDate and serialize Pages deployments - #81

Open
sparkyfen wants to merge 4 commits into
mainfrom
date-order-check
Open

Enforce endDate >= startDate and serialize Pages deployments#81
sparkyfen wants to merge 4 commits into
mainfrom
date-order-check

Conversation

@sparkyfen

@sparkyfen sparkyfen commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

  • Enforce endDate >= startDate in tools/materialize.py. The schema has always declared this via formatMinimum/$data, but that's an ajv extension that python-jsonschema silently ignores, so it was never enforced — Updated "Ainmhicon" to include 2027 event #77 shipped a 2027 event with a 2026 end date and validation passed. Dates are compared as parsed values, so the check doesn't depend on which ISO spellings the format checker admits.
  • Fix the never-set has_errors flag. Schema-invalid series files used to fall through into the event loop; they're now skipped. This also stops the event loop from writing output files for series whose ids never passed the schema's pattern check.
  • Validate imported data in import_fancons, import_rams, and import_furrynz before their push to main, mirroring import_concat including its failure annotations — a bad imported date now fails the import run instead of breaking every deploy.
  • Serialize Pages deployments with the standard concurrency: pages group in deploy.yml (same pattern as actions/starter-workflows pages/static.yml). Merging four PRs back to back on 2026-08-12 raced the Pages API: two deploy runs failed with "deployment request failed due to in progress deployment".
  • Housekeeping: adds the repo's first .gitignore (__pycache__/, *.pyc).

Tests

.github/scripts/test_materialize_dates.py (wired into validate.yml) runs the real materialize script against fixture series files: order violation, same-day event, violation on a non-first event, and a schema-invalid file that must be reported without a traceback. Each test fails when its guarded change is reverted. All 226 existing series files pass the new check, so this lands green with no data fixes needed.

Rollout

Nothing manual: validation and deploy changes ride the existing workflows on merge. Recommend squash-merge — an accidentally committed .pyc exists in this branch's first commit and squashing keeps it out of main's history.

Summary by CodeRabbit

  • Bug Fixes
    • Events with an end date earlier than their start date are now rejected with clear error details.
    • Invalid event series are prevented from being materialized, reducing the risk of publishing malformed data.
  • Improvements
    • Import workflows now format and validate data before committing changes, with separate, actionable messages for each failure type.
    • Deployment workflows now prevent outdated queued deployments from replacing newer ones.
  • Testing
    • Added coverage for valid events, invalid date ranges, and schema errors.

The schema expressed this as formatMinimum with a $data pointer, an ajv
extension that python-jsonschema silently ignores, so events with an end
date before their start date passed CI (ainmhicon 2027 in PR #77 shipped
with endDate 2026-04-04 against startDate 2027-04-02 and validated
green).

Enforce the constraint explicitly in materialize.py's event loop and fix
the adjacent has_errors flag, which was never set, so schema-invalid
files now skip event processing instead of risking KeyErrors.

Tested by .github/scripts/test_materialize_dates.py, which runs the real
script against fixture series files and is wired into validate.yml.
…idation

- Drop the accidentally committed .pyc and add a .gitignore so compiled
  bytecode can't be tracked again.
- Make test_schema_invalid_file_still_fails actually discriminate: the
  pre-fix code also exited 1 (via an uncaught KeyError), so the test now
  asserts the ErrorLogger message and the absence of a traceback.
  Verified by mutation: reverting the has_errors fix fails the test.
- Validate imported data in import_fancons, import_rams and
  import_furrynz before their push to main, mirroring import_concat,
  so a bad imported date fails the import instead of breaking deploy.
- Document the ajv-only formatMinimum keyword in schema.json and the
  preconditions of the string date comparison in materialize.py.
- Mirror import_concat.yml's failure-annotation steps in the three
  importer workflows so a red run says which stage failed, and shrink
  the duplicated rationale comment to one line.
- Decouple the schema-invalid test from jsonschema's exact message
  wording, run materialize via uv run --script, and cover the case
  where a later (non-first) event in a series has the bad dates.
- Condense the date-check comment in materialize.py.
- deploy.yml gets the standard Pages concurrency group (one deployment
  at a time, queued intermediates skipped, in-progress never cancelled;
  same pattern as actions/starter-workflows pages/static.yml). Merging
  four PRs back to back on 2026-08-12 raced the Pages API and two runs
  failed with 'deployment request failed due to in progress deployment'.
- Compare event dates as parsed values instead of raw strings, so the
  check no longer depends on the format checker admitting only
  canonical YYYY-MM-DD spellings.
- Skip the materialize tests with a clear message when uv is not on
  PATH instead of tracebacking.
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c77b8e43-dd4e-48cd-adbd-05f14207842c

📥 Commits

Reviewing files that changed from the base of the PR and between 6cae729 and 6032699.

📒 Files selected for processing (9)
  • .github/scripts/test_materialize_dates.py
  • .github/workflows/deploy.yml
  • .github/workflows/import_fancons.yml
  • .github/workflows/import_furrynz.yml
  • .github/workflows/import_rams.yml
  • .github/workflows/validate.yml
  • .gitignore
  • tools/materialize.py
  • tools/schema.json

📝 Walkthrough

Walkthrough

The materializer now enforces event date ordering and records schema failures per series. New integration tests cover these cases. Import workflows validate formatted data before commits. Pages deployments now use concurrency control.

Changes

Materialization validation

Layer / File(s) Summary
Materialization date validation
tools/materialize.py, tools/schema.json
The materializer tracks schema errors and rejects events where endDate precedes startDate. The schema documents this enforcement boundary.
Integration validation coverage
.github/scripts/test_materialize_dates.py, .github/workflows/validate.yml, .gitignore
Integration tests run materialize.py through uv against temporary fixtures. The validation workflow runs these tests, and Python cache files are ignored.
Import workflow validation
.github/workflows/import_fancons.yml, .github/workflows/import_furrynz.yml, .github/workflows/import_rams.yml
Import workflows format and materialize JSON before committing. Separate errors identify formatting and validation failures.
Estimated code review effort: 3 (Moderate) ~25 minutes

Mergeability Score: ⚪ Minimal · up to 60326

This PR adds date validation, import validation, and serialized Pages deployments; no actionable merge-blocking risk remains beyond normal checks and review.

Deployment concurrency

Layer / File(s) Summary
Pages deployment concurrency
.github/workflows/deploy.yml
Pages deployments use a shared concurrency group. Active runs continue, while queued outdated runs are skipped.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ImportWorkflow
  participant Formatter
  participant Materialize
  participant CommitStep
  ImportWorkflow->>Formatter: Format imported JSON
  Formatter-->>ImportWorkflow: Formatting status
  ImportWorkflow->>Materialize: Materialize and schema-validate data
  Materialize-->>ImportWorkflow: Validation status
  ImportWorkflow->>CommitStep: Commit only when checks pass
Loading

Possibly related PRs

  • consfyi/data#73: Adds related import validation through materialize.py with actionable workflow failure handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the two primary changes: date-order enforcement and serialized Pages deployments.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch date-order-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant