-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (116 loc) · 4.15 KB
/
tests.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
name: Tests and Linting
on: [pull_request]
jobs:
tflint:
name: Lint .tf examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: install tflint
uses: terraform-linters/setup-tflint@v2
- run: tflint --init
- name: tflint
run: |
exit_code=0
for DIR in $(find ./examples -type f -name '*.tf' -exec dirname {} \; | sort -u); do
pushd "$DIR"
tflint \
--enable-rule=terraform_comment_syntax \
--enable-rule=terraform_deprecated_index \
--enable-rule=terraform_deprecated_interpolation \
--disable-rule=terraform_unused_declarations \
--disable-rule=terraform_required_version \
--disable-rule=terraform_required_providers \
--disable-rule=terraform_typed_variables \
|| exit_code=1
popd
done
exit $exit_code
validate-terraform:
name: Check fmt and Validate .tf examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: build and install provider
run: make clean-dev && make install-dev
- name: override plugin
run: |
mkdir -p ~/.terraform.d/plugins/github.com/aziontech/azion/0.1.0/"$(go env GOOS)"_"$(go env GOARCH)"/
ls -lh ~/.terraform.d/plugins/github.com/aziontech/azion/0.1.0/linux_amd64
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
terraform_wrapper: false
- name: terraform check
run: |
for DIR in $(find ./examples -type f -name '*.tf' -exec dirname {} \; | sort -u); do
pushd "$DIR"
cat <<EOF > provider.tf
terraform {
required_providers {
azion = {
source = "github.com/aziontech/azion"
version = "0.1.0"
}
}
}
provider "azion" {
api_token = "t0k3nh3r3t0k3nh3r3t0k3nh3r3t0k3nh3r3t0k3nh3r3"
}
EOF
if [ -f terraform.template.tfvars ]; then
cp terraform.template.tfvars terraform.tfvars
fi
echo; echo -e "\e[1;35m===> Initializing Example: $DIR <===\e[0m"; echo
terraform init
echo; echo -e "\e[1;35m===> Format Checking Example: $DIR <===\e[0m"; echo
terraform fmt -check
echo; echo -e "\e[1;35m===> Validating Example: $DIR <===\e[0m"; echo
# Catch errors
terraform validate
popd
done
func-tests:
name: Terraform Functional Tests
timeout-minutes: 60
env:
AZION_API_TOKEN: ${{ secrets.E2E_PROD_TERRAFORM_TOKEN }}
AZION_API_ENTRYPOINT: "https://api.azionapi.net"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: build and install provider
run: make clean-dev && make install-dev
- name: override plugin
run: |
mkdir -p ~/.terraform.d/plugins/github.com/aziontech/azion/0.1.0/"$(go env GOOS)"_"$(go env GOARCH)"/
ls -lh ~/.terraform.d/plugins/github.com/aziontech/azion/0.1.0/linux_amd64
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
terraform_wrapper: false
- name: replace test-func string on .tf
run: |
sed -i 's/test-func/test-func-action/g' func-tests/main.tf
- name: run func tests
run: |
make func-init && make func-plan && make func-apply
- name: destroy after run func tests
if: ${{ always() }}
run: |
make func-destroy