-
Notifications
You must be signed in to change notification settings - Fork 10
187 lines (157 loc) · 5.14 KB
/
setup-tofu.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: 'Setup OpenTofu'
on:
push:
branches:
- main
pull_request:
defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
tofu-versions:
name: 'OpenTofu Versions'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-versions: [1.6.0-alpha1, latest]
tofu-wrapper: [true, false]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu - ${{ matrix['tofu-versions'] }}
uses: ./
with:
tofu_version: ${{ matrix['tofu-versions'] }}
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}
- name: Validate that OpenTofu was installed
run: tofu version | grep 'OpenTofu v'
- name: Validate the Version ${{ matrix['tofu-versions'] }} was installed
if: ${{ matrix['tofu-versions'] != 'latest' }}
run: tofu version | grep ${{ matrix['tofu-versions']}}
tofu-arguments:
name: 'OpenTofu Arguments'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-wrapper: [true, false]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu
uses: ./
with:
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}
- name: Check No Arguments
run: tofu || exit 0
- name: Check Single Argument
run: tofu help || exit 0
- name: Check Single Argument Hyphen
run: tofu -help
- name: Check Single Argument Double Hyphen
run: tofu --help
- name: Check Single Argument Subcommand
run: tofu fmt -check
- name: Check Multiple Arguments Subcommand
run: tofu fmt -check -list=true -no-color
tofu-run-local:
name: 'OpenTofu Run Local'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tofu-wrapper: [true, false]
defaults:
run:
shell: bash
working-directory: ./.github/workflows/data/local
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu
uses: ./
with:
tofu_wrapper: ${{ matrix['tofu-wrapper'] }}
- name: OpenTofu Init
run: tofu init
- name: OpenTofu Format
run: tofu fmt -check
- name: OpenTofu Plan
id: plan
run: tofu plan
- name: Print OpenTofu Plan
if: ${{ matrix['tofu-wrapper'] == 'true' }}
run: echo "${{ steps.plan.outputs.stdout }}"
tofu-credentials-cloud:
name: 'OpenTofu Cloud Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu
uses: ./
with:
cli_config_credentials_token: ${{ env.TF_CLOUD_API_TOKEN }}
- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
cat ${APPDATA}/tofu.rc | grep 'credentials "app.terraform.io"'
cat ${APPDATA}/tofu.rc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
cat ${HOME}/.tofurc | grep 'credentials "app.terraform.io"'
cat ${HOME}/.tofurc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
tofu-credentials-enterprise:
name: 'OpenTofu Enterprise Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
TF_CLOUD_API_TOKEN: 'XXXXXXXXXXXXXX.atlasv1.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu
uses: ./
with:
cli_config_credentials_hostname: 'tofu.example.com'
cli_config_credentials_token: ${{ env.TF_CLOUD_API_TOKEN }}
- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
cat ${APPDATA}/tofu.rc | grep 'credentials "tofu.example.com"'
cat ${APPDATA}/tofu.rc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
cat ${HOME}/.tofurc | grep 'credentials "tofu.example.com"'
cat ${HOME}/.tofurc | grep 'token = "${{ env.TF_CLOUD_API_TOKEN }}"'
tofu-credentials-none:
name: 'OpenTofu No Credentials'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup OpenTofu
uses: ./
- name: Validate OpenTofu Credentials (Windows)
if: runner.os == 'Windows'
run: |
[[ -f ${APPDATA}/tofu.rc ]] || exit 0
- name: Validate Teraform Credentials (Linux & macOS)
if: runner.os != 'Windows'
run: |
[[ -f ${HOME}/.tofurc ]] || exit 0