Skip to content

Commit 542b050

Browse files
authored
feat: add MultiConfigChecker to validate multiple schemas in a single pass (#4045)
Towards #3821. We want to be able to validate other JSON config files. We can reimplement the PR file checking loop, but it's inefficient to fetch/scan the PR files multiple times. Instead, we implement a new `MultiConfigChecker` which does multiple schema checks in a single file fetch loop. It will create individual GitHub checks for each invalid config file. feat: support validating JSON files as well refactor: ConfigChecker uses MultiConfigChecker
1 parent d4c87d3 commit 542b050

9 files changed

Lines changed: 454 additions & 83 deletions

File tree

packages/bot-config-utils/__snapshots__/bot-config-utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[
77
output: {
88
title: 'Config schema error',
99
summary: 'An error found in the config file',
10-
text: 'You tried to add .github/test.yml, but the config file must be .github/test.yaml\n',
10+
text: 'You tried to add .github/test.yml, but the config file must be .github/test.yaml',
1111
},
1212
};
1313

@@ -33,7 +33,7 @@ exports[
3333
output: {
3434
title: 'Config schema error',
3535
summary: 'An error found in the config file',
36-
text: 'You tried to add .github/test.yaml, but the config file must be .github/test.yml\n',
36+
text: 'You tried to add .github/test.yaml, but the config file must be .github/test.yml',
3737
},
3838
};
3939

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
exports[
2+
'MultiConfigChecker with config changes validates a single JSON config 1'
3+
] = {
4+
name: 'foo config schema',
5+
conclusion: 'failure',
6+
head_sha: 'def234',
7+
output: {
8+
title: 'Config schema error',
9+
summary: 'An error found in the config file',
10+
text: '[\n {\n "instancePath": "",\n "schemaPath": "#/additionalProperties",\n "keyword": "additionalProperties",\n "params": {\n "additionalProperty": "test"\n },\n "message": "must NOT have additional properties"\n }\n]',
11+
},
12+
};
13+
14+
exports[
15+
'MultiConfigChecker with config changes validates a single YAML config 1'
16+
] = {
17+
name: 'bar config schema',
18+
conclusion: 'failure',
19+
head_sha: 'def234',
20+
output: {
21+
title: 'Config schema error',
22+
summary: 'An error found in the config file',
23+
text: '[\n {\n "instancePath": "",\n "schemaPath": "#/additionalProperties",\n "keyword": "additionalProperties",\n "params": {\n "additionalProperty": "test"\n },\n "message": "must NOT have additional properties"\n }\n]',
24+
},
25+
};
26+
27+
exports['MultiConfigChecker with config changes validates multiple configs 1'] =
28+
{
29+
name: 'foo config schema',
30+
conclusion: 'failure',
31+
head_sha: 'def234',
32+
output: {
33+
title: 'Config schema error',
34+
summary: 'An error found in the config file',
35+
text: '[\n {\n "instancePath": "",\n "schemaPath": "#/additionalProperties",\n "keyword": "additionalProperties",\n "params": {\n "additionalProperty": "test"\n },\n "message": "must NOT have additional properties"\n }\n]',
36+
},
37+
};
38+
39+
exports['MultiConfigChecker with config changes validates multiple configs 2'] =
40+
{
41+
name: 'bar config schema',
42+
conclusion: 'failure',
43+
head_sha: 'def234',
44+
output: {
45+
title: 'Config schema error',
46+
summary: 'An error found in the config file',
47+
text: '[\n {\n "instancePath": "",\n "schemaPath": "#/additionalProperties",\n "keyword": "additionalProperties",\n "params": {\n "additionalProperty": "test"\n },\n "message": "must NOT have additional properties"\n }\n]',
48+
},
49+
};

0 commit comments

Comments
 (0)