chore: simplify CI workflows and build scripts for weekly maintenance - #91
Conversation
Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/d47a2eb0-3a98-427d-8ddb-d539503e61f5 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughI pity the fool — this PR adds a reusable Node.js composite action, centralizes Node setup across workflows, moves E2E into CI, adds a weekly project-stats checker, and refactors JS/CSS build scripts to use a new shared buildBundle helper. Changes
Sequence Diagram(s)sequenceDiagram
participant Scheduler as "Scheduler (cron/dispatch)"
participant Runner as "GitHub Actions Runner"
participant Script as "weekly-stats-check script"
participant GHAPI as "GitHub REST API"
participant Issues as "Repository Issues"
Scheduler->>Runner: trigger workflow
Runner->>Script: execute node script (reads project-stats.yaml)
Script->>GHAPI: paginate closed PRs (list pulls)
GHAPI-->>Script: closed PRs with merged_at
Script->>Script: compute totalMerged vs pr_count
alt pr_count outdated
Script->>GHAPI: list open issues (exclude PRs)
GHAPI-->>Script: open issues
Script->>Issues: create reminder issue (if none exists)
Issues-->>Script: issue created
else up-to-date
Script-->>Runner: exit no-op
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
I pity the fool who skips the review — check the workflows, composite action pinning, and the new build helper. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/b4a46e0d-829f-438a-a389-22e704bd74ad Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
scripts/build-bundle.js (1)
58-61: Optional: guard ratio math for empty bundles.I pity the fool debugging
NaN%logs—add a small zero-length guard so metrics stay sane even with empty input.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/build-bundle.js` around lines 58 - 61, The ratio calculation can produce NaN for empty bundles because it divides by unminified.length; update the calculation around the ratio variable (the const ratio = ... line) to guard against zero-length input by first checking if unminified.length is 0 and using 0 (or "0.0") as the percentage in that case, otherwise perform ((1 - result.code.length / unminified.length) * 100).toFixed(1); keep the rest of the log using the same ratio variable so logs never show NaN%.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/weekly-stats-check.yml:
- Around line 30-31: The code currently silently falls back to 0 when parsing
pr_count; instead validate the regex match and parsed value and fail fast: after
obtaining match using yaml.match(/^pr_count:\s*(\d+)/m) and computing
recordedCount from match[1], if match is null or parseInt returns NaN (or the
value is not an integer), throw an Error or exit non‑zero (e.g., throw new
Error("Invalid or missing pr_count in project-stats.yaml") or call the workflow
failure helper) so the job fails rather than treating malformed data as 0;
update the logic around the recordedCount variable to enforce this validation.
- Around line 75-82: The duplicate-check only inspects the first page returned
by github.rest.issues.listForRepo and doesn't exclude PRs, so it can miss
matches and create duplicates; replace the single-page call with
octokit.paginate(github.rest.issues.listForRepo, { owner: context.repo.owner,
repo: context.repo.repo, state: 'open' }) to retrieve all open items into
openIssues, then compute duplicate by finding an item whose title
startsWith('chore: update project-stats.yaml') and also has no pull_request
(i.e., !i.pull_request) to ensure only real issues are considered.
In `@scripts/build-bundle.js`:
- Around line 43-47: The concatenation is brittle because chunks.join('') and
direct footer append can merge tokens; change the logic around the
chunks/unminified assembly (variables: chunks, unminified, opts.header,
opts.footer) to insert explicit separators (e.g. a single '\n' or configurable
separator) between joined chunks and when prepending header or appending footer
so that files without trailing newlines do not merge tokens; ensure you use
chunks.join(separator) instead of join('') and always append a newline between
unminified and opts.footer and after opts.header when present.
---
Nitpick comments:
In `@scripts/build-bundle.js`:
- Around line 58-61: The ratio calculation can produce NaN for empty bundles
because it divides by unminified.length; update the calculation around the ratio
variable (the const ratio = ... line) to guard against zero-length input by
first checking if unminified.length is 0 and using 0 (or "0.0") as the
percentage in that case, otherwise perform ((1 - result.code.length /
unminified.length) * 100).toFixed(1); keep the rest of the log using the same
ratio variable so logs never show NaN%.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b2c78c2b-a1dc-4af2-8f59-f96c3bee8bfe
📒 Files selected for processing (9)
.github/actions/setup/action.yml.github/workflows/ci.yml.github/workflows/deploy.yml.github/workflows/e2e-tests.yml.github/workflows/preview.yml.github/workflows/weekly-stats-check.ymlscripts/build-bundle.jsscripts/build-css.jsscripts/build-js.js
💤 Files with no reviewable changes (1)
- .github/workflows/e2e-tests.yml
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
👁️ PR Preview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## main #91 +/- ##
=========================================
Coverage 100.00% 100.00% =========================================
Files 1 1 Lines 242 242 Branches 109 109 =========================================
Hits 242 242
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…dle separators and ratio NaN Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/96190522-cc07-4b03-99c0-cf0948a23a2e Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/build-bundle.js`:
- Line 63: The logged line count uses unminified.split('\n').length - 1 which
counts newlines, under-reporting by one for non-empty bundles; update the
template in scripts/build-bundle.js (the line that builds the string using
unminified and result.code) to compute actual line count—replace the current
expression with a correct count (e.g., use unminified ?
unminified.split('\n').length : 0 or handle empty string) so the log reports the
true number of lines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 49e00f9b-6a54-4544-8c12-6441a98239d6
📒 Files selected for processing (2)
.github/workflows/weekly-stats-check.ymlscripts/build-bundle.js
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/weekly-stats-check.yml
Uh oh!
There was an error while loading. Please reload this page.
Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/24d22b66-7021-4e64-afe0-bd4be732fffb Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
build-bundle.jsline 63: fix off-by-one in logged line count — replaceunminified.split('\n').length - 1withunminified ? unminified.split('\n').length : 0Summary by CodeRabbit
Tests
Chores