Skip to content

Commit

Permalink
Add additional debugging to troubleshoot actions issues (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
iansu committed Dec 2, 2021
1 parent 263ad91 commit ae8d809
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 11 deletions.
47 changes: 47 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release

on:
workflow_dispatch:
inputs:
tag:
description: 'The version tag of the release. This should match version in package.json and start with `v`. For example: `v1.0.0`'
required: true
branch:
description: 'The major version branch to commit to. Default v1.'
default: v1
required: true

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
cache: yarn
- name: Install
run: yarn --prefer-offline --frozen-lockfile --no-progress --non-interactive
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Test
run: yarn test
- name: Commit
uses: endbug/add-and-commit@45a4ede867982d5d85997a82529b1d9dd0328e7f
with:
add: 'build --force'
branch: ${{ github.event.inputs.branch }}
message: 'Add build output'
pull: 'NO-PULL'
push: 'origin ${{ github.event.inputs.branch }} --force'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag
uses: ncipollo/release-action@v1
with:
body: 'TODO: Add CHANGELOG entry'
tag: ${{ github.event.inputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Apollo Schema Check Action Changelog

## 1.2.1 (December 2, 2021)

- Improve output for debugging

## 1.2.0 (August 18, 2021)

- Add branch and author information when pushing to Apollo Studio
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.0",
"version": "1.2.1",
"author": "Ian Sutherland <ian@iansutherland.ca>",
"license": "MIT",
"repository": {
Expand Down
24 changes: 22 additions & 2 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { inspect } from 'util';
import createDebug from 'debug';
import { debug as githubDebug } from '@actions/core';
import { debug as githubDebug, info as githubInfo, error as githubError } from '@actions/core';

const localDebug = createDebug('apollo-schema-check');

Expand All @@ -18,4 +18,24 @@ const debug = (...args: any[]): void => {
}
};

export { isGitHubActions, debug };
const info = (...args: any[]): void => {
if (isGitHubActions()) {
for (const arg of args) {
githubInfo(inspect(arg));
}
} else {
console.log(args);
}
};

const error = (...args: any[]): void => {
if (isGitHubActions()) {
for (const arg of args) {
githubError(inspect(arg));
}
} else {
console.error(args);
}
};

export { isGitHubActions, debug, info, error };
13 changes: 5 additions & 8 deletions src/get-message.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import execa from 'execa';

import { debug } from './actions';
import { debug, info, error as logError } from './actions';
import { getArguments } from './get-arguments';
import { formatMessage } from './format-message';

Expand All @@ -18,15 +18,12 @@ const getMessage = async (
arg.startsWith('--key') ? arg.replace(/:[^:]+$/, '***') : arg
);

console.log(
'Apollo CLI command',
['npx', 'apollo@2.33.6', 'schema:check', ...redactedArgs].join(' ')
);
info('Apollo CLI command', ['npx', 'apollo@2.33.6', 'schema:check', ...redactedArgs].join(' '));

try {
const output = (await execa('npx', ['apollo@2.33.6', 'schema:check', ...args])).stdout;

console.log(output);
info(output);

const message = formatMessage(output, existingComment);

Expand All @@ -37,11 +34,11 @@ const getMessage = async (
}
} catch (error) {
if (error.exitCode !== 1) {
console.error(`Apollo CLI error: exit code ${error.exitCode}`, error);
logError(`Apollo CLI error: exit code ${error.exitCode}`, error);

throw new Error('Error running Apollo CLI');
} else {
console.log(error.stdout);
info(error.stdout);

const message = formatMessage(error.stdout, existingComment);

Expand Down

0 comments on commit ae8d809

Please sign in to comment.