소스 검색

.github/workflows: Add `go generate` testing to CI (#26)

The `go test` command cannot detect any issues when running `go generate`. This ensures that any `go generate` commands can successfully execute, while also ensuring there are no dangling Git differences afterwards to prevent cases where the documentation is not symmetrically updated.
Brian Flad 3 년 전
부모
커밋
2f9e03568a
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13 0
      .github/workflows/test.yml

+ 13 - 0
.github/workflows/test.yml

@@ -35,6 +35,19 @@ jobs:
       - run: go mod download
       - run: go build -v .
 
+  generate:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/setup-go@v3
+        with:
+          go-version: ${{ env.GO_VERSION }}
+      - uses: actions/checkout@v3
+      - run: go generate ./...
+      - name: git diff
+        run: |
+          git diff --compact-summary --exit-code || \
+            (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
+
   # Run acceptance tests in a matrix with Terraform CLI versions
   test:
     name: Terraform Provider Acceptance Tests