@node-core/utils 7.0.3 → 7.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.
- package/components/git/metadata.js +2 -2
- package/lib/pr_checker.js +5 -11
- package/lib/queries/PR.gql +5 -4
- package/lib/request.js +3 -2
- package/lib/run.js +9 -2
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { parsePRFromURL } from '../../lib/links.js';
|
|
|
2
2
|
import { getMetadata } from '../metadata.js';
|
|
3
3
|
import CLI from '../../lib/cli.js';
|
|
4
4
|
import { getMergedConfig } from '../../lib/config.js';
|
|
5
|
-
import { runPromise, IGNORE } from '../../lib/run.js';
|
|
5
|
+
import { runPromise, reportError, IGNORE } from '../../lib/run.js';
|
|
6
6
|
|
|
7
7
|
export const command = 'metadata <identifier>';
|
|
8
8
|
export const describe =
|
|
@@ -67,7 +67,7 @@ export async function writeMetadataJsonResult(metadataPromise) {
|
|
|
67
67
|
await writeStdout(`${JSON.stringify(json, null, 2)}\n`);
|
|
68
68
|
process.exitCode = json.exitCode;
|
|
69
69
|
} catch (error) {
|
|
70
|
-
|
|
70
|
+
reportError(error);
|
|
71
71
|
process.exitCode = 1;
|
|
72
72
|
}
|
|
73
73
|
}
|
package/lib/pr_checker.js
CHANGED
|
@@ -24,6 +24,7 @@ const WAIT_TIME_MULTI_APPROVAL = 24 * 2;
|
|
|
24
24
|
const WAIT_TIME_SINGLE_APPROVAL = 24 * 7;
|
|
25
25
|
|
|
26
26
|
const GITHUB_SUCCESS_CONCLUSIONS = ['SUCCESS', 'NEUTRAL', 'SKIPPED'];
|
|
27
|
+
const GITHUB_ACTIONS_APP = 'github-actions';
|
|
27
28
|
|
|
28
29
|
const FAST_TRACK_RE = /^Fast-track has been requested by @(.+?)\. Please 👍 to approve\.$/;
|
|
29
30
|
const FAST_TRACK_MIN_APPROVALS = 2;
|
|
@@ -459,16 +460,9 @@ export default class PRChecker {
|
|
|
459
460
|
const pendingJobs = [];
|
|
460
461
|
|
|
461
462
|
// GitHub new Check API
|
|
462
|
-
for (const { status, conclusion,
|
|
463
|
-
if (app.slug !== 'github-actions') {
|
|
464
|
-
// Ignore all non-github check suites, such as Dependabot and Codecov.
|
|
465
|
-
// They are expected to show up on PRs whose head branch is not on a
|
|
466
|
-
// fork and never complete.
|
|
467
|
-
continue;
|
|
468
|
-
}
|
|
469
|
-
|
|
463
|
+
for (const { status, conclusion, checkRuns } of checkSuites.nodes) {
|
|
470
464
|
if (status !== 'COMPLETED') {
|
|
471
|
-
pendingJobs.push({
|
|
465
|
+
pendingJobs.push({ status, conclusion });
|
|
472
466
|
continue;
|
|
473
467
|
}
|
|
474
468
|
|
|
@@ -499,13 +493,13 @@ export default class PRChecker {
|
|
|
499
493
|
// Fallback to check suite level information if no checkRuns
|
|
500
494
|
if (conclusion === 'CANCELLED') {
|
|
501
495
|
cancelledJobs.push({
|
|
502
|
-
name:
|
|
496
|
+
name: GITHUB_ACTIONS_APP,
|
|
503
497
|
conclusion,
|
|
504
498
|
url: null
|
|
505
499
|
});
|
|
506
500
|
} else {
|
|
507
501
|
failedJobs.push({
|
|
508
|
-
name:
|
|
502
|
+
name: GITHUB_ACTIONS_APP,
|
|
509
503
|
conclusion,
|
|
510
504
|
url: null
|
|
511
505
|
});
|
package/lib/queries/PR.gql
CHANGED
|
@@ -29,11 +29,12 @@ query PR($prid: Int!, $owner: String!, $repo: String!) {
|
|
|
29
29
|
nodes {
|
|
30
30
|
commit {
|
|
31
31
|
oid
|
|
32
|
-
|
|
32
|
+
# 15368 is the GitHub Actions App ID on GitHub.com. Filtering avoids
|
|
33
|
+
# querying App metadata that GITHUB_TOKEN cannot read for suites
|
|
34
|
+
# created by third-party Apps such as Jenkins and Codecov.
|
|
35
|
+
# https://api.github.com/apps/github-actions
|
|
36
|
+
checkSuites(first: 100, filterBy: { appId: 15368 }) {
|
|
33
37
|
nodes {
|
|
34
|
-
app {
|
|
35
|
-
slug
|
|
36
|
-
}
|
|
37
38
|
conclusion,
|
|
38
39
|
status,
|
|
39
40
|
checkRuns(first: 40) {
|
package/lib/request.js
CHANGED
|
@@ -335,11 +335,12 @@ export default class Request {
|
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
const result = await this.json(url, options);
|
|
338
|
-
if (result.errors) {
|
|
338
|
+
if (result.errors?.length > 0) {
|
|
339
339
|
const { type, message } = result.errors[0];
|
|
340
340
|
const err = new Error(`[${type}] GraphQL request Error: ${message}`);
|
|
341
341
|
err.data = {
|
|
342
|
-
variables
|
|
342
|
+
variables,
|
|
343
|
+
errors: result.errors
|
|
343
344
|
};
|
|
344
345
|
throw err;
|
|
345
346
|
}
|
package/lib/run.js
CHANGED
|
@@ -8,6 +8,13 @@ import {
|
|
|
8
8
|
|
|
9
9
|
export const IGNORE = '__ignore__';
|
|
10
10
|
|
|
11
|
+
export function reportError(error, write = console.error) {
|
|
12
|
+
write(error?.stack ?? error);
|
|
13
|
+
if (error?.data !== undefined) {
|
|
14
|
+
write(JSON.stringify(error.data, null, 2));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
function runAsyncBase(cmd, args, {
|
|
12
19
|
ignoreFailure = true,
|
|
13
20
|
spawnArgs,
|
|
@@ -72,7 +79,7 @@ export function forceRunAsync(cmd, args, options) {
|
|
|
72
79
|
return runAsyncBase(cmd, args, options).catch((error) => {
|
|
73
80
|
if (error.message !== IGNORE) {
|
|
74
81
|
if (!error.messageOnly) {
|
|
75
|
-
|
|
82
|
+
reportError(error);
|
|
76
83
|
}
|
|
77
84
|
throw error;
|
|
78
85
|
}
|
|
@@ -82,7 +89,7 @@ export function forceRunAsync(cmd, args, options) {
|
|
|
82
89
|
export function runPromise(promise) {
|
|
83
90
|
return promise.catch((error) => {
|
|
84
91
|
if (error.message !== IGNORE) {
|
|
85
|
-
|
|
92
|
+
reportError(error);
|
|
86
93
|
}
|
|
87
94
|
exit();
|
|
88
95
|
});
|