Skip to content

Commit

Permalink
More debug logging (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
iansu committed Dec 3, 2021
1 parent ad70e09 commit fbb71cf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <ian@iansutherland.ca>",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/format-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
18 changes: 11 additions & 7 deletions src/get-message.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,6 +10,7 @@ const getMessage = async (
existingComment: boolean
): Promise<string | undefined> => {
const args = getArguments();
const apolloCliVersion = getInput('apolloVersion');

if (existingComment) {
debug('existing comment found');
Expand All @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit fbb71cf

Please sign in to comment.