Skip to content

Commit 4564c29

Browse files
committed
remove tf version from matrix, to keep workflow names stable across upgrades
1 parent 6045cf6 commit 4564c29

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

.github/workflows/tests.yml

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,36 @@ env:
4141
DEFAULT_TOFU_VERSION: "1.10.0"
4242

4343
jobs:
44-
compute-matrix:
45-
runs-on: ubuntu-latest
46-
outputs:
47-
DEFAULT_TERRAFORM_FLAVOUR: ${{ env.DEFAULT_TERRAFORM_FLAVOUR }}
48-
DEFAULT_TERRAFORM_VERSION: ${{ env.DEFAULT_TERRAFORM_VERSION }}
49-
DEFAULT_TOFU_VERSION: ${{ env.DEFAULT_TOFU_VERSION }}
50-
steps:
51-
- name: dummy
52-
run: echo
53-
5444
setup-tf-providers:
5545
runs-on: ubuntu-latest
56-
needs:
57-
- compute-matrix
5846
strategy:
5947
matrix:
6048
include:
6149
- flavour: terraform
62-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TERRAFORM_VERSION }}"
6350
- flavour: tofu
64-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TOFU_VERSION }}"
6551
steps:
6652
- uses: actions/checkout@v4
53+
- name: Set Terraform versions
54+
run: |
55+
set -e -o xtrace
56+
if [[ ${{ matrix.flavour }} == 'terraform' ]] ; then
57+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TERRAFORM_VERSION }} | tee -a ${GITHUB_ENV}
58+
elif [[ ${{ matrix.flavour }} == 'tofu' ]] ; then
59+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TOFU_VERSION }} | tee -a ${GITHUB_ENV}
60+
else
61+
echo TERRAFORM_VERSION=unkown_flavor | tee -a ${GITHUB_ENV}
62+
fi
6763
6864
- uses: hashicorp/setup-terraform@v3
6965
if: ${{ matrix.flavour == 'terraform' }}
7066
with:
71-
terraform_version: ${{ matrix.version }}
67+
terraform_version: ${{ env.TERRAFORM_VERSION }}
7268
terraform_wrapper: false
7369

7470
- uses: opentofu/setup-opentofu@v1
7571
if: ${{ matrix.flavour == 'tofu' }}
7672
with:
77-
tofu_version: ${{ matrix.version }}
73+
tofu_version: ${{ env.TERRAFORM_VERSION }}
7874
tofu_wrapper: false
7975

8076
- name: Build lockfile and fetch providers
@@ -86,7 +82,7 @@ jobs:
8682
sed -i -e 's/>=\(.*# tftest\)/=\1/g' tools/lockfile/versions.tf tools/lockfile/versions.tofu
8783
8884
# change terraform version to the one that is running
89-
sed -i 's/required_version = .*$/required_version = ">= ${{ matrix.version }}"/g' tools/lockfile/versions.tf
85+
sed -i 's/required_version = .*$/required_version = ">= ${{ env.TERRAFORM_VERSION }}"/g' tools/lockfile/versions.tf
9086
9187
cd tools/lockfile
9288
${{ matrix.flavour }} init -upgrade=true
@@ -95,12 +91,12 @@ jobs:
9591
uses: actions/cache@v4
9692
with:
9793
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
98-
key: ${{ runner.os }}-${{ matrix.flavour }}-${{ matrix.version }}-${{ hashFiles('tools/lockfile/.terraform.lock.hcl') }}
94+
key: ${{ runner.os }}-${{ matrix.flavour }}-${{ env.TERRAFORM_VERSION }}-${{ hashFiles('tools/lockfile/.terraform.lock.hcl') }}
9995

10096
- name: Upload lockfile
10197
uses: actions/upload-artifact@v4
10298
with:
103-
name: lockfile-${{ runner.os }}-${{ matrix.flavour }}-${{ matrix.version }}
99+
name: lockfile-${{ runner.os }}-${{ matrix.flavour }}-${{ env.TERRAFORM_VERSION }}
104100
path: tools/lockfile/.terraform.lock.hcl
105101
overwrite: true
106102
include-hidden-files: true
@@ -131,23 +127,30 @@ jobs:
131127
runs-on: ubuntu-latest
132128
needs:
133129
- setup-tf-providers
134-
- compute-matrix
135130
strategy:
136131
matrix:
137132
include:
138133
- flavour: terraform
139-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TERRAFORM_VERSION }}"
140134
- flavour: tofu
141-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TOFU_VERSION }}"
142135

143136
steps:
144137
- uses: actions/checkout@v4
138+
- name: Set Terraform versions
139+
run: |
140+
set -e -o xtrace
141+
if [[ ${{ matrix.flavour }} == 'terraform' ]] ; then
142+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TERRAFORM_VERSION }} | tee -a ${GITHUB_ENV}
143+
elif [[ ${{ matrix.flavour }} == 'tofu' ]] ; then
144+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TOFU_VERSION }} | tee -a ${GITHUB_ENV}
145+
else
146+
echo TERRAFORM_VERSION=unkown_flavor | tee -a ${GITHUB_ENV}
147+
fi
145148
146149
- name: Call composite action fabric-tests
147150
uses: ./.github/actions/fabric-tests
148151
with:
149152
PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
150-
TERRAFORM_VERSION: ${{ matrix.version }}
153+
TERRAFORM_VERSION: ${{ env.TERRAFORM_VERSION }}
151154
TERRAFORM_FLAVOUR: ${{ matrix.flavour }}
152155

153156
- name: Run tests on documentation examples
@@ -165,25 +168,32 @@ jobs:
165168
runs-on: ubuntu-latest
166169
needs:
167170
- setup-tf-providers
168-
- compute-matrix
169171
strategy:
170172
matrix:
171173
include:
172174
- flavour: terraform
173-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TERRAFORM_VERSION }}"
174175
- flavour: tofu
175-
version: "${{ needs.compute-matrix.outputs.DEFAULT_TOFU_VERSION }}"
176176

177177
steps:
178178
- uses: actions/checkout@v4
179+
- name: Set Terraform versions
180+
run: |
181+
set -e -o xtrace
182+
if [[ ${{ matrix.flavour }} == 'terraform' ]] ; then
183+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TERRAFORM_VERSION }} | tee -a ${GITHUB_ENV}
184+
elif [[ ${{ matrix.flavour }} == 'tofu' ]] ; then
185+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TOFU_VERSION }} | tee -a ${GITHUB_ENV}
186+
else
187+
echo TERRAFORM_VERSION=unkown_flavor | tee -a ${GITHUB_ENV}
188+
fi
179189
180190
- name: Call composite action fabric-tests
181191
uses: ./.github/actions/fabric-tests
182192
env:
183193
TERRAFORM: ${{ matrix.flavour }}
184194
with:
185195
PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
186-
TERRAFORM_VERSION: ${{ matrix.version }}
196+
TERRAFORM_VERSION: ${{ env.TERRAFORM_VERSION }}
187197
TERRAFORM_FLAVOUR: ${{ matrix.flavour }}
188198

189199
- name: Run tests modules
@@ -200,15 +210,30 @@ jobs:
200210
fast:
201211
runs-on: ubuntu-latest
202212
needs: setup-tf-providers
213+
strategy:
214+
matrix:
215+
include:
216+
- flavour: terraform
217+
# - flavour: tofu # tofu fails to find the terraform binary for FAST tests
203218
steps:
204219
- uses: actions/checkout@v4
220+
- name: Set Terraform versions
221+
run: |
222+
set -e -o xtrace
223+
if [[ ${{ matrix.flavour }} == 'terraform' ]] ; then
224+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TERRAFORM_VERSION }} | tee -a ${GITHUB_ENV}
225+
elif [[ ${{ matrix.flavour }} == 'tofu' ]] ; then
226+
echo TERRAFORM_VERSION=${{ env.DEFAULT_TOFU_VERSION }} | tee -a ${GITHUB_ENV}
227+
else
228+
echo TERRAFORM_VERSION=unkown_flavor | tee -a ${GITHUB_ENV}
229+
fi
205230
206231
- name: Call composite action fabric-tests
207232
uses: ./.github/actions/fabric-tests
208233
with:
209234
PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
210-
TERRAFORM_VERSION: ${{ env.DEFAULT_TERRAFORM_VERSION }}
211-
TERRAFORM_FLAVOUR: ${{ env.DEFAULT_TERRAFORM_FLAVOUR }}
235+
TERRAFORM_VERSION: ${{ env.TERRAFORM_VERSION }}
236+
TERRAFORM_FLAVOUR: ${{ matrix.flavour }}
212237

213238
- name: Run tests on FAST stages
214239
run: pytest -vv -n4 --tb=line --junit-xml=test-results-raw.xml tests/fast

0 commit comments

Comments
 (0)