Skip to content

Add CI workflow to run tests on pull requests - #246

Merged
loiane merged 2 commits into
mainfrom
loiane/ci-test-workflow
Jul 1, 2026
Merged

loiane merged 2 commits into
mainfrom
loiane/ci-test-workflow

Conversation

@loiane

@loiane loiane commented Jun 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a GitHub Actions workflow (.github/workflows/test.yml) that runs the Jest test suite automatically on every pull request targeting main (and on pushes to main). This lets the repo's tests gate PRs before they're merged.

What it does

  • Triggers on pull_request and push to main.
  • Runs npm ci then npm test (Jest via ts-jest).
  • Runs on Node 24.x.
  • Uses npm dependency caching for faster runs.

Notes on JS + TS

The repo contains both JavaScript and TypeScript. All current test files are *.test.ts and are executed by Jest through the ts-jest preset, so npm test already covers the TypeScript sources. The plain .js files are example/illustration scripts without their own test files; they are still importable/runnable by the same Jest setup if .test.js files are added later (Jest's default testMatch picks up both .js and .ts).

Why tests only (not tsc build)

I intentionally did not add npm run build:ts (full tsc) as a required step. The build currently fails on pre-existing TypeScript errors in the leetcode example files (e.g. duplicate global TreeNode / TrieNode declarations and script-style redeclarations). Gating PRs on the build would block every PR until those are refactored into modules. That cleanup is out of scope here — happy to tackle it in a separate PR if you'd like.

Enforcing this before merge

The workflow makes the test run visible on every PR, but to actually block merging on failure you'll also need a branch protection (or ruleset) rule on main requiring the Test (Node 24.x) status check to pass. I can't configure that via code — it's a repo setting. Let me know if you'd like guidance on the exact settings.

@loiane
loiane merged commit 40b2f1c into main Jul 1, 2026
1 check passed
@loiane
loiane deleted the loiane/ci-test-workflow branch July 1, 2026 00:13
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