Skip to content

Commit 788db4c

Browse files
Merge branch 'main' into test
2 parents e4c9c53 + 4d28fab commit 788db4c

646 files changed

Lines changed: 3701 additions & 451 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@
88
version: 2
99

1010
updates:
11+
1112
- package-ecosystem: github-actions
13+
commit-message:
14+
prefix: dep(GHA)
1215
directory: /
16+
labels:
17+
- "dependencies"
18+
- "gh actions"
1319
schedule:
1420
interval: monthly
15-
commit-message:
16-
prefix: ci
1721

1822
- package-ecosystem: npm # See documentation for possible values
23+
commit-message:
24+
prefix: dep(prod)
25+
prefix-development: dep(dev)
1926
directories:
2027
- / # Location of package manifests
2128
- /recipies/*
22-
commit-message:
23-
prefix: deps
29+
labels:
30+
- "dependencies"
31+
- "npm"
2432
schedule:
2533
interval: weekly

.github/scripts/pr-prefixes.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* The subset of conventional commit prefixes used in this project.
3+
*/
4+
export const SUPPORTED_PREFIXES = [
5+
'doc',
6+
'dep',
7+
'fix',
8+
'feat',
9+
'setup',
10+
'test',
11+
] as const;
12+
13+
export const SCOPE_RGX = new RegExp(`^(${SUPPORTED_PREFIXES.join('|')})\\([\\w\\-\\d]*\\)\\: `);

.github/scripts/pr-title.test.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { equal, match } from 'node:assert/strict';
2+
import { execPath } from 'node:process';
3+
import { describe, it } from 'node:test';
4+
import { fileURLToPath } from 'node:url';
5+
6+
import { spawnPromisified } from '../../utils/src/spawn-promisified.ts';
7+
8+
import { SUPPORTED_PREFIXES } from './pr-prefixes.ts';
9+
10+
describe('Pull Request checks', { concurrency: true }, async () => {
11+
const encoding = 'utf8';
12+
const prTestPath = fileURLToPath(import.meta.resolve('./pr-title.ts'));
13+
14+
for (const prefix of SUPPORTED_PREFIXES) {
15+
describe(prefix, () => {
16+
it('should pass when valid', async () => {
17+
const { code, stderr } = await spawnPromisified(
18+
execPath,
19+
[prTestPath],
20+
{
21+
encoding,
22+
env: { PR_TITLE: `${prefix}(DEP0000): update …` },
23+
},
24+
);
25+
26+
equal(stderr, '');
27+
equal(code, 0);
28+
});
29+
30+
it('should fail when missing scope', async () => {
31+
const { code, stderr } = await spawnPromisified(
32+
execPath,
33+
[prTestPath],
34+
{
35+
encoding,
36+
env: { PR_TITLE: `${prefix}: update …` },
37+
},
38+
);
39+
40+
match(stderr, /AssertionError/);
41+
match(stderr, new RegExp(prefix));
42+
match(stderr, /pull request title/i);
43+
equal(code, 1);
44+
});
45+
46+
it('should fail scope is misformatted', async () => {
47+
const { code, stderr } = await spawnPromisified(
48+
execPath,
49+
[prTestPath],
50+
{
51+
encoding,
52+
env: { PR_TITLE: `${prefix}(DEP0000) update …` },
53+
},
54+
);
55+
56+
match(stderr, /AssertionError/);
57+
match(stderr, new RegExp(prefix));
58+
match(stderr, /pull request title/i);
59+
equal(code, 1);
60+
});
61+
});
62+
}
63+
64+
describe('unsupported prefix', () => {
65+
it('should fail', async () => {
66+
const prefix = 'foo';
67+
const { code, stderr } = await spawnPromisified(execPath, [prTestPath], {
68+
encoding,
69+
env: { PR_TITLE: `${prefix}(DEP0000): update …` },
70+
});
71+
72+
match(stderr, /AssertionError/);
73+
match(stderr, new RegExp(prefix));
74+
match(stderr, /pull request title/i);
75+
for (const p of SUPPORTED_PREFIXES) match(stderr, new RegExp(p));
76+
equal(code, 1);
77+
});
78+
})
79+
});

.github/scripts/pr-title.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import assert from 'node:assert/strict';
2+
import { env } from 'node:process';
3+
4+
import { SCOPE_RGX, SUPPORTED_PREFIXES } from './pr-prefixes.ts';
5+
6+
declare global {
7+
namespace NodeJS {
8+
interface ProcessEnv {
9+
PR_TITLE: string;
10+
}
11+
}
12+
}
13+
14+
const { PR_TITLE } = env;
15+
16+
const INVALID_PR_TITLE_ERR = '\
17+
The pull request title did not match the required format; see CONTRIBUTING.md for details.\
18+
';
19+
20+
assert.match(PR_TITLE, SCOPE_RGX, INVALID_PR_TITLE_ERR);
21+
const firstParen = PR_TITLE.indexOf('(');
22+
const prefix = PR_TITLE.slice(0, firstParen);
23+
24+
assert.ok(
25+
SUPPORTED_PREFIXES.includes(prefix),
26+
`The pull request title prefix '${prefix}' is not in the supported list: '${SUPPORTED_PREFIXES.join("', '")}'`,
27+
);

.github/workflows/ci.yml

Lines changed: 0 additions & 169 deletions
This file was deleted.

0 commit comments

Comments
 (0)