Skip to content

chore: simplify CI workflows and build scripts for weekly maintenance#91

Merged
nitrocode merged 4 commits into
mainfrom
copilot/simplify-code-base
Apr 26, 2026
Merged

chore: simplify CI workflows and build scripts for weekly maintenance#91
nitrocode merged 4 commits into
mainfrom
copilot/simplify-code-base

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

  • build-bundle.js line 63: fix off-by-one in logged line count — replace unminified.split('\n').length - 1 with unminified ? unminified.split('\n').length : 0

Summary by CodeRabbit

  • Tests

    • End-to-end tests are now automatically executed as part of the continuous integration pipeline.
  • Chores

    • Streamlined build and deployment automation for improved efficiency and consistency.
    • Added automated weekly project statistics validation to track repository merge metrics.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a245b695-481d-4447-8397-e142cd630538

📥 Commits

Reviewing files that changed from the base of the PR and between 76a04fe and b80574f.

📒 Files selected for processing (1)
  • scripts/build-bundle.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/build-bundle.js

📝 Walkthrough

Walkthrough

I 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

Cohort / File(s) Summary
GitHub Composite Action
./.github/actions/setup/action.yml
New composite action: sets up Node 22 (pinned), enables npm cache, and runs npm ci.
CI & Workflow updates
./.github/workflows/ci.yml, ./.github/workflows/deploy.yml, ./.github/workflows/preview.yml, ./.github/workflows/e2e-tests.yml
Centralizes Node/npm setup to local composite action; removes standalone e2e-tests.yml and integrates E2E into ci.yml; deploy.yml now uses npm run build; preview excludes project-stats.yaml.
New Scheduled Workflow
./.github/workflows/weekly-stats-check.yml
Adds weekly/manual workflow that reads project-stats.yaml, paginates closed PRs to count merged PRs, and creates a reminder issue if pr_count is stale (avoids duplicate reminders).
Build bundle helper
scripts/build-bundle.js
New exported buildBundle(opts) helper: validates sources, concatenates parts, runs esbuild.transformSync with merged options, writes output, and logs stats.
Build script delegation
scripts/build-js.js, scripts/build-css.js
Refactored to delegate concatenation/minification/write/logging to buildBundle (removed direct fs/esbuild logic).

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nitrocode

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)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes simplified CI workflows and build scripts, but the actual primary change is fixing an off-by-one error in build-bundle.js logging. Update the title to reflect the main fix, such as 'fix: correct line count in build-bundle.js log (remove off-by-one)' to accurately represent the primary changeset objective.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/simplify-code-base

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

@nitrocode nitrocode marked this pull request as ready for review April 26, 2026 18:51
@nitrocode nitrocode self-requested a review as a code owner April 26, 2026 18:51
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6e676fb and 851291c.

📒 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.yml
  • scripts/build-bundle.js
  • scripts/build-css.js
  • scripts/build-js.js
💤 Files with no reviewable changes (1)
  • .github/workflows/e2e-tests.yml

Comment thread .github/workflows/weekly-stats-check.yml Outdated
Comment thread .github/workflows/weekly-stats-check.yml Outdated
Comment thread scripts/build-bundle.js Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 26, 2026

👁️ PR Preview

🚀 Open Preview

Deployed from commit b80574f · Updates on every push to this PR
(Preview is removed automatically when the PR is closed.)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (99df9d1) to head (b80574f).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #91   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          242       242           
  Branches       109       109           
=========================================
  Hits           242       242           
Flag Coverage Δ
unit 100.00% <ø> (ø)

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


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 99df9d1...b80574f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…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>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 851291c and 76a04fe.

📒 Files selected for processing (2)
  • .github/workflows/weekly-stats-check.yml
  • scripts/build-bundle.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/weekly-stats-check.yml

Comment thread scripts/build-bundle.js Outdated
@nitrocode nitrocode enabled auto-merge (squash) April 26, 2026 22:01
@nitrocode nitrocode merged commit 0dec8d7 into main Apr 26, 2026
9 checks passed
@nitrocode nitrocode deleted the copilot/simplify-code-base branch April 26, 2026 22:01
github-actions Bot added a commit that referenced this pull request Apr 26, 2026
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.

2 participants