Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ always bump at least minor; breaking schema changes bump major.
- Add `infra/gitlab-ci` to the closed skill taxonomy (#24).

### Fixed
- Go (`foo_test.go`), Python (`test_foo.py`) and Ruby (`foo_spec.rb`) test files are now categorised as `testing` instead of falling through to `backend`.
- Improve manifest dependency detection by comparing parent and child
revision snapshots instead of relying only on added diff lines. This now
correctly detects dependencies added inside existing blocks in
Expand Down
10 changes: 9 additions & 1 deletion src/categorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import type { CategoryName } from "./types.js";
//
// Order matters: first matching rule wins.
const RULES: Array<[RegExp, CategoryName]> = [
[/(^|\/)(__tests__|tests?|specs?)(\/|$)|\.(test|spec)\.[jt]sx?$/i, "testing"],
// Recognise test files across languages: a `test/` or `spec/` directory, the
// JS/TS `.test.`/`.spec.` infix, the `_test.`/`_spec.` suffix used by Go
// (`foo_test.go`), Ruby (`foo_spec.rb`) and others, and the Python `test_`
// prefix (`test_foo.py`). Previously only the JS/TS forms were matched, so
// `foo_test.go` and `test_foo.py` fell through to "backend".
[
/(^|\/)(__tests__|tests?|specs?)(\/|$)|[._](test|spec)\.[a-z0-9]+$|(^|\/)test_[^/]+\.[a-z0-9]+$/i,
"testing",
],
[/(^|\/)(claude\.md|agents\.md|\.cursor|\.aider|copilot)/i, "ai-workflow"],
[
/(^|\/)(\.github\/workflows|dockerfile|docker-compose|terraform|k8s|kubernetes|infra)(\/|$|\.)/i,
Expand Down
22 changes: 22 additions & 0 deletions test/categorize.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";

import { categorize } from "../src/categorize.js";

describe("categorize", () => {
it("classifies JS/TS test files as testing", () => {
expect(categorize("src/Button.test.tsx")).toBe("testing");
expect(categorize("__tests__/foo.ts")).toBe("testing");
});

it("classifies Go, Python and Ruby test files as testing", () => {
expect(categorize("pkg/foo_test.go")).toBe("testing");
expect(categorize("app/test_user.py")).toBe("testing");
expect(categorize("lib/user_spec.rb")).toBe("testing");
});

it("does not misclassify non-test source files", () => {
expect(categorize("src/api/users.go")).toBe("backend");
expect(categorize("src/latest.go")).toBe("backend");
expect(categorize("src/contest.py")).toBe("backend");
});
});