@graphql-inspector/action 6.0.0 → 6.1.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.
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckConclusion = exports.CheckStatus = exports.AnnotationLevel = void 0;
3
+ exports.CheckConclusion = exports.CheckStatus = exports.AnnotationLevel = exports.AnnotationFilterLevel = void 0;
4
+ var AnnotationFilterLevel;
5
+ (function (AnnotationFilterLevel) {
6
+ AnnotationFilterLevel["All"] = "all";
7
+ AnnotationFilterLevel["Dangerous"] = "dangerous";
8
+ AnnotationFilterLevel["Breaking"] = "breaking";
9
+ })(AnnotationFilterLevel || (exports.AnnotationFilterLevel = AnnotationFilterLevel = {}));
4
10
  var AnnotationLevel;
5
11
  (function (AnnotationLevel) {
6
12
  AnnotationLevel["Failure"] = "failure";
@@ -31,6 +31,10 @@ async function run() {
31
31
  }
32
32
  const useMerge = (0, utils_js_2.castToBoolean)(core.getInput('experimental_merge'), true);
33
33
  const useAnnotations = (0, utils_js_2.castToBoolean)(core.getInput('annotations'));
34
+ const annotationLevel = core.getInput('annotation-level') || types_js_1.AnnotationFilterLevel.All;
35
+ if (!(0, utils_js_2.isAnnotationFilterLevel)(annotationLevel)) {
36
+ return core.setFailed(`Invalid annotation-level. Expected one of: ${Object.values(types_js_1.AnnotationFilterLevel).join(', ')}.`);
37
+ }
34
38
  const failOnBreaking = (0, utils_js_2.castToBoolean)(core.getInput('fail-on-breaking'));
35
39
  const endpoint = core.getInput('endpoint');
36
40
  const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
@@ -166,6 +170,11 @@ async function run() {
166
170
  core.info(`Anotations are disabled. Skipping annotations...`);
167
171
  annotations = [];
168
172
  }
173
+ else if (annotationLevel !== types_js_1.AnnotationFilterLevel.All) {
174
+ annotations = annotations.filter(annotation => annotationLevel === types_js_1.AnnotationFilterLevel.Breaking
175
+ ? annotation.annotation_level === types_js_1.AnnotationLevel.Failure
176
+ : annotation.annotation_level !== types_js_1.AnnotationLevel.Notice);
177
+ }
169
178
  const summary = (0, utils_js_1.createSummary)(changes, 100, false);
170
179
  const title = conclusion === types_js_1.CheckConclusion.Failure
171
180
  ? 'Something is wrong with your schema'
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.batch = batch;
4
4
  exports.castToBoolean = castToBoolean;
5
+ exports.isAnnotationFilterLevel = isAnnotationFilterLevel;
5
6
  exports.getInputAsArray = getInputAsArray;
6
7
  exports.resolveRule = resolveRule;
7
8
  const tslib_1 = require("tslib");
@@ -9,6 +10,8 @@ const fs_1 = require("fs");
9
10
  const core = tslib_1.__importStar(require("@actions/core"));
10
11
  const commands_1 = require("@graphql-inspector/commands");
11
12
  const core_1 = require("@graphql-inspector/core");
13
+ const types_js_1 = require("../helpers/types.js");
14
+ const annotationFilterLevels = Object.values(types_js_1.AnnotationFilterLevel);
12
15
  function batch(items, limit) {
13
16
  const batches = [];
14
17
  const batchesNum = Math.ceil(items.length / limit);
@@ -38,6 +41,9 @@ function castToBoolean(value, defaultValue) {
38
41
  }
39
42
  return true;
40
43
  }
44
+ function isAnnotationFilterLevel(value) {
45
+ return annotationFilterLevels.includes(value);
46
+ }
41
47
  function getInputAsArray(name, options) {
42
48
  return core
43
49
  .getInput(name, options)
package/cjs/run.js CHANGED
@@ -31,6 +31,10 @@ async function run() {
31
31
  }
32
32
  const useMerge = (0, utils_js_2.castToBoolean)(core.getInput('experimental_merge'), true);
33
33
  const useAnnotations = (0, utils_js_2.castToBoolean)(core.getInput('annotations'));
34
+ const annotationLevel = core.getInput('annotation-level') || types_js_1.AnnotationFilterLevel.All;
35
+ if (!(0, utils_js_2.isAnnotationFilterLevel)(annotationLevel)) {
36
+ return core.setFailed(`Invalid annotation-level. Expected one of: ${Object.values(types_js_1.AnnotationFilterLevel).join(', ')}.`);
37
+ }
34
38
  const failOnBreaking = (0, utils_js_2.castToBoolean)(core.getInput('fail-on-breaking'));
35
39
  const endpoint = core.getInput('endpoint');
36
40
  const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
@@ -166,6 +170,11 @@ async function run() {
166
170
  core.info(`Anotations are disabled. Skipping annotations...`);
167
171
  annotations = [];
168
172
  }
173
+ else if (annotationLevel !== types_js_1.AnnotationFilterLevel.All) {
174
+ annotations = annotations.filter(annotation => annotationLevel === types_js_1.AnnotationFilterLevel.Breaking
175
+ ? annotation.annotation_level === types_js_1.AnnotationLevel.Failure
176
+ : annotation.annotation_level !== types_js_1.AnnotationLevel.Notice);
177
+ }
169
178
  const summary = (0, utils_js_1.createSummary)(changes, 100, false);
170
179
  const title = conclusion === types_js_1.CheckConclusion.Failure
171
180
  ? 'Something is wrong with your schema'
package/cjs/utils.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.batch = batch;
4
4
  exports.castToBoolean = castToBoolean;
5
+ exports.isAnnotationFilterLevel = isAnnotationFilterLevel;
5
6
  exports.getInputAsArray = getInputAsArray;
6
7
  exports.resolveRule = resolveRule;
7
8
  const tslib_1 = require("tslib");
@@ -9,6 +10,8 @@ const fs_1 = require("fs");
9
10
  const core = tslib_1.__importStar(require("@actions/core"));
10
11
  const commands_1 = require("@graphql-inspector/commands");
11
12
  const core_1 = require("@graphql-inspector/core");
13
+ const types_js_1 = require("../helpers/types.js");
14
+ const annotationFilterLevels = Object.values(types_js_1.AnnotationFilterLevel);
12
15
  function batch(items, limit) {
13
16
  const batches = [];
14
17
  const batchesNum = Math.ceil(items.length / limit);
@@ -38,6 +41,9 @@ function castToBoolean(value, defaultValue) {
38
41
  }
39
42
  return true;
40
43
  }
44
+ function isAnnotationFilterLevel(value) {
45
+ return annotationFilterLevels.includes(value);
46
+ }
41
47
  function getInputAsArray(name, options) {
42
48
  return core
43
49
  .getInput(name, options)
@@ -1,3 +1,9 @@
1
+ export var AnnotationFilterLevel;
2
+ (function (AnnotationFilterLevel) {
3
+ AnnotationFilterLevel["All"] = "all";
4
+ AnnotationFilterLevel["Dangerous"] = "dangerous";
5
+ AnnotationFilterLevel["Breaking"] = "breaking";
6
+ })(AnnotationFilterLevel || (AnnotationFilterLevel = {}));
1
7
  export var AnnotationLevel;
2
8
  (function (AnnotationLevel) {
3
9
  AnnotationLevel["Failure"] = "failure";
@@ -5,12 +5,12 @@ import * as github from '@actions/github';
5
5
  import { diff } from '../helpers/diff.js';
6
6
  import { printSchemaFromEndpoint } from '../helpers/loaders.js';
7
7
  import { produceSchema } from '../helpers/schema.js';
8
- import { CheckConclusion } from '../helpers/types.js';
8
+ import { AnnotationFilterLevel, AnnotationLevel, CheckConclusion } from '../helpers/types.js';
9
9
  import { createSummary } 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';
13
- import { castToBoolean, getInputAsArray, resolveRule } from './utils.js';
13
+ import { castToBoolean, getInputAsArray, isAnnotationFilterLevel, resolveRule } from './utils.js';
14
14
  const CHECK_NAME = 'GraphQL Inspector';
15
15
  export async function run() {
16
16
  core.info(`GraphQL Inspector started`);
@@ -27,6 +27,10 @@ export async function run() {
27
27
  }
28
28
  const useMerge = castToBoolean(core.getInput('experimental_merge'), true);
29
29
  const useAnnotations = castToBoolean(core.getInput('annotations'));
30
+ const annotationLevel = core.getInput('annotation-level') || AnnotationFilterLevel.All;
31
+ if (!isAnnotationFilterLevel(annotationLevel)) {
32
+ return core.setFailed(`Invalid annotation-level. Expected one of: ${Object.values(AnnotationFilterLevel).join(', ')}.`);
33
+ }
30
34
  const failOnBreaking = castToBoolean(core.getInput('fail-on-breaking'));
31
35
  const endpoint = core.getInput('endpoint');
32
36
  const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
@@ -162,6 +166,11 @@ export async function run() {
162
166
  core.info(`Anotations are disabled. Skipping annotations...`);
163
167
  annotations = [];
164
168
  }
169
+ else if (annotationLevel !== AnnotationFilterLevel.All) {
170
+ annotations = annotations.filter(annotation => annotationLevel === AnnotationFilterLevel.Breaking
171
+ ? annotation.annotation_level === AnnotationLevel.Failure
172
+ : annotation.annotation_level !== AnnotationLevel.Notice);
173
+ }
165
174
  const summary = createSummary(changes, 100, false);
166
175
  const title = conclusion === CheckConclusion.Failure
167
176
  ? 'Something is wrong with your schema'
@@ -2,6 +2,8 @@ import { existsSync } from 'fs';
2
2
  import * as core from '@actions/core';
3
3
  import { ensureAbsolute } from '@graphql-inspector/commands';
4
4
  import { DiffRule } from '@graphql-inspector/core';
5
+ import { AnnotationFilterLevel } from '../helpers/types.js';
6
+ const annotationFilterLevels = Object.values(AnnotationFilterLevel);
5
7
  export function batch(items, limit) {
6
8
  const batches = [];
7
9
  const batchesNum = Math.ceil(items.length / limit);
@@ -31,6 +33,9 @@ export function castToBoolean(value, defaultValue) {
31
33
  }
32
34
  return true;
33
35
  }
36
+ export function isAnnotationFilterLevel(value) {
37
+ return annotationFilterLevels.includes(value);
38
+ }
34
39
  export function getInputAsArray(name, options) {
35
40
  return core
36
41
  .getInput(name, options)
package/esm/run.js CHANGED
@@ -5,12 +5,12 @@ import * as github from '@actions/github';
5
5
  import { diff } from '../helpers/diff.js';
6
6
  import { printSchemaFromEndpoint } from '../helpers/loaders.js';
7
7
  import { produceSchema } from '../helpers/schema.js';
8
- import { CheckConclusion } from '../helpers/types.js';
8
+ import { AnnotationFilterLevel, AnnotationLevel, CheckConclusion } from '../helpers/types.js';
9
9
  import { createSummary } 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';
13
- import { castToBoolean, getInputAsArray, resolveRule } from './utils.js';
13
+ import { castToBoolean, getInputAsArray, isAnnotationFilterLevel, resolveRule } from './utils.js';
14
14
  const CHECK_NAME = 'GraphQL Inspector';
15
15
  export async function run() {
16
16
  core.info(`GraphQL Inspector started`);
@@ -27,6 +27,10 @@ export async function run() {
27
27
  }
28
28
  const useMerge = castToBoolean(core.getInput('experimental_merge'), true);
29
29
  const useAnnotations = castToBoolean(core.getInput('annotations'));
30
+ const annotationLevel = core.getInput('annotation-level') || AnnotationFilterLevel.All;
31
+ if (!isAnnotationFilterLevel(annotationLevel)) {
32
+ return core.setFailed(`Invalid annotation-level. Expected one of: ${Object.values(AnnotationFilterLevel).join(', ')}.`);
33
+ }
30
34
  const failOnBreaking = castToBoolean(core.getInput('fail-on-breaking'));
31
35
  const endpoint = core.getInput('endpoint');
32
36
  const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
@@ -162,6 +166,11 @@ export async function run() {
162
166
  core.info(`Anotations are disabled. Skipping annotations...`);
163
167
  annotations = [];
164
168
  }
169
+ else if (annotationLevel !== AnnotationFilterLevel.All) {
170
+ annotations = annotations.filter(annotation => annotationLevel === AnnotationFilterLevel.Breaking
171
+ ? annotation.annotation_level === AnnotationLevel.Failure
172
+ : annotation.annotation_level !== AnnotationLevel.Notice);
173
+ }
165
174
  const summary = createSummary(changes, 100, false);
166
175
  const title = conclusion === CheckConclusion.Failure
167
176
  ? 'Something is wrong with your schema'
package/esm/utils.js CHANGED
@@ -2,6 +2,8 @@ import { existsSync } from 'fs';
2
2
  import * as core from '@actions/core';
3
3
  import { ensureAbsolute } from '@graphql-inspector/commands';
4
4
  import { DiffRule } from '@graphql-inspector/core';
5
+ import { AnnotationFilterLevel } from '../helpers/types.js';
6
+ const annotationFilterLevels = Object.values(AnnotationFilterLevel);
5
7
  export function batch(items, limit) {
6
8
  const batches = [];
7
9
  const batchesNum = Math.ceil(items.length / limit);
@@ -31,6 +33,9 @@ export function castToBoolean(value, defaultValue) {
31
33
  }
32
34
  return true;
33
35
  }
36
+ export function isAnnotationFilterLevel(value) {
37
+ return annotationFilterLevels.includes(value);
38
+ }
34
39
  export function getInputAsArray(name, options) {
35
40
  return core
36
41
  .getInput(name, options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-inspector/action",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "GraphQL Inspector functionality for GitHub Actions",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "graphql-hive/graphql-inspector",
18
+ "url": "https://github.com/graphql-hive/graphql-inspector",
19
19
  "directory": "packages/action"
20
20
  },
21
21
  "keywords": [
@@ -16,6 +16,11 @@ export interface Annotation {
16
16
  start_column?: number;
17
17
  end_column?: number;
18
18
  }
19
+ export declare enum AnnotationFilterLevel {
20
+ All = "all",
21
+ Dangerous = "dangerous",
22
+ Breaking = "breaking"
23
+ }
19
24
  export declare enum AnnotationLevel {
20
25
  Failure = "failure",
21
26
  Warning = "warning",
@@ -16,6 +16,11 @@ export interface Annotation {
16
16
  start_column?: number;
17
17
  end_column?: number;
18
18
  }
19
+ export declare enum AnnotationFilterLevel {
20
+ All = "all",
21
+ Dangerous = "dangerous",
22
+ Breaking = "breaking"
23
+ }
19
24
  export declare enum AnnotationLevel {
20
25
  Failure = "failure",
21
26
  Warning = "warning",
@@ -1,9 +1,11 @@
1
1
  import * as core from '@actions/core';
2
2
  import { Rule } from '@graphql-inspector/core';
3
+ import { AnnotationFilterLevel } from '../helpers/types.cjs';
3
4
  export declare function batch<T>(items: T[], limit: number): T[][];
4
5
  /**
5
6
  * Treats non-falsy value as true
6
7
  */
7
8
  export declare function castToBoolean(value: string | boolean, defaultValue?: boolean): boolean;
9
+ export declare function isAnnotationFilterLevel(value: string): value is AnnotationFilterLevel;
8
10
  export declare function getInputAsArray(name: string, options?: core.InputOptions): string[];
9
11
  export declare function resolveRule(name: string): Rule | undefined;
@@ -1,9 +1,11 @@
1
1
  import * as core from '@actions/core';
2
2
  import { Rule } from '@graphql-inspector/core';
3
+ import { AnnotationFilterLevel } from '../helpers/types.js';
3
4
  export declare function batch<T>(items: T[], limit: number): T[][];
4
5
  /**
5
6
  * Treats non-falsy value as true
6
7
  */
7
8
  export declare function castToBoolean(value: string | boolean, defaultValue?: boolean): boolean;
9
+ export declare function isAnnotationFilterLevel(value: string): value is AnnotationFilterLevel;
8
10
  export declare function getInputAsArray(name: string, options?: core.InputOptions): string[];
9
11
  export declare function resolveRule(name: string): Rule | undefined;
@@ -1,9 +1,11 @@
1
1
  import * as core from '@actions/core';
2
2
  import { Rule } from '@graphql-inspector/core';
3
+ import { AnnotationFilterLevel } from '../helpers/types.cjs';
3
4
  export declare function batch<T>(items: T[], limit: number): T[][];
4
5
  /**
5
6
  * Treats non-falsy value as true
6
7
  */
7
8
  export declare function castToBoolean(value: string | boolean, defaultValue?: boolean): boolean;
9
+ export declare function isAnnotationFilterLevel(value: string): value is AnnotationFilterLevel;
8
10
  export declare function getInputAsArray(name: string, options?: core.InputOptions): string[];
9
11
  export declare function resolveRule(name: string): Rule | undefined;
@@ -1,9 +1,11 @@
1
1
  import * as core from '@actions/core';
2
2
  import { Rule } from '@graphql-inspector/core';
3
+ import { AnnotationFilterLevel } from '../helpers/types.js';
3
4
  export declare function batch<T>(items: T[], limit: number): T[][];
4
5
  /**
5
6
  * Treats non-falsy value as true
6
7
  */
7
8
  export declare function castToBoolean(value: string | boolean, defaultValue?: boolean): boolean;
9
+ export declare function isAnnotationFilterLevel(value: string): value is AnnotationFilterLevel;
8
10
  export declare function getInputAsArray(name: string, options?: core.InputOptions): string[];
9
11
  export declare function resolveRule(name: string): Rule | undefined;