From 41b10d12f4cbc0339cf80762033deffd4636e272 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 5 Oct 2023 11:12:37 +0900 Subject: [PATCH 1/5] action check diffs --- .github/workflows/check-diff.yml | 26 ++++++++++++++++++++++++++ Makefile | 12 ++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/check-diff.yml diff --git a/.github/workflows/check-diff.yml b/.github/workflows/check-diff.yml new file mode 100644 index 0000000..ad055f1 --- /dev/null +++ b/.github/workflows/check-diff.yml @@ -0,0 +1,26 @@ +name: Check GraphQL Diff + +on: + pull_request: + +jobs: + check-diff: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + go-version: + - 1.20.6 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Go ${{ matrix.go-version}} + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version}} + + - name: Run make check-diff + run: | + make check-diff diff --git a/Makefile b/Makefile index 2b35530..e4467e0 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ SHELL = /bin/bash -.PHONY: all build test +.PHONY: all build test check-diff -all: build test +all: build test check-diff build: go build @@ -14,3 +14,11 @@ test: build echo "Merging $$dir into $$output..."; \ ./gqlmerge $$dir $$output; \ done + +check-diff: build test + @if git diff --exit-code --quiet -- '*.graphql'; then \ + echo "Ok"; \ + else \ + echo "Error: Differences found in generated.graphql files"; \ + exit -1; \ + fi \ No newline at end of file From 2170a8f3727579087dea2106e0c801181565860b Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 5 Oct 2023 11:15:14 +0900 Subject: [PATCH 2/5] make diff --- lib/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parse.go b/lib/parse.go index 7731913..3cda187 100644 --- a/lib/parse.go +++ b/lib/parse.go @@ -40,7 +40,7 @@ func (p *Parser) parseArgs() []*Arg { p.lex.consumeToken(tokLParen) for p.lex.peek() != ')' { arg := Arg{} - name, comments := p.lex.consumeIdent(tokInput, tokType) + name, comments := p.lex.consumeIdent(tokType) arg.Name = name.String() arg.Descriptions = comments p.lex.consumeToken(tokColon) From d9fe326075eb13f06c2754606bf9ac3ce362c927 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 5 Oct 2023 11:17:36 +0900 Subject: [PATCH 3/5] make diff --- lib/parse.go | 2 +- lib/write.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/parse.go b/lib/parse.go index 3cda187..7731913 100644 --- a/lib/parse.go +++ b/lib/parse.go @@ -40,7 +40,7 @@ func (p *Parser) parseArgs() []*Arg { p.lex.consumeToken(tokLParen) for p.lex.peek() != ')' { arg := Arg{} - name, comments := p.lex.consumeIdent(tokType) + name, comments := p.lex.consumeIdent(tokInput, tokType) arg.Name = name.String() arg.Descriptions = comments p.lex.consumeToken(tokColon) diff --git a/lib/write.go b/lib/write.go index 27c3ab5..8d9b168 100644 --- a/lib/write.go +++ b/lib/write.go @@ -11,7 +11,7 @@ type MergedSchema struct { func (ms *MergedSchema) WriteSchema(s *Schema) string { ms.writeDescriptions(s.SchemaDefinitions[0].Descriptions, 0, true) - ms.buf.WriteString("schema {\n") + ms.buf.WriteString("schema! {\n") ms.addIndent(1) if s.SchemaDefinitions[0].Query != nil { ms.buf.WriteString("query: " + *s.SchemaDefinitions[0].Query + "\n") From 13f2a58eecff98671d656ed4475e501bb72dcf65 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 5 Oct 2023 11:19:21 +0900 Subject: [PATCH 4/5] revert --- lib/write.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/write.go b/lib/write.go index 8d9b168..27c3ab5 100644 --- a/lib/write.go +++ b/lib/write.go @@ -11,7 +11,7 @@ type MergedSchema struct { func (ms *MergedSchema) WriteSchema(s *Schema) string { ms.writeDescriptions(s.SchemaDefinitions[0].Descriptions, 0, true) - ms.buf.WriteString("schema! {\n") + ms.buf.WriteString("schema {\n") ms.addIndent(1) if s.SchemaDefinitions[0].Query != nil { ms.buf.WriteString("query: " + *s.SchemaDefinitions[0].Query + "\n") From 320b4f1dcbad0494513a026f2f2f3d556cbe4ec5 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 5 Oct 2023 11:20:01 +0900 Subject: [PATCH 5/5] eof --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e4467e0..6abcae0 100644 --- a/Makefile +++ b/Makefile @@ -21,4 +21,4 @@ check-diff: build test else \ echo "Error: Differences found in generated.graphql files"; \ exit -1; \ - fi \ No newline at end of file + fi