@graphql-inspector/action 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/action/helpers/utils.js +18 -12
- package/cjs/action/src/run.js +35 -15
- package/cjs/run.js +35 -15
- package/esm/action/helpers/utils.js +17 -12
- package/esm/action/src/run.js +36 -16
- package/esm/run.js +36 -16
- package/package.json +4 -4
- package/typings/action/helpers/types.d.cts +5 -0
- package/typings/action/helpers/types.d.ts +5 -0
- package/typings/action/helpers/utils.d.cts +2 -0
- package/typings/action/helpers/utils.d.ts +2 -0
|
@@ -5,6 +5,7 @@ exports.quotesTransformer = quotesTransformer;
|
|
|
5
5
|
exports.slackCoderize = slackCoderize;
|
|
6
6
|
exports.discordCoderize = discordCoderize;
|
|
7
7
|
exports.filterChangesByLevel = filterChangesByLevel;
|
|
8
|
+
exports.splitChangesIntoGroups = splitChangesIntoGroups;
|
|
8
9
|
exports.createSummary = createSummary;
|
|
9
10
|
exports.isNil = isNil;
|
|
10
11
|
exports.parseEndpoint = parseEndpoint;
|
|
@@ -31,16 +32,21 @@ function discordCoderize(msg) {
|
|
|
31
32
|
function filterChangesByLevel(level) {
|
|
32
33
|
return (change) => change.criticality.level === level;
|
|
33
34
|
}
|
|
35
|
+
function splitChangesIntoGroups(changes) {
|
|
36
|
+
return {
|
|
37
|
+
breaking: changes.filter(filterChangesByLevel(core_1.CriticalityLevel.Breaking)),
|
|
38
|
+
dangerous: changes.filter(filterChangesByLevel(core_1.CriticalityLevel.Dangerous)),
|
|
39
|
+
safe: changes.filter(filterChangesByLevel(core_1.CriticalityLevel.NonBreaking)),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
34
42
|
function createSummary(changes, summaryLimit, isLegacyConfig = false) {
|
|
35
|
-
const
|
|
36
|
-
const dangerousChanges = changes.filter(filterChangesByLevel(core_1.CriticalityLevel.Dangerous));
|
|
37
|
-
const safeChanges = changes.filter(filterChangesByLevel(core_1.CriticalityLevel.NonBreaking));
|
|
43
|
+
const groupedChanges = splitChangesIntoGroups(changes);
|
|
38
44
|
const summary = [
|
|
39
45
|
`# Found ${changes.length} change${changes.length > 1 ? 's' : ''}`,
|
|
40
46
|
'',
|
|
41
|
-
`Breaking: ${
|
|
42
|
-
`Dangerous: ${
|
|
43
|
-
`Safe: ${
|
|
47
|
+
`Breaking: ${groupedChanges.breaking.length}`,
|
|
48
|
+
`Dangerous: ${groupedChanges.dangerous.length}`,
|
|
49
|
+
`Safe: ${groupedChanges.safe.length}`,
|
|
44
50
|
];
|
|
45
51
|
if (isLegacyConfig) {
|
|
46
52
|
summary.push([
|
|
@@ -63,14 +69,14 @@ function createSummary(changes, summaryLimit, isLegacyConfig = false) {
|
|
|
63
69
|
}
|
|
64
70
|
summaryLimit -= changes.length;
|
|
65
71
|
}
|
|
66
|
-
if (
|
|
67
|
-
addChangesToSummary('Breaking',
|
|
72
|
+
if (groupedChanges.breaking.length) {
|
|
73
|
+
addChangesToSummary('Breaking', groupedChanges.breaking);
|
|
68
74
|
}
|
|
69
|
-
if (
|
|
70
|
-
addChangesToSummary('Dangerous',
|
|
75
|
+
if (groupedChanges.dangerous.length) {
|
|
76
|
+
addChangesToSummary('Dangerous', groupedChanges.dangerous);
|
|
71
77
|
}
|
|
72
|
-
if (
|
|
73
|
-
addChangesToSummary('Safe',
|
|
78
|
+
if (groupedChanges.safe.length) {
|
|
79
|
+
addChangesToSummary('Safe', groupedChanges.safe);
|
|
74
80
|
}
|
|
75
81
|
summary.push([
|
|
76
82
|
'',
|
package/cjs/action/src/run.js
CHANGED
|
@@ -40,21 +40,30 @@ async function run() {
|
|
|
40
40
|
const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
|
|
41
41
|
const rulesList = (0, utils_js_2.getInputAsArray)('rules') || [];
|
|
42
42
|
const onUsage = core.getInput('onUsage');
|
|
43
|
+
const createActionCheck = (0, utils_js_2.castToBoolean)(core.getInput('create-action-check'), true);
|
|
43
44
|
const octokit = github.getOctokit(token);
|
|
44
45
|
// repo
|
|
45
46
|
const { owner, repo } = github.context.repo;
|
|
46
47
|
// pull request
|
|
47
48
|
const pullRequest = await (0, git_js_1.getAssociatedPullRequest)(octokit, commitSha);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
let checkId = null;
|
|
50
|
+
let seeCheckURL = '';
|
|
51
|
+
if (createActionCheck) {
|
|
52
|
+
core.info(`Creating a check named "${checkName}"`);
|
|
53
|
+
const check = await octokit.rest.checks.create({
|
|
54
|
+
owner,
|
|
55
|
+
repo,
|
|
56
|
+
name: checkName,
|
|
57
|
+
head_sha: commitSha,
|
|
58
|
+
status: 'in_progress',
|
|
59
|
+
});
|
|
60
|
+
checkId = check.data.id;
|
|
61
|
+
seeCheckURL = ' For more info see: ' + check.data.html_url;
|
|
62
|
+
core.info(`Check ID: ${checkId}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
core.info('Skipping check creation - disabled by input option');
|
|
66
|
+
}
|
|
58
67
|
const schemaPointer = core.getInput('schema', { required: true });
|
|
59
68
|
const loadFile = (0, files_js_1.fileLoader)({
|
|
60
69
|
octokit,
|
|
@@ -157,8 +166,11 @@ async function run() {
|
|
|
157
166
|
let conclusion = action.conclusion;
|
|
158
167
|
let annotations = action.annotations || [];
|
|
159
168
|
const changes = action.changes || [];
|
|
169
|
+
const groupedChanges = (0, utils_js_1.splitChangesIntoGroups)(changes);
|
|
160
170
|
core.setOutput('changes', String(changes.length || 0));
|
|
161
|
-
core.
|
|
171
|
+
core.setOutput('breaking-changes', groupedChanges.breaking.map(c => c.message));
|
|
172
|
+
core.setOutput('dangerous-changes', groupedChanges.dangerous.map(c => c.message));
|
|
173
|
+
core.setOutput('safe-changes', groupedChanges.safe.map(c => c.message));
|
|
162
174
|
const hasApprovedBreakingChangeLabel = pullRequest?.labels?.some((label) => label.name === approveLabel);
|
|
163
175
|
// Force Success when failOnBreaking is disabled
|
|
164
176
|
if ((failOnBreaking === false || hasApprovedBreakingChangeLabel) &&
|
|
@@ -166,6 +178,18 @@ async function run() {
|
|
|
166
178
|
core.info('FailOnBreaking disabled. Forcing SUCCESS');
|
|
167
179
|
conclusion = types_js_1.CheckConclusion.Success;
|
|
168
180
|
}
|
|
181
|
+
const title = conclusion === types_js_1.CheckConclusion.Failure
|
|
182
|
+
? 'Something is wrong with your schema.' + seeCheckURL // add Check URL to navigate users to Check from action.
|
|
183
|
+
: 'Everything looks good';
|
|
184
|
+
core.info(`Conclusion: ${conclusion}`);
|
|
185
|
+
// Action Check is disabled
|
|
186
|
+
if (checkId === null) {
|
|
187
|
+
core.info('Github Action Check is disabled, use outputs to determine errors');
|
|
188
|
+
if (conclusion === types_js_1.CheckConclusion.Failure) {
|
|
189
|
+
core.setFailed(conclusion);
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
169
193
|
if (useAnnotations === false || isNewSchemaUrl) {
|
|
170
194
|
core.info(`Anotations are disabled. Skipping annotations...`);
|
|
171
195
|
annotations = [];
|
|
@@ -176,10 +200,6 @@ async function run() {
|
|
|
176
200
|
: annotation.annotation_level !== types_js_1.AnnotationLevel.Notice);
|
|
177
201
|
}
|
|
178
202
|
const summary = (0, utils_js_1.createSummary)(changes, 100, false);
|
|
179
|
-
const title = conclusion === types_js_1.CheckConclusion.Failure
|
|
180
|
-
? 'Something is wrong with your schema'
|
|
181
|
-
: 'Everything looks good';
|
|
182
|
-
core.info(`Conclusion: ${conclusion}`);
|
|
183
203
|
try {
|
|
184
204
|
return await (0, checks_js_1.updateCheckRun)(octokit, checkId, {
|
|
185
205
|
conclusion,
|
package/cjs/run.js
CHANGED
|
@@ -40,21 +40,30 @@ async function run() {
|
|
|
40
40
|
const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
|
|
41
41
|
const rulesList = (0, utils_js_2.getInputAsArray)('rules') || [];
|
|
42
42
|
const onUsage = core.getInput('onUsage');
|
|
43
|
+
const createActionCheck = (0, utils_js_2.castToBoolean)(core.getInput('create-action-check'), true);
|
|
43
44
|
const octokit = github.getOctokit(token);
|
|
44
45
|
// repo
|
|
45
46
|
const { owner, repo } = github.context.repo;
|
|
46
47
|
// pull request
|
|
47
48
|
const pullRequest = await (0, git_js_1.getAssociatedPullRequest)(octokit, commitSha);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
let checkId = null;
|
|
50
|
+
let seeCheckURL = '';
|
|
51
|
+
if (createActionCheck) {
|
|
52
|
+
core.info(`Creating a check named "${checkName}"`);
|
|
53
|
+
const check = await octokit.rest.checks.create({
|
|
54
|
+
owner,
|
|
55
|
+
repo,
|
|
56
|
+
name: checkName,
|
|
57
|
+
head_sha: commitSha,
|
|
58
|
+
status: 'in_progress',
|
|
59
|
+
});
|
|
60
|
+
checkId = check.data.id;
|
|
61
|
+
seeCheckURL = ' For more info see: ' + check.data.html_url;
|
|
62
|
+
core.info(`Check ID: ${checkId}`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
core.info('Skipping check creation - disabled by input option');
|
|
66
|
+
}
|
|
58
67
|
const schemaPointer = core.getInput('schema', { required: true });
|
|
59
68
|
const loadFile = (0, files_js_1.fileLoader)({
|
|
60
69
|
octokit,
|
|
@@ -157,8 +166,11 @@ async function run() {
|
|
|
157
166
|
let conclusion = action.conclusion;
|
|
158
167
|
let annotations = action.annotations || [];
|
|
159
168
|
const changes = action.changes || [];
|
|
169
|
+
const groupedChanges = (0, utils_js_1.splitChangesIntoGroups)(changes);
|
|
160
170
|
core.setOutput('changes', String(changes.length || 0));
|
|
161
|
-
core.
|
|
171
|
+
core.setOutput('breaking-changes', groupedChanges.breaking.map(c => c.message));
|
|
172
|
+
core.setOutput('dangerous-changes', groupedChanges.dangerous.map(c => c.message));
|
|
173
|
+
core.setOutput('safe-changes', groupedChanges.safe.map(c => c.message));
|
|
162
174
|
const hasApprovedBreakingChangeLabel = pullRequest?.labels?.some((label) => label.name === approveLabel);
|
|
163
175
|
// Force Success when failOnBreaking is disabled
|
|
164
176
|
if ((failOnBreaking === false || hasApprovedBreakingChangeLabel) &&
|
|
@@ -166,6 +178,18 @@ async function run() {
|
|
|
166
178
|
core.info('FailOnBreaking disabled. Forcing SUCCESS');
|
|
167
179
|
conclusion = types_js_1.CheckConclusion.Success;
|
|
168
180
|
}
|
|
181
|
+
const title = conclusion === types_js_1.CheckConclusion.Failure
|
|
182
|
+
? 'Something is wrong with your schema.' + seeCheckURL // add Check URL to navigate users to Check from action.
|
|
183
|
+
: 'Everything looks good';
|
|
184
|
+
core.info(`Conclusion: ${conclusion}`);
|
|
185
|
+
// Action Check is disabled
|
|
186
|
+
if (checkId === null) {
|
|
187
|
+
core.info('Github Action Check is disabled, use outputs to determine errors');
|
|
188
|
+
if (conclusion === types_js_1.CheckConclusion.Failure) {
|
|
189
|
+
core.setFailed(conclusion);
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
169
193
|
if (useAnnotations === false || isNewSchemaUrl) {
|
|
170
194
|
core.info(`Anotations are disabled. Skipping annotations...`);
|
|
171
195
|
annotations = [];
|
|
@@ -176,10 +200,6 @@ async function run() {
|
|
|
176
200
|
: annotation.annotation_level !== types_js_1.AnnotationLevel.Notice);
|
|
177
201
|
}
|
|
178
202
|
const summary = (0, utils_js_1.createSummary)(changes, 100, false);
|
|
179
|
-
const title = conclusion === types_js_1.CheckConclusion.Failure
|
|
180
|
-
? 'Something is wrong with your schema'
|
|
181
|
-
: 'Everything looks good';
|
|
182
|
-
core.info(`Conclusion: ${conclusion}`);
|
|
183
203
|
try {
|
|
184
204
|
return await (0, checks_js_1.updateCheckRun)(octokit, checkId, {
|
|
185
205
|
conclusion,
|
|
@@ -19,16 +19,21 @@ export function discordCoderize(msg) {
|
|
|
19
19
|
export function filterChangesByLevel(level) {
|
|
20
20
|
return (change) => change.criticality.level === level;
|
|
21
21
|
}
|
|
22
|
+
export function splitChangesIntoGroups(changes) {
|
|
23
|
+
return {
|
|
24
|
+
breaking: changes.filter(filterChangesByLevel(CriticalityLevel.Breaking)),
|
|
25
|
+
dangerous: changes.filter(filterChangesByLevel(CriticalityLevel.Dangerous)),
|
|
26
|
+
safe: changes.filter(filterChangesByLevel(CriticalityLevel.NonBreaking)),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
22
29
|
export function createSummary(changes, summaryLimit, isLegacyConfig = false) {
|
|
23
|
-
const
|
|
24
|
-
const dangerousChanges = changes.filter(filterChangesByLevel(CriticalityLevel.Dangerous));
|
|
25
|
-
const safeChanges = changes.filter(filterChangesByLevel(CriticalityLevel.NonBreaking));
|
|
30
|
+
const groupedChanges = splitChangesIntoGroups(changes);
|
|
26
31
|
const summary = [
|
|
27
32
|
`# Found ${changes.length} change${changes.length > 1 ? 's' : ''}`,
|
|
28
33
|
'',
|
|
29
|
-
`Breaking: ${
|
|
30
|
-
`Dangerous: ${
|
|
31
|
-
`Safe: ${
|
|
34
|
+
`Breaking: ${groupedChanges.breaking.length}`,
|
|
35
|
+
`Dangerous: ${groupedChanges.dangerous.length}`,
|
|
36
|
+
`Safe: ${groupedChanges.safe.length}`,
|
|
32
37
|
];
|
|
33
38
|
if (isLegacyConfig) {
|
|
34
39
|
summary.push([
|
|
@@ -51,14 +56,14 @@ export function createSummary(changes, summaryLimit, isLegacyConfig = false) {
|
|
|
51
56
|
}
|
|
52
57
|
summaryLimit -= changes.length;
|
|
53
58
|
}
|
|
54
|
-
if (
|
|
55
|
-
addChangesToSummary('Breaking',
|
|
59
|
+
if (groupedChanges.breaking.length) {
|
|
60
|
+
addChangesToSummary('Breaking', groupedChanges.breaking);
|
|
56
61
|
}
|
|
57
|
-
if (
|
|
58
|
-
addChangesToSummary('Dangerous',
|
|
62
|
+
if (groupedChanges.dangerous.length) {
|
|
63
|
+
addChangesToSummary('Dangerous', groupedChanges.dangerous);
|
|
59
64
|
}
|
|
60
|
-
if (
|
|
61
|
-
addChangesToSummary('Safe',
|
|
65
|
+
if (groupedChanges.safe.length) {
|
|
66
|
+
addChangesToSummary('Safe', groupedChanges.safe);
|
|
62
67
|
}
|
|
63
68
|
summary.push([
|
|
64
69
|
'',
|
package/esm/action/src/run.js
CHANGED
|
@@ -6,7 +6,7 @@ import { diff } from '../helpers/diff.js';
|
|
|
6
6
|
import { printSchemaFromEndpoint } from '../helpers/loaders.js';
|
|
7
7
|
import { produceSchema } from '../helpers/schema.js';
|
|
8
8
|
import { AnnotationFilterLevel, AnnotationLevel, CheckConclusion } from '../helpers/types.js';
|
|
9
|
-
import { createSummary } from '../helpers/utils.js';
|
|
9
|
+
import { createSummary, splitChangesIntoGroups } from '../helpers/utils.js';
|
|
10
10
|
import { updateCheckRun } from './checks.js';
|
|
11
11
|
import { fileLoader } from './files.js';
|
|
12
12
|
import { getAssociatedPullRequest, getCurrentCommitSha } from './git.js';
|
|
@@ -36,21 +36,30 @@ export async function run() {
|
|
|
36
36
|
const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
|
|
37
37
|
const rulesList = getInputAsArray('rules') || [];
|
|
38
38
|
const onUsage = core.getInput('onUsage');
|
|
39
|
+
const createActionCheck = castToBoolean(core.getInput('create-action-check'), true);
|
|
39
40
|
const octokit = github.getOctokit(token);
|
|
40
41
|
// repo
|
|
41
42
|
const { owner, repo } = github.context.repo;
|
|
42
43
|
// pull request
|
|
43
44
|
const pullRequest = await getAssociatedPullRequest(octokit, commitSha);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
let checkId = null;
|
|
46
|
+
let seeCheckURL = '';
|
|
47
|
+
if (createActionCheck) {
|
|
48
|
+
core.info(`Creating a check named "${checkName}"`);
|
|
49
|
+
const check = await octokit.rest.checks.create({
|
|
50
|
+
owner,
|
|
51
|
+
repo,
|
|
52
|
+
name: checkName,
|
|
53
|
+
head_sha: commitSha,
|
|
54
|
+
status: 'in_progress',
|
|
55
|
+
});
|
|
56
|
+
checkId = check.data.id;
|
|
57
|
+
seeCheckURL = ' For more info see: ' + check.data.html_url;
|
|
58
|
+
core.info(`Check ID: ${checkId}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
core.info('Skipping check creation - disabled by input option');
|
|
62
|
+
}
|
|
54
63
|
const schemaPointer = core.getInput('schema', { required: true });
|
|
55
64
|
const loadFile = fileLoader({
|
|
56
65
|
octokit,
|
|
@@ -153,8 +162,11 @@ export async function run() {
|
|
|
153
162
|
let conclusion = action.conclusion;
|
|
154
163
|
let annotations = action.annotations || [];
|
|
155
164
|
const changes = action.changes || [];
|
|
165
|
+
const groupedChanges = splitChangesIntoGroups(changes);
|
|
156
166
|
core.setOutput('changes', String(changes.length || 0));
|
|
157
|
-
core.
|
|
167
|
+
core.setOutput('breaking-changes', groupedChanges.breaking.map(c => c.message));
|
|
168
|
+
core.setOutput('dangerous-changes', groupedChanges.dangerous.map(c => c.message));
|
|
169
|
+
core.setOutput('safe-changes', groupedChanges.safe.map(c => c.message));
|
|
158
170
|
const hasApprovedBreakingChangeLabel = pullRequest?.labels?.some((label) => label.name === approveLabel);
|
|
159
171
|
// Force Success when failOnBreaking is disabled
|
|
160
172
|
if ((failOnBreaking === false || hasApprovedBreakingChangeLabel) &&
|
|
@@ -162,6 +174,18 @@ export async function run() {
|
|
|
162
174
|
core.info('FailOnBreaking disabled. Forcing SUCCESS');
|
|
163
175
|
conclusion = CheckConclusion.Success;
|
|
164
176
|
}
|
|
177
|
+
const title = conclusion === CheckConclusion.Failure
|
|
178
|
+
? 'Something is wrong with your schema.' + seeCheckURL // add Check URL to navigate users to Check from action.
|
|
179
|
+
: 'Everything looks good';
|
|
180
|
+
core.info(`Conclusion: ${conclusion}`);
|
|
181
|
+
// Action Check is disabled
|
|
182
|
+
if (checkId === null) {
|
|
183
|
+
core.info('Github Action Check is disabled, use outputs to determine errors');
|
|
184
|
+
if (conclusion === CheckConclusion.Failure) {
|
|
185
|
+
core.setFailed(conclusion);
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
165
189
|
if (useAnnotations === false || isNewSchemaUrl) {
|
|
166
190
|
core.info(`Anotations are disabled. Skipping annotations...`);
|
|
167
191
|
annotations = [];
|
|
@@ -172,10 +196,6 @@ export async function run() {
|
|
|
172
196
|
: annotation.annotation_level !== AnnotationLevel.Notice);
|
|
173
197
|
}
|
|
174
198
|
const summary = createSummary(changes, 100, false);
|
|
175
|
-
const title = conclusion === CheckConclusion.Failure
|
|
176
|
-
? 'Something is wrong with your schema'
|
|
177
|
-
: 'Everything looks good';
|
|
178
|
-
core.info(`Conclusion: ${conclusion}`);
|
|
179
199
|
try {
|
|
180
200
|
return await updateCheckRun(octokit, checkId, {
|
|
181
201
|
conclusion,
|
package/esm/run.js
CHANGED
|
@@ -6,7 +6,7 @@ import { diff } from '../helpers/diff.js';
|
|
|
6
6
|
import { printSchemaFromEndpoint } from '../helpers/loaders.js';
|
|
7
7
|
import { produceSchema } from '../helpers/schema.js';
|
|
8
8
|
import { AnnotationFilterLevel, AnnotationLevel, CheckConclusion } from '../helpers/types.js';
|
|
9
|
-
import { createSummary } from '../helpers/utils.js';
|
|
9
|
+
import { createSummary, splitChangesIntoGroups } from '../helpers/utils.js';
|
|
10
10
|
import { updateCheckRun } from './checks.js';
|
|
11
11
|
import { fileLoader } from './files.js';
|
|
12
12
|
import { getAssociatedPullRequest, getCurrentCommitSha } from './git.js';
|
|
@@ -36,21 +36,30 @@ export async function run() {
|
|
|
36
36
|
const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
|
|
37
37
|
const rulesList = getInputAsArray('rules') || [];
|
|
38
38
|
const onUsage = core.getInput('onUsage');
|
|
39
|
+
const createActionCheck = castToBoolean(core.getInput('create-action-check'), true);
|
|
39
40
|
const octokit = github.getOctokit(token);
|
|
40
41
|
// repo
|
|
41
42
|
const { owner, repo } = github.context.repo;
|
|
42
43
|
// pull request
|
|
43
44
|
const pullRequest = await getAssociatedPullRequest(octokit, commitSha);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
let checkId = null;
|
|
46
|
+
let seeCheckURL = '';
|
|
47
|
+
if (createActionCheck) {
|
|
48
|
+
core.info(`Creating a check named "${checkName}"`);
|
|
49
|
+
const check = await octokit.rest.checks.create({
|
|
50
|
+
owner,
|
|
51
|
+
repo,
|
|
52
|
+
name: checkName,
|
|
53
|
+
head_sha: commitSha,
|
|
54
|
+
status: 'in_progress',
|
|
55
|
+
});
|
|
56
|
+
checkId = check.data.id;
|
|
57
|
+
seeCheckURL = ' For more info see: ' + check.data.html_url;
|
|
58
|
+
core.info(`Check ID: ${checkId}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
core.info('Skipping check creation - disabled by input option');
|
|
62
|
+
}
|
|
54
63
|
const schemaPointer = core.getInput('schema', { required: true });
|
|
55
64
|
const loadFile = fileLoader({
|
|
56
65
|
octokit,
|
|
@@ -153,8 +162,11 @@ export async function run() {
|
|
|
153
162
|
let conclusion = action.conclusion;
|
|
154
163
|
let annotations = action.annotations || [];
|
|
155
164
|
const changes = action.changes || [];
|
|
165
|
+
const groupedChanges = splitChangesIntoGroups(changes);
|
|
156
166
|
core.setOutput('changes', String(changes.length || 0));
|
|
157
|
-
core.
|
|
167
|
+
core.setOutput('breaking-changes', groupedChanges.breaking.map(c => c.message));
|
|
168
|
+
core.setOutput('dangerous-changes', groupedChanges.dangerous.map(c => c.message));
|
|
169
|
+
core.setOutput('safe-changes', groupedChanges.safe.map(c => c.message));
|
|
158
170
|
const hasApprovedBreakingChangeLabel = pullRequest?.labels?.some((label) => label.name === approveLabel);
|
|
159
171
|
// Force Success when failOnBreaking is disabled
|
|
160
172
|
if ((failOnBreaking === false || hasApprovedBreakingChangeLabel) &&
|
|
@@ -162,6 +174,18 @@ export async function run() {
|
|
|
162
174
|
core.info('FailOnBreaking disabled. Forcing SUCCESS');
|
|
163
175
|
conclusion = CheckConclusion.Success;
|
|
164
176
|
}
|
|
177
|
+
const title = conclusion === CheckConclusion.Failure
|
|
178
|
+
? 'Something is wrong with your schema.' + seeCheckURL // add Check URL to navigate users to Check from action.
|
|
179
|
+
: 'Everything looks good';
|
|
180
|
+
core.info(`Conclusion: ${conclusion}`);
|
|
181
|
+
// Action Check is disabled
|
|
182
|
+
if (checkId === null) {
|
|
183
|
+
core.info('Github Action Check is disabled, use outputs to determine errors');
|
|
184
|
+
if (conclusion === CheckConclusion.Failure) {
|
|
185
|
+
core.setFailed(conclusion);
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
165
189
|
if (useAnnotations === false || isNewSchemaUrl) {
|
|
166
190
|
core.info(`Anotations are disabled. Skipping annotations...`);
|
|
167
191
|
annotations = [];
|
|
@@ -172,10 +196,6 @@ export async function run() {
|
|
|
172
196
|
: annotation.annotation_level !== AnnotationLevel.Notice);
|
|
173
197
|
}
|
|
174
198
|
const summary = createSummary(changes, 100, false);
|
|
175
|
-
const title = conclusion === CheckConclusion.Failure
|
|
176
|
-
? 'Something is wrong with your schema'
|
|
177
|
-
: 'Everything looks good';
|
|
178
|
-
core.info(`Conclusion: ${conclusion}`);
|
|
179
199
|
try {
|
|
180
200
|
return await updateCheckRun(octokit, checkId, {
|
|
181
201
|
conclusion,
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/action",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "GraphQL Inspector functionality for GitHub Actions",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@actions/core": "^1.10.1",
|
|
8
8
|
"@actions/github": "^6.0.0",
|
|
9
|
+
"@graphql-inspector/commands": "^7.0.0",
|
|
10
|
+
"@graphql-inspector/core": "^8.0.0",
|
|
9
11
|
"dataloader": "^2.2.2",
|
|
10
12
|
"js-yaml": "^4.1.1",
|
|
11
13
|
"probot": "^13.2.2",
|
|
12
|
-
"tslib": "~2.6.2"
|
|
13
|
-
"@graphql-inspector/commands": "^7.0.0",
|
|
14
|
-
"@graphql-inspector/core": "^8.0.0"
|
|
14
|
+
"tslib": "~2.6.2"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -5,6 +5,11 @@ export interface ActionResult {
|
|
|
5
5
|
annotations?: Annotation[];
|
|
6
6
|
changes?: Change[];
|
|
7
7
|
}
|
|
8
|
+
export interface GroupedChanges {
|
|
9
|
+
breaking: Change[];
|
|
10
|
+
dangerous: Change[];
|
|
11
|
+
safe: Change[];
|
|
12
|
+
}
|
|
8
13
|
export interface Annotation {
|
|
9
14
|
path: string;
|
|
10
15
|
start_line: number;
|
|
@@ -5,6 +5,11 @@ export interface ActionResult {
|
|
|
5
5
|
annotations?: Annotation[];
|
|
6
6
|
changes?: Change[];
|
|
7
7
|
}
|
|
8
|
+
export interface GroupedChanges {
|
|
9
|
+
breaking: Change[];
|
|
10
|
+
dangerous: Change[];
|
|
11
|
+
safe: Change[];
|
|
12
|
+
}
|
|
8
13
|
export interface Annotation {
|
|
9
14
|
path: string;
|
|
10
15
|
start_line: number;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Change, CriticalityLevel } from '@graphql-inspector/core';
|
|
2
2
|
import { Endpoint } from './config.cjs';
|
|
3
|
+
import { GroupedChanges } from './types.cjs';
|
|
3
4
|
export declare function bolderize(msg: string): string;
|
|
4
5
|
export declare function quotesTransformer(msg: string, symbols?: string): string;
|
|
5
6
|
export declare function slackCoderize(msg: string): string;
|
|
6
7
|
export declare function discordCoderize(msg: string): string;
|
|
7
8
|
export declare function filterChangesByLevel(level: CriticalityLevel): (change: Change) => boolean;
|
|
9
|
+
export declare function splitChangesIntoGroups(changes: Change[]): GroupedChanges;
|
|
8
10
|
export declare function createSummary(changes: Change[], summaryLimit: number, isLegacyConfig?: boolean): string;
|
|
9
11
|
export declare function isNil(val: any): val is undefined | null;
|
|
10
12
|
export declare function parseEndpoint(endpoint: Endpoint): {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Change, CriticalityLevel } from '@graphql-inspector/core';
|
|
2
2
|
import { Endpoint } from './config.js';
|
|
3
|
+
import { GroupedChanges } from './types.js';
|
|
3
4
|
export declare function bolderize(msg: string): string;
|
|
4
5
|
export declare function quotesTransformer(msg: string, symbols?: string): string;
|
|
5
6
|
export declare function slackCoderize(msg: string): string;
|
|
6
7
|
export declare function discordCoderize(msg: string): string;
|
|
7
8
|
export declare function filterChangesByLevel(level: CriticalityLevel): (change: Change) => boolean;
|
|
9
|
+
export declare function splitChangesIntoGroups(changes: Change[]): GroupedChanges;
|
|
8
10
|
export declare function createSummary(changes: Change[], summaryLimit: number, isLegacyConfig?: boolean): string;
|
|
9
11
|
export declare function isNil(val: any): val is undefined | null;
|
|
10
12
|
export declare function parseEndpoint(endpoint: Endpoint): {
|