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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ logs/
.tmp/
coverage/
**/*.tsbuildinfo
.worktrees/

# yarn ignores
# https://next.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"implementations-update": "ts-node src/cli/implementations-update.ts",
"approval-report": "ts-node src/cli/approval-report.ts",
"upsert-act-board": "ts-node src/cli/upsert-act-board.ts",
"sync-act-board-project": "ts-node src/cli/sync-act-board-project.ts",
"write-act-board-snapshot": "ts-node src/cli/write-act-board-snapshot.ts",
"test": "jest",
"prepare": "husky install"
},
Expand Down
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,20 @@ GITHUB_TOKEN=... yarn upsert-act-board --input approval-report.json

The upsert command owns act-board issue titles, bodies, state, and sub-issue
relationships. It does not update GitHub Project fields.

```sh
GITHUB_TOKEN=... ACT_BOARD_PROJECT_NUMBER=1 yarn sync-act-board-project \
--input approval-report.json
yarn write-act-board-snapshot --input approval-report.json \
--outFile ../act-board/data/snapshot.json
```

`sync-act-board-project` writes Projects v2 Status and optional numeric/date/URL
fields. It skips GitHub writes when values already match, warns and skips
missing or mistyped optional fields, and exits if the Status field is missing.
`--projectOwner` must name a GitHub organization; user-owned Projects are not
supported. Row failures are reported after the remaining rows are attempted and
cause a non-zero exit status. Both
`upsert-act-board` and `sync-act-board-project` fail clearly when `GITHUB_TOKEN`
is unset. The snapshot command rewrites `data/snapshot.json` only when the
classifier JSON actually changed.
42 changes: 42 additions & 0 deletions src/approval-report/__tests__/load-rows.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";

import { loadRuleApprovalRows } from "../load-rows";

describe("loadRuleApprovalRows", () => {
let directory: string;

beforeEach(() => {
directory = fs.mkdtempSync(path.join(os.tmpdir(), "act-tools-rows-"));
});

afterEach(() => {
fs.rmSync(directory, { recursive: true, force: true });
});

function write(contents: string): string {
const filePath = path.join(directory, "rows.json");
fs.writeFileSync(filePath, contents);
return filePath;
}

it("loads an array containing rule ids", () => {
expect(loadRuleApprovalRows(write('[{"ruleId":"674b10"}]'))).toEqual([
{ ruleId: "674b10" },
]);
});

it("rejects malformed JSON", () => {
expect(() => loadRuleApprovalRows(write("{not json"))).toThrow(SyntaxError);
});

it("rejects JSON that is not a RuleApprovalRow array", () => {
expect(() =>
loadRuleApprovalRows(write('[{"name":"Missing id"}]')),
).toThrow(/not a RuleApprovalRow JSON array/);
expect(() => loadRuleApprovalRows(write("{}"))).toThrow(
/not a RuleApprovalRow JSON array/,
);
});
});
27 changes: 27 additions & 0 deletions src/approval-report/__tests__/snapshot.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { formatSnapshotJson, snapshotsEqual } from "../snapshot";
import { RuleApprovalRow } from "../types";

describe("snapshot formatting", () => {
it("formats rows with a trailing newline", () => {
const rows = [{ ruleId: "674b10" }] as RuleApprovalRow[];
expect(formatSnapshotJson(rows)).toBe(
'[\n {\n "ruleId": "674b10"\n }\n]\n',
);
});

it("skips equal formatted content but rewrites stale key order", () => {
expect(
snapshotsEqual(
'{\n "ruleId": "674b10",\n "name": "A"\n}\n',
'{"ruleId":"674b10","name":"A"}',
),
).toBe(true);
expect(
snapshotsEqual(
'{"ruleId":"674b10","name":"A"}',
'{"name":"A","ruleId":"674b10"}',
),
).toBe(false);
expect(snapshotsEqual('{"ruleId":"a"}', '{"ruleId":"b"}')).toBe(false);
});
});
Loading
Loading