-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Updater/feat/add-github-action
Add the initial files and logic
- Loading branch information
Showing
8 changed files
with
4,626 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"rules": [ | ||
"descriptions-are-capitalized", | ||
"enum-values-all-caps", | ||
"fields-are-camel-cased", | ||
"fields-have-descriptions", | ||
"types-have-descriptions", | ||
"defined-types-are-used", | ||
"deprecations-have-a-reason", | ||
"input-object-fields-sorted-alphabetically", | ||
"interface-fields-sorted-alphabetically", | ||
"type-fields-sorted-alphabetically", | ||
"types-are-capitalized", | ||
"enum-values-sorted-alphabetically" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# action-graphql-linter | ||
Custom GitHub Action for linting GraphQL | ||
# GraphQL Linter Action | ||
|
||
This action lints the GraphQL Schemas sent in the input. | ||
|
||
## Inputs | ||
|
||
## `graphql-schemas` | ||
|
||
**Required** GraphQL Schemas to lint. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: actions/[email protected] | ||
with: | ||
graphql-schemas: 'app/graphql.schema' | ||
``` | ||
```yaml | ||
uses: actions/[email protected] | ||
with: | ||
graphql-schemas: 'graphql1.schema,graphql2.schema' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: 'GraphQL Linter' | ||
description: 'Lints the given GraphQL schemas' | ||
inputs: | ||
files: | ||
description: 'Files to lint' | ||
required: true | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const { runner } = require('graphql-schema-linter'); | ||
|
||
function lintSchemas(schemas) { | ||
const args = [null, __dirname, ...schemas]; | ||
console.log("Linting schemas: ", schemas.join()) | ||
return runner.run(process.stdout, process.stdin, process.stderr, args) | ||
} | ||
async function main() { | ||
const payload = JSON.stringify(github.context.payload, undefined, 2) | ||
console.log(`The event payload: ${payload}`); | ||
try { | ||
const schemaFiles = core.getInput('files').split(','); | ||
const combined = core.getInput('combined'); | ||
|
||
if (combined) { | ||
const exitCode = await lintSchemas(schemaFiles); | ||
if (exitCode !== 0) { | ||
throw new Error(`Invalid Schemas ${schemas}`); | ||
} | ||
} else { | ||
for (const schema of schemaFiles) { | ||
const exitCode = await lintSchemas([schema]); | ||
if (exitCode !== 0) { | ||
throw new Error(`Invalid Schema ${schema}`); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "playground", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@actions/core": "^1.9.0", | ||
"@actions/github": "^5.0.3", | ||
"graphql": "^16.5.0", | ||
"graphql-schema-linter": "^3.0.1" | ||
} | ||
} |
Oops, something went wrong.