Skip to content

Commit c82e79b

Browse files
DeDuckProjectclaude
andcommitted
Add unit tests for root action.yml correctness
Tests verify: correct main path, node20 runtime, and that inputs/outputs stay in sync with packages/action/action.yml to prevent drift. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eae7de4 commit c82e79b

3 files changed

Lines changed: 67 additions & 2 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"lint": "pnpm -r lint"
1919
},
2020
"devDependencies": {
21+
"@types/js-yaml": "^4.0.9",
22+
"@types/node": "^20.12.0",
23+
"js-yaml": "^4.1.1",
2124
"typescript": "^5.4.5",
22-
"vitest": "^1.6.0",
23-
"@types/node": "^20.12.0"
25+
"vitest": "^1.6.0"
2426
}
2527
}

pnpm-lock.yaml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/action-yml.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { readFileSync } from 'fs';
3+
import { resolve } from 'path';
4+
import { load } from 'js-yaml';
5+
6+
const root = resolve(__dirname, '../..');
7+
8+
function loadActionYml(path: string): any {
9+
return load(readFileSync(path, 'utf8'));
10+
}
11+
12+
describe('root action.yml', () => {
13+
const rootAction = loadActionYml(resolve(root, 'action.yml'));
14+
const pkgAction = loadActionYml(resolve(root, 'packages/action/action.yml'));
15+
16+
it('points main to packages/action/dist/index.js', () => {
17+
expect(rootAction.runs.main).toBe('packages/action/dist/index.js');
18+
});
19+
20+
it('uses node20 runtime', () => {
21+
expect(rootAction.runs.using).toBe('node20');
22+
});
23+
24+
it('has the same inputs as packages/action/action.yml', () => {
25+
expect(Object.keys(rootAction.inputs ?? {})).toEqual(
26+
Object.keys(pkgAction.inputs ?? {})
27+
);
28+
});
29+
30+
it('has the same outputs as packages/action/action.yml', () => {
31+
expect(Object.keys(rootAction.outputs ?? {})).toEqual(
32+
Object.keys(pkgAction.outputs ?? {})
33+
);
34+
});
35+
36+
it('packages/action/action.yml still uses relative dist path', () => {
37+
expect(pkgAction.runs.main).toBe('dist/index.js');
38+
});
39+
});

0 commit comments

Comments
 (0)