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..6abcae0 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