-
Notifications
You must be signed in to change notification settings - Fork 21
148 lines (142 loc) · 5.58 KB
/
terraform_provider.yml
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
name: Terraform Provider Checks
on:
push:
branches:
- main
- develop
paths-ignore:
- '**.md'
pull_request:
branches:
- main
- develop
paths-ignore:
- '**.md'
env:
TERRAFORM_VERSION: "1.2.6"
jobs:
go_build:
name: go build
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
continue-on-error: true
id: cache-terraform-plugin-dir
timeout-minutes: 2
with:
path: terraform-plugin-dir
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('provider/**') }}
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure'
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure'
name: go mod download
run: go mod download
- if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure'
name: go build
run: go build -o terraform-plugin-dir/registry.terraform.io/RedisLabs/rediscloud/99.99.99/$(go env GOOS)_$(go env GOARCH)/terraform-provider-rediscloud .
terraform_providers_schema:
name: terraform providers schema
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
continue-on-error: true
id: cache-terraform-providers-schema
timeout-minutes: 2
with:
path: terraform-providers-schema
key: ${{ runner.os }}-terraform-providers-schema-${{ hashFiles('go.sum') }}-${{ hashFiles('provider/**') }}
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure'
uses: actions/[email protected]
timeout-minutes: 2
with:
path: terraform-plugin-dir
key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('provider/**') }}
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure'
uses: hashicorp/[email protected]
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure'
name: terraform init
run: |
# We need a file to initialize the provider
cat <<EOT >> providers.tf
terraform {
required_providers {
rediscloud = {
source = "RedisLabs/rediscloud"
version = "99.99.99"
}
}
}
EOT
echo 'resource "rediscloud_subscription" "example" {}' > example.tf
terraform init -plugin-dir terraform-plugin-dir
- if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure'
name: terraform providers schema
run: |
mkdir terraform-providers-schema
terraform providers schema -json > terraform-providers-schema/schema.json
go_test:
name: go test
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: dorny/[email protected]
id: filter
with:
filters: |
code-changes:
- 'go.mod'
- 'go.sum'
- 'provider/**'
- '*.go'
- '.github/workflows/**'
- run: make testacc
if: steps.filter.outputs.code-changes == 'true'
env:
REDISCLOUD_ACCESS_KEY: ${{ secrets.REDISCLOUD_ACCESS_KEY_QA }}
REDISCLOUD_SECRET_KEY: ${{ secrets.REDISCLOUD_SECRET_KEY_QA }}
REDISCLOUD_URL: https://api-k8s-cloudapi.qa.redislabs.com/v1
AWS_TEST_CLOUD_ACCOUNT_NAME: "${{ secrets.AWS_TEST_CLOUD_ACCOUNT_NAME }}"
AWS_PEERING_REGION: ${{ secrets.AWS_PEERING_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_VPC_CIDR: ${{ secrets.AWS_VPC_CIDR }}
AWS_VPC_ID: ${{ secrets.AWS_VPC_ID }}
TF_ACC: true
TF_LOG: debug
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUD_ACCOUNT_KEY }}
AWS_ACCESS_SECRET_KEY: ${{ secrets.CLOUD_ACCOUNT_SECRET }}
AWS_CONSOLE_USERNAME: ${{ secrets.CLOUD_ACCOUNT_USERNAME }}
AWS_CONSOLE_PASSWORD: ${{ secrets.CLOUD_ACCOUNT_PASS }}
AWS_SIGNIN_URL: ${{ secrets.CLOUD_ACCOUNT_URL }}
GCP_VPC_PROJECT: ${{ secrets.GCP_VPC_PROJECT }}
GCP_VPC_ID: ${{ secrets.GCP_VPC_ID }}
- name: Generate code coverage report
if: steps.filter.outputs.code-changes == 'true' && (success() || failure())
run: make generate_coverage
- name: Upload code coverage report
if: steps.filter.outputs.code-changes == 'true' && (success() || failure())
uses: actions/upload-artifact@v3
with:
name: coverage.html
path: bin/coverage.html
tfproviderlint:
name: tfproviderlint
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: make tfproviderlint