From fbb71cf63d34b90cc168d06213f6bcb6601cbfcd Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Thu, 2 Dec 2021 18:30:21 -0700 Subject: [PATCH] More debug logging (#20) --- CHANGELOG.md | 5 +++++ action.yml | 4 ++-- package.json | 2 +- src/format-message.ts | 2 +- src/get-message.ts | 18 +++++++++++------- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3835334..912a96bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Apollo Schema Check Action Changelog +## 1.2.2 (December 2, 2021) + +- Add additional debug logging +- Use the `apolloVersion` argument that was previously added but not used in the code + ## 1.2.1 (December 2, 2021) - Improve output for debugging diff --git a/action.yml b/action.yml index 0909be41..132dcb88 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: description: The variant to check the proposed schema against required: false endpoint: - description: The URL for the CLI use to introspect your service + description: The URL for the CLI to use to introspect your service required: false header: description: 'Additional header to send to server for introspectionQuery. Multiple headers can be provided as a comma separated list. NOTE: The `--endpoint` flag is REQUIRED if using the `--header` flag.' @@ -49,7 +49,7 @@ inputs: required: false apolloVersion: description: The version of the Apollo CLI to use - default: '2.33.6' + default: '2.33.9' required: false runs: diff --git a/package.json b/package.json index 5f779bbc..734f3693 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "apollo-schema-check-action", "description": "A GitHub Action to run a schema check and post the results as a comment on a Pull Request", - "version": "1.2.1", + "version": "1.2.2", "author": "Ian Sutherland ", "license": "MIT", "repository": { diff --git a/src/format-message.ts b/src/format-message.ts index 1110e925..eaf35fad 100644 --- a/src/format-message.ts +++ b/src/format-message.ts @@ -9,7 +9,7 @@ const formatMessage = (output: string, existingComment: boolean): string | undef const failOnError = getInput('failOnError'); if (startOfMessage === -1) { - throw new Error('Error running Apollo CLI'); + throw new Error('Received unexpected output from Apollo CLI'); } if (alwaysComment !== 'true' && output.includes('null operations')) { diff --git a/src/get-message.ts b/src/get-message.ts index 0fd982c3..eadde03a 100644 --- a/src/get-message.ts +++ b/src/get-message.ts @@ -1,4 +1,5 @@ import execa from 'execa'; +import { getInput } from '@actions/core'; import { debug, info, error as logError } from './actions'; import { getArguments } from './get-arguments'; @@ -9,6 +10,7 @@ const getMessage = async ( existingComment: boolean ): Promise => { const args = getArguments(); + const apolloCliVersion = getInput('apolloVersion'); if (existingComment) { debug('existing comment found'); @@ -18,12 +20,16 @@ const getMessage = async ( arg.startsWith('--key') ? arg.replace(/:[^:]+$/, '***') : arg ); - info('Apollo CLI command', ['npx', 'apollo@2.33.6', 'schema:check', ...redactedArgs].join(' ')); + info( + 'Apollo CLI command', + ['npx', `apollo@${apolloCliVersion}`, 'schema:check', ...redactedArgs].join(' ') + ); try { - const output = (await execa('npx', ['apollo@2.33.6', 'schema:check', ...args])).stdout; + const output = (await execa('npx', [`apollo@${apolloCliVersion}`, 'schema:check', ...args])) + .stdout; - info(output); + info('Apollo CLI output', output); const message = formatMessage(output, existingComment); @@ -33,13 +39,11 @@ const getMessage = async ( return; } } catch (error) { - if (error.exitCode !== 1) { - logError(`Apollo CLI error: exit code ${error.exitCode}`, error); + logError(`Apollo CLI error: exit code ${error.exitCode}`, error); + if (error.exitCode !== 1) { throw new Error('Error running Apollo CLI'); } else { - info(error.stdout); - const message = formatMessage(error.stdout, existingComment); if (message) {