-
Notifications
You must be signed in to change notification settings - Fork 13
135 lines (128 loc) · 4.34 KB
/
test.yml
File metadata and controls
135 lines (128 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Terraform Provider testing workflow.
name: Terraform Provider Build Tests
# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
paths-ignore:
- "*.md"
push:
branches:
- main
paths-ignore:
- "*.md"
workflow_dispatch:
workflow_call:
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
# Define the latest Terraform version to use for upload of coverage report
env:
LATEST_VERSION: 1.14.*
jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
#cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v3.7.1
with:
version: latest
skip-cache: true
generate:
if: github.event.pull_request.draft == false
name: Docu Generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85
with:
terraform_version: ${{ env.LATEST_VERSION }}
terraform_wrapper: false
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
cache: true
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
gofix:
if: github.event.pull_request.draft == false
name: Go Fix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
cache: false
- run: go fix ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after running 'go fix'. Run 'go fix ./...' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test_with_terraform_versions:
if: github.event.pull_request.draft == false
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# List of Terraform versions to be tested - last three versions are in scope
# Check https://endoflife.date/terraform for end of support dates
# '1.6.*' end of security support 10 Apr 2024
# '1.7.*' end of security support 26 Jun 2024
# '1.8.*' end of security support 26 Nov 2024
# '1.9.*' #end of security support 27 Feb 2025
# '1.10.*' end of security support 14 May 2025
# '1.11.*' end of security support 20 Aug 2025
terraform:
- "1.12.*"
- "1.13.*"
- "1.14.*"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
cache: true
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- if: ${{ matrix.terraform != env.LATEST_VERSION }}
env:
TF_ACC: "1"
run: go test -v -timeout=900s -parallel=4 ./...
timeout-minutes: 20
- if: ${{ matrix.terraform == env.LATEST_VERSION }}
env:
TF_ACC: "1"
uses: robherley/go-test-action@v0
with:
testArguments: -v -cover -coverprofile=cover.out -timeout=900s -parallel=4 ./...
- uses: actions/upload-artifact@v7
if: ${{ matrix.terraform == env.LATEST_VERSION }}
with:
name: coverage-report
path: cover.out