-
Notifications
You must be signed in to change notification settings - Fork 3
162 lines (155 loc) · 5.03 KB
/
ci.yml
File metadata and controls
162 lines (155 loc) · 5.03 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Terraform Provider CI workflow.
name: CI
on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/ci.yml'
- '.goreleaser.yml'
- 'examples/**'
push:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/ci.yml'
- '.goreleaser.yml'
- 'examples/**'
permissions:
contents: read
jobs:
govulncheck:
name: Vulnerability Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- id: govulncheck
uses: golang/govulncheck-action@v1
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v -o terraform-provider-ona .
- name: Run linters
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: latest
test:
name: Unit Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go test -v -cover ./...
integration:
name: Integration Test (Terraform ${{ matrix.terraform }})
needs:
- build
- govulncheck
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
strategy:
max-parallel: 1
matrix:
terraform:
- '1.7.*'
- '1.14.*'
env:
GITPOD_API_KEY: ${{ secrets.GITPOD_API_KEY }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: Build provider
run: go build -o terraform-provider-ona .
- name: Setup dev overrides
run: |
cat > ~/.terraformrc << EOF
provider_installation {
dev_overrides {
"combor/ona" = "${{ github.workspace }}"
}
direct {}
}
EOF
- name: Clean up stale runners
working-directory: examples/cleanup
run: |
terraform apply -auto-approve \
-var="runner_manager_id=${{ secrets.RUNNER_MANAGER_ID }}"
terraform destroy -auto-approve \
-var="runner_manager_id=${{ secrets.RUNNER_MANAGER_ID }}"
- name: Terraform Apply
working-directory: examples
run: |
terraform apply -auto-approve \
-var="runner_name=tf-ci-${{ github.run_id }}" \
-var="runner_provider_type=RUNNER_PROVIDER_MANAGED" \
-var="runner_manager_id=${{ secrets.RUNNER_MANAGER_ID }}" \
-var="runner_region=eu-central-1" \
-var="project_name=tf-ci-proj-${{ github.run_id }}"
- name: Terraform Destroy
if: always()
working-directory: examples
run: |
terraform destroy -auto-approve \
-var="runner_name=tf-ci-${{ github.run_id }}" \
-var="runner_provider_type=RUNNER_PROVIDER_MANAGED" \
-var="runner_manager_id=${{ secrets.RUNNER_MANAGER_ID }}" \
-var="runner_region=eu-central-1" \
-var="project_name=tf-ci-proj-${{ github.run_id }}"
release:
name: Release
needs:
- test
- integration
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: 'go.mod'
cache: true
# - name: Import GPG key
# uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
# id: import_gpg
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}