@graphql-inspector/action 3.4.0 → 3.4.1-alpha-20230111100013-a6d87d52
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/index.js +19 -19
- package/index.mjs +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('@actions/core');
|
|
4
4
|
const tslib = require('tslib');
|
|
5
|
-
const
|
|
5
|
+
const child_process = require('child_process');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
8
|
-
const
|
|
9
|
-
const github$1 = require('@
|
|
8
|
+
const github = require('@actions/github');
|
|
9
|
+
const github$1 = require('@graphql-inspector/github');
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Return true if `value` is object-like. A value is object-like if it's not
|
|
@@ -12439,7 +12439,7 @@ function getCurrentCommitSha() {
|
|
|
12439
12439
|
}
|
|
12440
12440
|
function getAssociatedPullRequest(octokit, commitSha) {
|
|
12441
12441
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
12442
|
-
const result = yield octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls', Object.assign(Object.assign({}, github
|
|
12442
|
+
const result = yield octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls', Object.assign(Object.assign({}, github.context.repo), { commit_sha: commitSha }));
|
|
12443
12443
|
return result.data.length > 0 ? result.data[0] : null;
|
|
12444
12444
|
});
|
|
12445
12445
|
}
|
|
@@ -12463,9 +12463,9 @@ function run() {
|
|
|
12463
12463
|
const failOnBreaking = castToBoolean(core.getInput('fail-on-breaking'));
|
|
12464
12464
|
const endpoint = core.getInput('endpoint');
|
|
12465
12465
|
const approveLabel = core.getInput('approve-label') || 'approved-breaking-change';
|
|
12466
|
-
const octokit = github
|
|
12466
|
+
const octokit = github.getOctokit(token);
|
|
12467
12467
|
// repo
|
|
12468
|
-
const { owner, repo } = github
|
|
12468
|
+
const { owner, repo } = github.context.repo;
|
|
12469
12469
|
// pull request
|
|
12470
12470
|
const pullRequest = yield getAssociatedPullRequest(octokit, commitSha);
|
|
12471
12471
|
core.info(`Creating a check named "${checkName}"`);
|
|
@@ -12505,13 +12505,13 @@ function run() {
|
|
|
12505
12505
|
const isNewSchemaUrl = endpoint && schemaPath.startsWith('http');
|
|
12506
12506
|
const [oldFile, newFile] = yield Promise.all([
|
|
12507
12507
|
endpoint
|
|
12508
|
-
? github.printSchemaFromEndpoint(endpoint)
|
|
12508
|
+
? github$1.printSchemaFromEndpoint(endpoint)
|
|
12509
12509
|
: loadFile({
|
|
12510
12510
|
ref: schemaRef,
|
|
12511
12511
|
path: schemaPath,
|
|
12512
12512
|
}),
|
|
12513
12513
|
isNewSchemaUrl
|
|
12514
|
-
? github.printSchemaFromEndpoint(schemaPath)
|
|
12514
|
+
? github$1.printSchemaFromEndpoint(schemaPath)
|
|
12515
12515
|
: loadFile({
|
|
12516
12516
|
path: schemaPath,
|
|
12517
12517
|
ref,
|
|
@@ -12535,8 +12535,8 @@ function run() {
|
|
|
12535
12535
|
old: new Source(oldFile, endpoint || `${schemaRef}:${schemaPath}`),
|
|
12536
12536
|
new: new Source(newFile, schemaPath),
|
|
12537
12537
|
};
|
|
12538
|
-
oldSchema = github.produceSchema(sources.old);
|
|
12539
|
-
newSchema = github.produceSchema(sources.new);
|
|
12538
|
+
oldSchema = github$1.produceSchema(sources.old);
|
|
12539
|
+
newSchema = github$1.produceSchema(sources.new);
|
|
12540
12540
|
}
|
|
12541
12541
|
const schemas = {
|
|
12542
12542
|
old: oldSchema,
|
|
@@ -12544,7 +12544,7 @@ function run() {
|
|
|
12544
12544
|
};
|
|
12545
12545
|
core.info(`Built both schemas`);
|
|
12546
12546
|
core.info(`Start comparing schemas`);
|
|
12547
|
-
const action = yield github.diff({
|
|
12547
|
+
const action = yield github$1.diff({
|
|
12548
12548
|
path: schemaPath,
|
|
12549
12549
|
schemas,
|
|
12550
12550
|
sources,
|
|
@@ -12557,16 +12557,16 @@ function run() {
|
|
|
12557
12557
|
const hasApprovedBreakingChangeLabel = (_b = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.labels) === null || _b === void 0 ? void 0 : _b.some((label) => label.name === approveLabel);
|
|
12558
12558
|
// Force Success when failOnBreaking is disabled
|
|
12559
12559
|
if ((failOnBreaking === false || hasApprovedBreakingChangeLabel) &&
|
|
12560
|
-
conclusion === github.CheckConclusion.Failure) {
|
|
12560
|
+
conclusion === github$1.CheckConclusion.Failure) {
|
|
12561
12561
|
core.info('FailOnBreaking disabled. Forcing SUCCESS');
|
|
12562
|
-
conclusion = github.CheckConclusion.Success;
|
|
12562
|
+
conclusion = github$1.CheckConclusion.Success;
|
|
12563
12563
|
}
|
|
12564
12564
|
if (useAnnotations === false || isNewSchemaUrl) {
|
|
12565
12565
|
core.info(`Anotations are disabled. Skipping annotations...`);
|
|
12566
12566
|
annotations = [];
|
|
12567
12567
|
}
|
|
12568
|
-
const summary = github.createSummary(changes, 100, false);
|
|
12569
|
-
const title = conclusion === github.CheckConclusion.Failure
|
|
12568
|
+
const summary = github$1.createSummary(changes, 100, false);
|
|
12569
|
+
const title = conclusion === github$1.CheckConclusion.Failure
|
|
12570
12570
|
? 'Something is wrong with your schema'
|
|
12571
12571
|
: 'Everything looks good';
|
|
12572
12572
|
core.info(`Conclusion: ${conclusion}`);
|
|
@@ -12581,7 +12581,7 @@ function run() {
|
|
|
12581
12581
|
core.error(e.message || e);
|
|
12582
12582
|
const title = 'Invalid config. Failed to add annotation';
|
|
12583
12583
|
yield updateCheckRun(octokit, checkId, {
|
|
12584
|
-
conclusion: github.CheckConclusion.Failure,
|
|
12584
|
+
conclusion: github$1.CheckConclusion.Failure,
|
|
12585
12585
|
output: { title, summary: title, annotations: [] },
|
|
12586
12586
|
});
|
|
12587
12587
|
return core.setFailed(title);
|
|
@@ -12651,13 +12651,13 @@ function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
|
12651
12651
|
const { title, summary, annotations = [] } = output;
|
|
12652
12652
|
const batches = batch(annotations, 50);
|
|
12653
12653
|
core.info(`annotations to be sent: ${annotations.length}`);
|
|
12654
|
-
yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId, completed_at: new Date().toISOString(), status: 'completed' }, github
|
|
12654
|
+
yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId, completed_at: new Date().toISOString(), status: 'completed' }, github.context.repo), { conclusion, output: {
|
|
12655
12655
|
title,
|
|
12656
12656
|
summary,
|
|
12657
12657
|
} }));
|
|
12658
12658
|
try {
|
|
12659
12659
|
yield Promise.all(batches.map((chunk) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
12660
|
-
yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId }, github
|
|
12660
|
+
yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId }, github.context.repo), { output: {
|
|
12661
12661
|
title,
|
|
12662
12662
|
summary,
|
|
12663
12663
|
annotations: chunk,
|
|
@@ -12670,7 +12670,7 @@ function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
|
12670
12670
|
throw error;
|
|
12671
12671
|
}
|
|
12672
12672
|
// Fail
|
|
12673
|
-
if (conclusion === github.CheckConclusion.Failure) {
|
|
12673
|
+
if (conclusion === github$1.CheckConclusion.Failure) {
|
|
12674
12674
|
return core.setFailed(output.title);
|
|
12675
12675
|
}
|
|
12676
12676
|
// Success or Neutral
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { info, getInput, setFailed, error, setOutput } from '@actions/core';
|
|
2
2
|
import { __awaiter } from 'tslib';
|
|
3
|
-
import {
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
import { resolve, extname } from 'path';
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
6
|
import { getOctokit, context } from '@actions/github';
|
|
7
|
+
import { printSchemaFromEndpoint, produceSchema, diff, CheckConclusion, createSummary } from '@graphql-inspector/github';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Return true if `value` is object-like. A value is object-like if it's not
|