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 :
7- branches :
8- - main
98 paths-ignore :
109 - " README.md"
1110 push :
12- branches :
13- - main
1411 paths-ignore :
1512 - " README.md"
1613 # We test at a regular interval to ensure we are alerted to something breaking due
1714 # to an API change, even if the code did not change.
1815 schedule :
1916 - cron : " 0 0 * * *"
20- concurrency :
21- group : ${{ github.workflow }}-${{ github.ref }}
22- cancel-in-progress : true
17+
18+ # Testing only needs permissions to read the repository contents.
19+ permissions :
20+ contents : read
21+
2322jobs :
24- # ensure the code builds...
23+ # Ensure project builds before running testing matrix
2524 build :
2625 name : Build
2726 runs-on : ubuntu-latest
2827 timeout-minutes : 5
2928 steps :
30- - uses : actions/checkout@v4
31- - uses : actions/setup-go@v5
29+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
3231 with :
3332 go-version-file : " go.mod"
3433 cache : true
35- - name : Get dependencies
36- run : |
37- go mod download
38- - name : Build
39- run : |
40- go build -v .
34+ - run : go mod download
35+ - run : go build -v .
36+ - name : Run linters
37+ uses : golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
38+ with :
39+ version : latest
4140
4241 generate :
4342 runs-on : ubuntu-latest
4443 steps :
45- - uses : actions/checkout@v4
46- - uses : actions/setup-go@v5
44+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
4746 with :
4847 go-version-file : " go.mod"
4948 cache : true
50- - run : go generate ./...
49+ # We need the latest version of Terraform for our documentation generation to use
50+ - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
51+ with :
52+ terraform_wrapper : false
53+ - run : make generate
5154 - name : git diff
5255 run : |
53- git diff --exit-code || \
54- (echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./... ' command and commit."; exit 1)
56+ git diff --compact-summary -- exit-code || \
57+ (echo; echo "Unexpected difference in directories after code generation. Run 'make generate' command and commit."; exit 1)
5558
56- # run acceptance tests in a matrix with Terraform core versions
59+ # Run acceptance tests in a matrix with Terraform CLI versions
5760 test :
58- name : Matrix Test
61+ name : Terraform Provider Acceptance Tests
5962 needs : build
6063 runs-on : ubuntu-latest
61- timeout-minutes : 30
64+ timeout-minutes : 15
6265 strategy :
6366 fail-fast : false
6467 max-parallel : 1
@@ -69,36 +72,36 @@ jobs:
6972 - " 1.6.*"
7073 - " 1.7.*"
7174 - " 1.8.*"
75+ - " 1.9.*"
76+ - " 1.10.*"
77+ is-pr :
78+ - ${{ github.event_name == 'pull_request' }}
79+ # Only run the latest version of Terraform on pull requests
80+ exclude :
81+ - terraform : " 1.4.*"
82+ is-pr : true
83+ - terraform : " 1.5.*"
84+ is-pr : true
85+ - terraform : " 1.6.*"
86+ is-pr : true
87+ - terraform : " 1.7.*"
88+ is-pr : true
89+ - terraform : " 1.8.*"
90+ is-pr : true
91+ - terraform : " 1.9.*"
92+ is-pr : true
7293 steps :
73- - uses : actions/checkout@v4
74- - uses : actions/setup-go@v5
94+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
95+ - uses : actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
7596 with :
7697 go-version-file : " go.mod"
7798 cache : true
78-
79- - uses : hashicorp/setup-terraform@v3
99+ - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
80100 with :
81101 terraform_version : ${{ matrix.terraform }}
82102 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 :
103+ - run : go mod download
104+ - env :
91105 TF_ACC : " 1"
92- SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
93- SENTRY_TEST_GITHUB_INSTALLATION_ID : ${{ secrets.SENTRY_TEST_GITHUB_INSTALLATION_ID }}
94- SENTRY_TEST_GITHUB_REPOSITORY_IDENTIFIER : ${{ secrets.SENTRY_TEST_GITHUB_REPOSITORY_IDENTIFIER }}
95- SENTRY_TEST_GITLAB_INSTALLATION_ID : ${{ secrets.SENTRY_TEST_GITLAB_INSTALLATION_ID }}
96- SENTRY_TEST_GITLAB_REPOSITORY_IDENTIFIER : ${{ secrets.SENTRY_TEST_GITLAB_REPOSITORY_IDENTIFIER }}
97- SENTRY_TEST_OPSGENIE_INTEGRATION_KEY : ${{ secrets.SENTRY_TEST_OPSGENIE_INTEGRATION_KEY }}
98- SENTRY_TEST_OPSGENIE_ORGANIZATION : ${{ secrets.SENTRY_TEST_OPSGENIE_ORGANIZATION }}
99- SENTRY_TEST_ORGANIZATION : ${{ secrets.SENTRY_TEST_ORGANIZATION }}
100- SENTRY_TEST_PAGERDUTY_ORGANIZATION : ${{ secrets.SENTRY_TEST_PAGERDUTY_ORGANIZATION }}
101- SENTRY_TEST_VSTS_INSTALLATION_ID : ${{ secrets.SENTRY_TEST_VSTS_INSTALLATION_ID }}
102- SENTRY_TEST_VSTS_REPOSITORY_IDENTIFIER : ${{ secrets.SENTRY_TEST_VSTS_REPOSITORY_IDENTIFIER }}
103- run : |
104- go test -v -cover -timeout 30m ./...
106+ run : go test -v -cover ./internal/provider/
107+ timeout-minutes : 10
0 commit comments