Skip to content

Commit

Permalink
Github Actions and v0.7.0 (#39)
Browse files Browse the repository at this point in the history
* Github Actions
* Release v0.7.0
  • Loading branch information
kamilkisiela authored Jan 4, 2019
1 parent 1d349c5 commit 8ca41e5
Show file tree
Hide file tree
Showing 20 changed files with 193 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ignore all files by default
*
# include required files with an exception
!entrypoint.sh
25 changes: 17 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
FROM node:10
FROM node:10-slim

ENV PATH=$PATH:/app/node_modules/.bin
WORKDIR /app
COPY . .
RUN yarn
RUN yarn build
LABEL version="1.0.1"
LABEL repository="http://github.com/kamilkisiela/graphql-inspector"
LABEL homepage="http://github.com/kamilkisiela/graphql-inspector"
LABEL maintainer="Kamil Kisiela <[email protected]>"

ENTRYPOINT ["probot", "receive"]
CMD ["/app/index.js"]
LABEL com.github.actions.name="GitHub Action for GraphQL Inspector"
LABEL com.github.actions.description="Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types."
LABEL com.github.actions.icon="notify"
LABEL com.github.actions.color="red"

ENV LOG_LEVEL 'debug'

RUN yarn global add @graphql-inspector/[email protected]

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

set -e
sh -c "graphql-inspector-github"
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.6.5"
"version": "0.7.0"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"packages/api",
"packages/ui",
"packages/load",
"packages/github"
"packages/github",
"packages/github-actions"
]
},
"lint-staged": {
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/api",
"version": "0.6.5",
"version": "0.7.0",
"description": "GraphQL Inspector API",
"keywords": [
"graphql",
Expand Down Expand Up @@ -28,8 +28,8 @@
"prepublishOnly": "yarn build"
},
"dependencies": {
"@graphql-inspector/core": "0.6.5",
"@graphql-inspector/load": "0.6.5",
"@graphql-inspector/core": "0.7.0",
"@graphql-inspector/load": "0.7.0",
"@graphql-modules/epoxy": "0.2.17",
"apollo-server-express": "2.2.6",
"graphql": "14.0.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/cli",
"version": "0.6.5",
"version": "0.7.0",
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
"keywords": [
"graphql",
Expand Down Expand Up @@ -45,10 +45,10 @@
"typescript": "3.2.2"
},
"dependencies": {
"@graphql-inspector/api": "0.6.5",
"@graphql-inspector/core": "0.6.5",
"@graphql-inspector/load": "0.6.5",
"@graphql-inspector/ui": "0.6.5",
"@graphql-inspector/api": "0.7.0",
"@graphql-inspector/core": "0.7.0",
"@graphql-inspector/load": "0.7.0",
"@graphql-inspector/ui": "0.7.0",
"apollo-server": "2.2.6",
"apollo-server-express": "2.2.6",
"chalk": "2.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/core",
"version": "0.6.5",
"version": "0.7.0",
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
"keywords": [
"graphql",
Expand Down
2 changes: 2 additions & 0 deletions packages/github-actions/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/
tsconfig.json
1 change: 1 addition & 0 deletions packages/github-actions/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
21 changes: 21 additions & 0 deletions packages/github-actions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Kamil Kisiela

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions packages/github-actions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@graphql-inspector/actions",
"version": "0.7.0",
"description": "Github Actions for GraphQL",
"sideEffects": false,
"author": {
"name": "Kamil Kisiela",
"email": "[email protected]",
"url": "https://github.com/kamilkisiela"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "kamilkisiela/graphql-inspector"
},
"bin": {
"graphql-inspector-github": "./dist/index.js"
},
"keywords": [
"graphql",
"graphql-inspector",
"tools",
"probot",
"probot-plugin",
"github"
],
"scripts": {
"build": "tsc",
"clean": "rm -rf dist/",
"deploy": "now --docker",
"prebuild": "yarn clean",
"prepublishOnly": "yarn build"
},
"dependencies": {
"@graphql-inspector/github": "0.7.0",
"graphql": "14.0.2",
"probot": "7.4.0",
"uuid": "3.3.2"
},
"devDependencies": {
"@types/graphql": "14.0.4",
"@types/node": "10.12.18",
"@types/uuid": "3.4.4",
"typescript": "3.2.2"
}
}
55 changes: 55 additions & 0 deletions packages/github-actions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env node

import appFn, {handleAction} from '@graphql-inspector/github';
import * as uuid from 'uuid';
import {resolve} from 'path';
import {findPrivateKey} from 'probot/lib/private-key';
import {createProbot, Application, ApplicationFunction} from 'probot';

const event = process.env.GITHUB_EVENT_NAME;
const cert = findPrivateKey()!;
const payload = require(resolve(process.env.GITHUB_EVENT_PATH!));

const probot = createProbot({
id: parseInt(process.env.APP_ID!, 10),
cert: cert as string,
githubToken: process.env.GITHUB_TOKEN,
});

function wrapAppFn(fn: ApplicationFunction) {
return (app: Application) => {
fn(app);

app.on('pull_request', async context => {
if (!process.env.GITHUB_ACTION) {
return;
}
const ref = context.payload.pull_request.head.sha;
const action = 'gh-action';
const {owner, repo} = context.repo();

await handleAction({context, owner, repo, ref, action});
process.exit(0);
});

app.on('push', async context => {
if (!process.env.GITHUB_ACTION) {
return;
}

const ref = context.payload.head_commit.id;
const action = 'gh-action';
const {owner, repo} = context.repo();

await handleAction({context, owner, repo, ref, action});
process.exit(0);
});
};
}

probot.setup([wrapAppFn(appFn)]);

probot.receive({name: event, payload, id: uuid.v4()}).catch(() => {
// Process must exist non-zero to indicate that the action failed to run
process.exit(1);
});
22 changes: 22 additions & 0 deletions packages/github-actions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",

"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"skipLibCheck": true,

"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"types": [],
"lib": ["es2015", "esnext.asynciterable"]
},
"files": ["src/index.ts"]
}
4 changes: 2 additions & 2 deletions packages/github/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/github",
"version": "0.6.5",
"version": "0.7.0",
"description": "Probot for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
"keywords": [
"graphql",
Expand Down Expand Up @@ -36,7 +36,7 @@
"probot": "^7.4.0"
},
"dependencies": {
"@graphql-inspector/core": "0.6.5"
"@graphql-inspector/core": "0.7.0"
},
"devDependencies": {
"@types/express": "4.16.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/github/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import appFn from './probot';
import appFn, {handleAction} from './probot';

export default appFn;
export {handleAction};
5 changes: 3 additions & 2 deletions packages/github/src/probot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function handleProbot(app: probot.Application) {

await handleAction({context, owner, repo, ref, action});
});

app.on('check_suite', async context => {
const ref = context.payload.check_suite.head_sha;
const action = context.payload.action;
Expand All @@ -64,7 +65,7 @@ export default function handleProbot(app: probot.Application) {
});
}

async function handleAction({
export async function handleAction({
context,
owner,
repo,
Expand All @@ -77,7 +78,7 @@ async function handleAction({
ref: string;
action: string;
}) {
if (['requested', 'rerequested'].indexOf(action) === -1) {
if (['requested', 'rerequested', 'gh-action'].indexOf(action) === -1) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/load/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/load",
"version": "0.6.5",
"version": "0.7.0",
"description": "Load GraphQL Schema and Documents from any source",
"keywords": [
"graphql",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/ui",
"version": "0.6.5",
"version": "0.7.0",
"description": "GraphQL Inspector GUI",
"keywords": [
"graphql",
Expand Down

0 comments on commit 8ca41e5

Please sign in to comment.