1- # This GitHub action runs your tests for each commit push and/or PR. Optionally
2- # you can turn it on using a cron schedule for regular testing.
3- #
1+ # Terraform Provider testing workflow.
42name : Tests
3+
4+ # This GitHub action runs your tests for each pull request and push.
5+ # Optionally, you can turn it on using a schedule for regular testing.
56on :
67 pull_request :
78 paths-ignore :
89 - " README.md"
910 push :
1011 paths-ignore :
1112 - " README.md"
12- # For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.),
13- # we recommend testing at a regular interval not necessarily tied to code changes. This will
14- # ensure you are alerted to something breaking due to an API change, even if the code did not
15- # change.
16- # schedule:
17- # - cron: '0 13 * * *'
13+
14+ # Testing only needs permissions to read the repository contents.
15+ permissions :
16+ contents : read
17+
1818jobs :
19- # ensure the code builds...
19+ # Ensure project builds before running testing matrix
2020 build :
2121 name : Build
2222 runs-on : ubuntu-latest
2323 timeout-minutes : 5
2424 steps :
25- - name : Check out code into the Go module directory
26- uses : actions/checkout@v3
27-
28- - name : Set up Go
29- uses : actions/setup-go@v3
25+ - uses : actions/checkout@v3
26+ - uses : actions/setup-go@v3
3027 with :
31- go-version-file : go.mod
32- id : go
33-
34- - name : Get dependencies
35- run : |
36- go mod download
28+ go-version-file : " go.mod"
29+ cache : true
30+ - run : go mod download
31+ - run : go build -v .
3732
38- - name : Build
33+ generate :
34+ runs-on : ubuntu-latest
35+ steps :
36+ - uses : actions/checkout@v3
37+ - uses : actions/setup-go@v3
38+ with :
39+ go-version-file : " go.mod"
40+ cache : true
41+ - run : go generate ./...
42+ - name : git diff
3943 run : |
40- go build -v .
44+ git diff --compact-summary --exit-code || \
45+ (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
4146
42- # run acceptance tests in a matrix with Terraform core versions
47+ # Run acceptance tests in a matrix with Terraform CLI versions
4348 test :
44- name : Matrix Test
49+ name : Terraform Provider Acceptance Tests
4550 needs : build
4651 runs-on : ubuntu-latest
4752 timeout-minutes : 15
@@ -54,29 +59,17 @@ jobs:
5459 - " 1.1.*"
5560 - " 1.2.*"
5661 steps :
57- - name : Check out code into the Go module directory
58- uses : actions/checkout@v3
59-
60- - name : Set up Go
61- uses : actions/setup-go@v3
62+ - uses : actions/checkout@v3
63+ - uses : actions/setup-go@v3
6264 with :
63- go-version-file : go.mod
64- id : go
65-
66- - name : Get dependencies
67- run : |
68- go mod download
69-
70- - name : TF acceptance tests
71- timeout-minutes : 10
72- env :
65+ go-version-file : " go.mod"
66+ cache : true
67+ - uses : hashicorp/setup-terraform@v2
68+ with :
69+ terraform_version : ${{ matrix.terraform }}
70+ terraform_wrapper : false
71+ - run : go mod download
72+ - env :
7373 TF_ACC : " 1"
74- TF_ACC_TERRAFORM_VERSION : ${{ matrix.terraform }}
75-
76- # Set whatever additional acceptance test env vars here. You can
77- # optionally use data from your repository secrets using the
78- # following syntax:
79- # SOME_VAR: ${{ secrets.SOME_VAR }}
80-
81- run : |
82- go test -v -cover ./internal/provider/
74+ run : go test -v -cover ./internal/provider/
75+ timeout-minutes : 10
0 commit comments