Skip to content

Commit 1057443

Browse files
committed
ref: Only run the latest version of Terraform on PRs
1 parent 51b3d78 commit 1057443

File tree

2 files changed

+87
-64
lines changed

2 files changed

+87
-64
lines changed

.github/workflows/test.yml

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,67 @@
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.
42
name: 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.
56
on:
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+
2322
jobs:
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

Makefile

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
1-
GO_VER ?= go
2-
SWEEP ?= cloud
1+
SWEEP ?= cloud
32
SWEEP_TIMEOUT ?= 360m
43

5-
default: testacc
4+
default: fmt lint install generate
65

7-
.PHONY: deps
8-
deps:
9-
$(GO_VER) mod download
6+
.PHONY: build
7+
build:
8+
go build -v ./...
9+
10+
.PHONY: install
11+
install: build
12+
go install -v ./...
13+
14+
.PHONY: lint
15+
lint:
16+
golangci-lint run
17+
18+
.PHONY: generate
19+
generate:
20+
go generate ./...
21+
22+
.PHONY: fmt
23+
fmt:
24+
gofmt -s -w -e .
25+
26+
.PHONY: test
27+
test:
28+
go test -v -cover -timeout=120s -parallel=10 ./...
1029

11-
# Run acceptance tests
1230
.PHONY: testacc
1331
testacc:
14-
TF_ACC=1 $(GO_VER) test ./... -v $(TESTARGS) -timeout 120m
32+
TF_ACC=1 go test -v -cover -timeout 120m ./...
1533

16-
sweep: ## Run sweepers
34+
.PHONY: sweep
35+
sweep:
1736
# make sweep SWEEPARGS=-sweep-run=sentry_team
1837
# set SWEEPARGS=-sweep-allow-failures to continue after first failure
1938
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
20-
$(GO_VER) test ./... -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout $(SWEEP_TIMEOUT)
39+
go test ./... -v -sweep=$(SWEEP) $(SWEEPARGS) -timeout $(SWEEP_TIMEOUT)
2140

22-
sweeper: ## Run sweepers with failures allowed
41+
.PHONY: sweeper
42+
sweeper:
2343
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
24-
$(GO_VER) test ./... -v -tags=sweep -sweep=$(SWEEP) -sweep-allow-failures -timeout $(SWEEP_TIMEOUT)
44+
go test ./... -v -tags=sweep -sweep=$(SWEEP) -sweep-allow-failures -timeout $(SWEEP_TIMEOUT)

0 commit comments

Comments
 (0)