UNPKG

@graphql-inspector/cli

Version:

Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.

65 lines (64 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.start = start; exports.annotate = annotate; exports.complete = complete; const types_js_1 = require("./types.js"); const utils_js_1 = require("./utils.js"); async function start({ context, owner, repo, sha, logger, }) { try { const result = await context.octokit.checks.create({ owner, repo, name: 'graphql-inspector', head_sha: sha, status: types_js_1.CheckStatus.InProgress, }); logger.info(`check started`); return result.data.id; } catch (error) { logger.error(`failed to start a check`, error); throw error; } } async function annotate({ context, owner, repo, checkRunId, annotations, title, summary, logger, }) { const batches = (0, utils_js_1.batch)(annotations, 50); context.log.info(`annotations to be sent: ${annotations.length}`); context.log.info(`title: ${title}`); try { await Promise.all(batches.map(async (chunk) => { await context.octokit.checks.update({ owner, repo, check_run_id: checkRunId, output: { annotations: chunk, title, summary, }, }); logger.info(`annotations sent (${chunk.length})`); })); } catch (error) { logger.error(`failed to send annotations`, error); throw error; } } async function complete({ context, owner, repo, checkRunId, conclusion, logger, }) { try { await context.octokit.checks.update({ owner, repo, check_run_id: checkRunId, conclusion, status: types_js_1.CheckStatus.Completed, }); logger.info(`check completed`); } catch (error) { logger.error(`failed to complete a check`, error); throw error; } }