-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (122 loc) · 3.73 KB
/
pr.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
148
name: Run Tests
on:
pull_request:
branches:
- main
jobs:
terraform_format:
name: Run terraform fmt
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
- name: Format all .tf files recursively
run: |
terraform fmt -check -diff -recursive ${{ github.workspace }}
terraform_docs:
name: Run tfplugindocs
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- uses: actions/setup-go@v4
with:
go-version: '1.20.5' # tfplugindocs requires go >= 1.18
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup tfplugindocs
run: |
cd /tmp
curl -L -o tfplugindocs.zip https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.15.0/tfplugindocs_0.15.0_linux_amd64.zip
unzip tfplugindocs.zip
chmod +x tfplugindocs
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Generate files with checked in files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "Dan Bot"
rm -r docs
/tmp/tfplugindocs
git add .
git commit -m "added terraform docs"
git push
terraform_lint:
name: Run terraform-lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup Terraform Lint
uses: terraform-linters/setup-tflint@v1
with:
tflint_version: v0.26.0
- name: Lint examples directory in a loop
run: |
tflint \
--config ${{ github.workspace }}/.tflint.hcl \
${{ github.workspace }}/examples/
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Checkout code
uses: actions/checkout@v2
- name: Setup terraform CLI
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
terraform_wrapper: false
- name: Compile
run: make
- name: Run Unit Tests
run: make test
acc-tests:
runs-on: ubuntu-latest
## Skip acc tests on dependabot PRs because secrets are excluded on these PRs
## which in turn guarantees that the acc-tests will fail. We will rely solely on
## unit tests to tell us that the dependencies are working as expected.
if: ${{ github.actor != 'dependabot[bot]' }}
env:
LIGHTSTEP_API_KEY_PUBLIC: ${{ secrets.LIGHTSTEP_API_KEY_PUBLIC }}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Checkout code
uses: actions/checkout@v2
- name: Setup terraform CLI
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
terraform_wrapper: false
- name: Compile
run: make
- name: Run Unit Tests
run: make acc-test