Skip to content

feat(ci): missed-run heartbeat for the daily sync cron - #72

Merged
wpak-ai merged 2 commits into
cppalliance:masterfrom
timon0305:feat/sync-heartbeat-71
Jul 30, 2026
Merged

feat(ci): missed-run heartbeat for the daily sync cron#72
wpak-ai merged 2 commits into
cppalliance:masterfrom
timon0305:feat/sync-heartbeat-71

Conversation

@timon0305

@timon0305 timon0305 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #71

Problem

The daily translation sync (.github/workflows/sync-translation.yml, cron: "0 0 * * *") surfaces a failed run on its own, but a run that never fires is silent: GitHub can drop scheduled runs, auto-disable the workflow after repo inactivity, or lose the schedule. A silently missed sync can go unnoticed until translations fall behind.

What changed

  • New scheduled workflow .github/workflows/heartbeat.yml (0 12 * * *, offset from the sync's 00:00) queries the last successful scheduled sync-translation run via the gh API and alerts when it is older than the threshold. It runs independently, so it still fires once the sync workflow has stopped.
  • The staleness decision is a pure heartbeat_run_is_stale() in assets/lib.sh (missing or older-than-threshold), with four bats tests (no-run / older / within / boundary).
  • HEARTBEAT_MAX_AGE_HOURS = 30 in assets/env.sh carries margin above the 24h cadence, so a delayed run does not trip the alert while a fully missed day is caught by the next heartbeat.

Alerting is interim: the job fails so the missed run surfaces to watchers. It is a one-step swap to the shared notification channel once the failure-notification work (#66) provides one.

Repo lint (shellcheck + actionlint + JSON-schema) is clean and the full bats suite passes locally (135).

Summary by CodeRabbit

  • New Features
    • Added a daily synchronization “heartbeat” check to detect missed or paused scheduled translation runs.
    • Supports manual triggering of the heartbeat check.
    • Alerts and fails the workflow when the most recent successful scheduled run is older than the allowed threshold.
  • Bug Fixes
    • Uses the original run time to detect staleness more reliably, so reruns of old runs don’t hide a stopped schedule.
  • Tests
    • Added Bats coverage for missing, stale, fresh, and exact-threshold heartbeat behavior.

A failed sync run surfaces on its own, but a run that never fires is silent:
GitHub can drop scheduled runs, auto-disable the workflow after inactivity, or
lose the schedule. Add a separate scheduled workflow (heartbeat.yml) that checks
the last successful scheduled sync-translation run and alerts when it is older
than a threshold, so a silently missed run is caught. It does not depend on the
sync workflow running, so it still fires once that workflow has stopped.

The staleness decision lives in a pure heartbeat_run_is_stale() in lib.sh with
bats coverage; HEARTBEAT_MAX_AGE_HOURS (30) carries margin above the 24h cadence.
Alerting is interim (fails the job); point it at the shared notification channel
once the failure-notification work lands.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0093fc83-90b5-4359-9ef0-7ae430f2c47d

📥 Commits

Reviewing files that changed from the base of the PR and between 746027d and af97b90.

📒 Files selected for processing (1)
  • .github/workflows/heartbeat.yml

📝 Walkthrough

Walkthrough

Adds a scheduled heartbeat workflow that checks the latest successful scheduled translation-sync run, uses shared timestamp validation, and fails with an error when the run exceeds the 30-hour threshold. Tests cover missing, stale, fresh, and boundary timestamps.

Changes

Translation sync heartbeat

Layer / File(s) Summary
Heartbeat constants and stale-run validation
.github/workflows/assets/env.sh, .github/workflows/assets/lib.sh, tests/test_lib.bats
Adds the heartbeat phase and 30-hour threshold, implements stale timestamp detection, and tests missing, stale, fresh, and exact-threshold behavior.
Scheduled heartbeat workflow
.github/workflows/heartbeat.yml
Runs daily or manually, finds the latest successful scheduled sync run using createdAt, validates its age, emits an error for stale state, and closes the phase through traps.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HeartbeatWorkflow
  participant GitHubActions
  participant heartbeat_run_is_stale
  HeartbeatWorkflow->>GitHubActions: query latest successful scheduled sync run
  GitHubActions-->>HeartbeatWorkflow: return createdAt timestamp
  HeartbeatWorkflow->>heartbeat_run_is_stale: compare timestamp with 30-hour threshold
  heartbeat_run_is_stale-->>HeartbeatWorkflow: return stale or fresh status
  HeartbeatWorkflow-->>GitHubActions: emit error and fail when stale
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The heartbeat and threshold logic satisfy #71, but it does not use the shared notification channel required by the issue. Route heartbeat alerts through the shared failure-notification channel instead of only failing the job, or note the dependency if unavailable.
✅ 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 summarizes the new missed-run heartbeat workflow for the daily sync cron.
Out of Scope Changes check ✅ Passed All changes support the heartbeat workflow, helper logic, and tests for the missed-run detection goal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@whisper67265
whisper67265 self-requested a review July 30, 2026 14:34
Comment thread .github/workflows/heartbeat.yml Outdated
updatedAt moves when an old run is rerun, so a stopped schedule whose last run
was manually rerun looked healthy. Query createdAt, the schedule-fire time, so
the age reflects when the run actually fired.
@timon0305
timon0305 requested a review from whisper67265 July 30, 2026 16:29
@whisper67265
whisper67265 requested a review from wpak-ai July 30, 2026 17:21
@wpak-ai
wpak-ai merged commit fc7bc90 into cppalliance:master Jul 30, 2026
4 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.

Missed-run heartbeat for the daily translation-sync cron

3 participants