Skip to content

Commit e7d1012

Browse files
committed
ci: add lint step and only run unit tests for now (can be controlled via .env file later setting TF_ACC=1)
1 parent 176ec2b commit e7d1012

File tree

1 file changed

+38
-42
lines changed

1 file changed

+38
-42
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths-ignore:
99
- 'README.md'
1010
push:
11+
branches:
12+
- main
1113
paths-ignore:
1214
- 'README.md'
1315

@@ -16,31 +18,43 @@ permissions:
1618
contents: read
1719

1820
jobs:
19-
# Ensure project builds before running testing matrix
2021
build:
21-
name: Build
22+
name: Go Build
2223
runs-on: ubuntu-latest
23-
timeout-minutes: 5
2424
steps:
25-
- uses: actions/checkout@v4
26-
- uses: actions/setup-go@v5
25+
- uses: actions/checkout@v6
26+
- uses: actions/setup-go@v6
2727
with:
2828
go-version-file: 'go.mod'
2929
cache: true
30-
- run: go mod download
30+
- run: go mod tidy
3131
- run: go build -v .
32-
# - name: Run linters
33-
# uses: golangci/golangci-lint-action@v7
34-
# with:
35-
# version: latest
32+
- name: git diff
33+
run: |
34+
git diff --compact-summary --exit-code || \
35+
(echo; echo "Unexpected difference in directories after 'go mod tidy'. Run 'go mod tidy' command and commit."; exit 1)
36+
37+
golangci:
38+
needs: [ build ]
39+
name: Go Lint
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v5
43+
- uses: actions/setup-go@v6
44+
with:
45+
go-version: stable
46+
- name: golangci-lint
47+
uses: golangci/golangci-lint-action@v9
48+
with:
49+
version: latest
3650

3751
format:
52+
needs: [ build ]
3853
name: Go Format Check
3954
runs-on: ubuntu-latest
40-
timeout-minutes: 5
4155
steps:
42-
- uses: actions/checkout@v4
43-
- uses: actions/setup-go@v5
56+
- uses: actions/checkout@v6
57+
- uses: actions/setup-go@v6
4458
with:
4559
go-version-file: 'go.mod'
4660
cache: true
@@ -54,50 +68,32 @@ jobs:
5468
fi
5569
5670
generate:
71+
name: Generate Terraform Provider Docs
72+
needs: [ build ]
5773
runs-on: ubuntu-latest
5874
steps:
59-
- uses: actions/checkout@v4
60-
- uses: actions/setup-go@v5
75+
- uses: actions/checkout@v6
76+
- uses: actions/setup-go@v6
6177
with:
6278
go-version-file: 'go.mod'
6379
cache: true
64-
- uses: hashicorp/setup-terraform@v2
80+
- uses: hashicorp/setup-terraform@v3
6581
with:
6682
terraform_wrapper: false
67-
- run: go generate ./...
83+
- run: go generate
6884
- name: git diff
6985
run: |
7086
git diff --compact-summary --exit-code || \
7187
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
7288
73-
# Run acceptance tests in a matrix with Terraform CLI versions
7489
test:
75-
name: Terraform Provider Acceptance Tests
76-
needs: [build, format]
90+
name: Go Test
91+
needs: [ build ]
7792
runs-on: ubuntu-latest
78-
timeout-minutes: 15
79-
strategy:
80-
fail-fast: false
81-
matrix:
82-
# list whatever Terraform versions here you would like to support
83-
terraform:
84-
- '1.0.*'
85-
- '1.1.*'
86-
- '1.2.*'
87-
- '1.3.*'
88-
- '1.4.*'
8993
steps:
90-
- uses: actions/checkout@v4
91-
- uses: actions/setup-go@v5
94+
- uses: actions/checkout@v6
95+
- uses: actions/setup-go@v6
9296
with:
9397
go-version-file: 'go.mod'
9498
cache: true
95-
- uses: hashicorp/setup-terraform@v2
96-
with:
97-
terraform_version: ${{ matrix.terraform }}
98-
terraform_wrapper: false
99-
- run: go mod download
100-
- env:
101-
TF_ACC: "1"
102-
run: go test -v -cover ./internal/provider/
103-
timeout-minutes: 10
99+
- run: go test -v -cover ./...

0 commit comments

Comments
 (0)