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 branches :
1718 # to an API change, even if the code did not change.
1819 schedule :
1920 - cron : " 0 0 * * *"
21+
22+ # Testing only needs permissions to read the repository contents.
23+ permissions :
24+ contents : read
25+
2026concurrency :
2127 group : ${{ github.workflow }}-${{ github.ref }}
2228 cancel-in-progress : true
29+
2330jobs :
24- # ensure the code builds...
31+ # Ensure project builds before running testing matrix
2532 build :
2633 name : Build
2734 runs-on : ubuntu-latest
2835 timeout-minutes : 5
2936 steps :
30- - uses : actions/checkout@v4
31- - uses : actions/setup-go@v5
37+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
3239 with :
3340 go-version-file : " go.mod"
3441 cache : true
35- - name : Get dependencies
36- run : |
37- go mod download
38- - name : Build
39- run : |
40- go build -v .
42+ - run : go mod download
43+ - run : go build -v .
44+ - name : Run linters
45+ uses : golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
46+ with :
47+ version : latest
4148
4249 generate :
4350 runs-on : ubuntu-latest
4451 steps :
45- - uses : actions/checkout@v4
46- - uses : actions/setup-go@v5
52+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
4754 with :
4855 go-version-file : " go.mod"
4956 cache : true
50- - run : go generate ./...
57+ # We need the latest version of Terraform for our documentation generation to use
58+ - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
59+ with :
60+ terraform_wrapper : false
61+ - run : make generate
5162 - name : git diff
5263 run : |
53- git diff --exit-code || \
54- (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./... ' command and commit."; exit 1)
64+ git diff --compact-summary -- exit-code || \
65+ (echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1)
5566
56- # run acceptance tests in a matrix with Terraform core versions
67+ # Run acceptance tests in a matrix with Terraform CLI versions
5768 test :
58- name : Matrix Test
69+ name : Terraform Provider Acceptance Tests
5970 needs : build
6071 runs-on : ubuntu-latest
61- timeout-minutes : 30
72+ timeout-minutes : 15
6273 strategy :
6374 fail-fast : false
6475 max-parallel : 1
@@ -69,25 +80,36 @@ jobs:
6980 - " 1.6.*"
7081 - " 1.7.*"
7182 - " 1.8.*"
83+ - " 1.9.*"
84+ - " 1.10.*"
85+ is-pr :
86+ - ${{ github.event_name == 'pull_request' }}
87+ # Only run the latest version of Terraform on pull requests
88+ exclude :
89+ - terraform : " 1.4.*"
90+ is-pr : true
91+ - terraform : " 1.5.*"
92+ is-pr : true
93+ - terraform : " 1.6.*"
94+ is-pr : true
95+ - terraform : " 1.7.*"
96+ is-pr : true
97+ - terraform : " 1.8.*"
98+ is-pr : true
99+ - terraform : " 1.9.*"
100+ is-pr : true
72101 steps :
73- - uses : actions/checkout@v4
74- - uses : actions/setup-go@v5
102+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
103+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
75104 with :
76105 go-version-file : " go.mod"
77106 cache : true
78-
79- - uses : hashicorp/setup-terraform@v3
107+ - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
80108 with :
81109 terraform_version : ${{ matrix.terraform }}
82110 terraform_wrapper : false
83-
84- - name : Get dependencies
85- run : |
86- go mod download
87-
88- - name : TF acceptance tests
89- timeout-minutes : 30
90- env :
111+ - run : go mod download
112+ - env :
91113 TF_ACC : " 1"
92114 SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
93115 SENTRY_TEST_GITHUB_INSTALLATION_ID : ${{ secrets.SENTRY_TEST_GITHUB_INSTALLATION_ID }}
@@ -100,5 +122,5 @@ jobs:
100122 SENTRY_TEST_PAGERDUTY_ORGANIZATION : ${{ secrets.SENTRY_TEST_PAGERDUTY_ORGANIZATION }}
101123 SENTRY_TEST_VSTS_INSTALLATION_ID : ${{ secrets.SENTRY_TEST_VSTS_INSTALLATION_ID }}
102124 SENTRY_TEST_VSTS_REPOSITORY_IDENTIFIER : ${{ secrets.SENTRY_TEST_VSTS_REPOSITORY_IDENTIFIER }}
103- run : |
104- go test -v -cover -timeout 30m ./...
125+ run : go test -v -cover ./internal/provider/
126+ timeout-minutes : 10
0 commit comments