Skip to content

Commit 9f89f55

Browse files
committed
backport of commit 926b688
1 parent 31fdb1f commit 9f89f55

File tree

169 files changed

+1922
-3780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+1922
-3780
lines changed

.github/actions/equivalence-test/action.yml

+25-43
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
# SPDX-License-Identifier: BUSL-1.1
33

44
name: equivalence-test
5-
description: "Execute the suite of Terraform equivalence tests in testing/equivalence-tests and update the golden files."
5+
description: "Execute the suite of Terraform equivalence tests in testing/equivalence-tests"
66
inputs:
7+
target-terraform-version:
8+
description: "The version of Terraform to use in execution."
9+
required: true
10+
target-terraform-branch:
11+
description: "The branch within this repository to update and compare."
12+
required: true
713
target-equivalence-test-version:
814
description: "The version of the Terraform equivalence tests to use."
915
default: "0.3.0"
@@ -13,22 +19,9 @@ inputs:
1319
target-arch:
1420
description: "Current architecture"
1521
default: "amd64"
16-
current-branch:
17-
description: "What branch are we currently on?"
18-
required: true
19-
new-branch:
20-
description: "Name of new branch to be created for the review."
21-
required: true
22-
reviewers:
23-
description: "Comma-separated list of GitHub usernames to request review from."
24-
required: true
25-
message:
26-
description: "Message to include in the commit."
27-
required: true
2822
runs:
2923
using: "composite"
3024
steps:
31-
3225
- name: "download equivalence test binary"
3326
shell: bash
3427
run: |
@@ -37,43 +30,32 @@ runs:
3730
./bin/equivalence-tests \
3831
${{ inputs.target-os }} \
3932
${{ inputs.target-arch }}
40-
41-
- name: Build terraform
33+
- name: "download terraform binary"
4234
shell: bash
43-
run: ./.github/scripts/equivalence-test.sh build_terraform_binary ./bin/terraform
44-
35+
run: |
36+
./.github/scripts/equivalence-test.sh download_terraform_binary \
37+
${{ inputs.target-terraform-version }} \
38+
./bin/terraform \
39+
${{ inputs.target-os }} \
40+
${{ inputs.target-arch }}
4541
- name: "run and update equivalence tests"
46-
id: execute
4742
shell: bash
4843
run: |
4944
./bin/equivalence-tests update \
5045
--tests=testing/equivalence-tests/tests \
5146
--goldens=testing/equivalence-tests/outputs \
5247
--binary=$(pwd)/bin/terraform
5348
54-
git add --intent-to-add testing/equivalence-tests/outputs
5549
changed=$(git diff --quiet -- testing/equivalence-tests/outputs || echo true)
56-
echo "changed=$changed" >> "${GITHUB_OUTPUT}"
50+
if [[ $changed == "true" ]]; then
51+
echo "found changes, and pushing new golden files into branch ${{ inputs.target-terraform-branch }}."
5752
58-
- name: "branch, commit, and push changes"
59-
if: steps.execute.outputs.changed == 'true'
60-
shell: bash
61-
run: |
62-
git config user.name "hc-github-team-tf-core"
63-
git config user.email "github-team-tf-core@hashicorp.com"
64-
git checkout -b ${{ inputs.new-branch }}
65-
git add testing/equivalence-tests/outputs
66-
git commit -m "Update equivalence test golden files."
67-
git push --set-upstream origin ${{ inputs.new-branch }}
68-
69-
- name: "create pull request"
70-
if: steps.execute.outputs.changed == 'true'
71-
shell: bash
72-
run: |
73-
gh pr create \
74-
--draft \
75-
--base ${{ inputs.current-branch }} \
76-
--head ${{ inputs.new-branch }} \
77-
--title "Update equivalence test golden files" \
78-
--body '${{ inputs.message }}' \
79-
--reviewer ${{ inputs.reviewers }}
53+
git config user.email "52939924+teamterraform@users.noreply.github.com"
54+
git config user.name "The Terraform Team"
55+
56+
git add ./testing/equivalence-tests/outputs
57+
git commit -m "Automated equivalence test golden file update for release ${{ inputs.target-terraform-version }}."
58+
git push
59+
else
60+
echo "found no changes, so not pushing any updates."
61+
fi

.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ label to enable the backport bot.
3131
3232
-->
3333

34-
1.11.x
34+
1.10.x
3535

3636
## Draft CHANGELOG entry
3737

.github/scripts/equivalence-test.sh

+20-12
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Commands:
2626
2727
./equivalence-test.sh download_equivalence_test_binary 0.3.0 ./bin/terraform-equivalence-testing linux amd64
2828
29-
build_terraform_binary <target>
30-
download_terraform_binary builds the Terraform binary and places it at the
31-
target path.
29+
download_terraform_binary <version> <target> <os> <arch>
30+
download_terraform_binary downloads the terraform release binary for a given
31+
version and places it at the target path.
3232
33-
./equivalence-test.sh build_terraform_binary ./bin/terraform
33+
./equivalence-test.sh download_terraform_binary 1.4.3 ./bin/terraform linux amd64
3434
EOF
3535
}
3636

@@ -65,17 +65,25 @@ function download_equivalence_test_binary {
6565
rm releases.json
6666
}
6767

68-
function build_terraform_binary {
69-
TARGET="${1:-}"
68+
function download_terraform_binary {
69+
VERSION="${1:-}"
70+
TARGET="${2:-}"
71+
OS="${3:-}"
72+
ARCH="${4:-}"
7073

71-
if [[ -z "$TARGET" ]]; then
72-
echo "target argument"
74+
if [[ -z "$VERSION" || -z "$TARGET" || -z "$OS" || -z "$ARCH" ]]; then
75+
echo "missing at least one of [<version>, <target>, <os>, <arch>] arguments"
7376
usage
7477
exit 1
7578
fi
7679

77-
go build -o "$TARGET" ./
80+
mkdir -p zip
81+
curl "https://releases.hashicorp.com/terraform/${VERSION}/terraform_${VERSION}_${OS}_${ARCH}.zip" > "zip/terraform.zip"
82+
83+
mkdir -p bin
84+
unzip -p "zip/terraform.zip" terraform > "$TARGET"
7885
chmod u+x "$TARGET"
86+
rm -r zip
7987
}
8088

8189
function get_target_branch {
@@ -134,14 +142,14 @@ function main {
134142
download_equivalence_test_binary "$2" "$3" "$4" "$5"
135143

136144
;;
137-
build_terraform_binary)
138-
if [ "${#@}" != 2 ]; then
145+
download_terraform_binary)
146+
if [ "${#@}" != 5 ]; then
139147
echo "invalid number of arguments"
140148
usage
141149
exit 1
142150
fi
143151

144-
build_terraform_binary "$2"
152+
download_terraform_binary "$2" "$3" "$4" "$5"
145153

146154
;;
147155
*)

.github/workflows/build-terraform-cli.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
runs-on: ${{ inputs.runson }}
3939
name: Terraform ${{ inputs.goos }} ${{ inputs.goarch }} v${{ inputs.product-version }}
4040
steps:
41-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
41+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
42+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
4343
with:
4444
go-version: ${{ inputs.go-version }}
4545
- name: Build Terraform
@@ -86,13 +86,13 @@ jobs:
8686
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
8787
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
8888
- if: ${{ inputs.goos == 'linux' }}
89-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
89+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
9090
with:
9191
name: ${{ env.RPM_PACKAGE }}
9292
path: out/${{ env.RPM_PACKAGE }}
9393
if-no-files-found: error
9494
- if: ${{ inputs.goos == 'linux' }}
95-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
95+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
9696
with:
9797
name: ${{ env.DEB_PACKAGE }}
9898
path: out/${{ env.DEB_PACKAGE }}

.github/workflows/build.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
pkg-name: ${{ steps.get-pkg-name.outputs.pkg-name }}
3838

3939
steps:
40-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
40+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4141
- name: Get Package Name
4242
id: get-pkg-name
4343
run: |
@@ -64,7 +64,7 @@ jobs:
6464
go-version: ${{ steps.get-go-version.outputs.version }}
6565

6666
steps:
67-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
6868
- name: Determine Go version
6969
id: get-go-version
7070
uses: ./.github/actions/go-version
@@ -77,15 +77,15 @@ jobs:
7777
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
7878

7979
steps:
80-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
8181
- name: Generate package metadata
8282
id: generate-metadata-file
8383
uses: hashicorp/actions-generate-metadata@fdbc8803a0e53bcbb912ddeee3808329033d6357 # v1.1.1
8484
with:
8585
version: ${{ needs.get-product-version.outputs.product-version }}
8686
product: ${{ env.PKG_NAME }}
8787

88-
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
88+
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
8989
with:
9090
name: metadata.json
9191
path: ${{ steps.generate-metadata-file.outputs.filepath }}
@@ -139,7 +139,7 @@ jobs:
139139
repo: "terraform"
140140
version: ${{needs.get-product-version.outputs.product-version}}
141141
steps:
142-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
142+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
143143
- name: Build Docker images
144144
uses: hashicorp/actions-docker-build@11d43ef520c65f58683d048ce9b47d6617893c9a # v2
145145
with:
@@ -187,10 +187,10 @@ jobs:
187187
cache_path=internal/command/e2etest/build
188188
echo "e2e-cache-key=${cache_key}" | tee -a "${GITHUB_OUTPUT}"
189189
echo "e2e-cache-path=${cache_path}" | tee -a "${GITHUB_OUTPUT}"
190-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
190+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
191191

192192
- name: Install Go toolchain
193-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
193+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
194194
with:
195195
go-version: ${{ needs.get-go-version.outputs.go-version }}
196196

@@ -207,7 +207,7 @@ jobs:
207207
bash ./internal/command/e2etest/make-archive.sh
208208
209209
- name: Save test harness to cache
210-
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
210+
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
211211
with:
212212
path: ${{ steps.set-cache-values.outputs.e2e-cache-path }}
213213
key: ${{ steps.set-cache-values.outputs.e2e-cache-key }}_${{ matrix.goos }}_${{ matrix.goarch }}
@@ -245,9 +245,9 @@ jobs:
245245
# fresh build from source.)
246246
- name: Checkout repo
247247
if: ${{ (matrix.goos == 'linux') || (matrix.goos == 'darwin') }}
248-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
248+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
249249
- name: "Restore cache"
250-
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
250+
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
251251
id: e2etestpkg
252252
with:
253253
path: ${{ needs.e2etest-build.outputs.e2e-cache-path }}
@@ -300,7 +300,7 @@ jobs:
300300

301301
steps:
302302
- name: Install Go toolchain
303-
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
303+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
304304
with:
305305
go-version: ${{ needs.get-go-version.outputs.go-version }}
306306
- name: Download Terraform CLI package
@@ -310,7 +310,7 @@ jobs:
310310
name: terraform_${{ env.version }}_linux_amd64.zip
311311
path: .
312312
- name: Checkout terraform-exec repo
313-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
313+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
314314
with:
315315
repository: hashicorp/terraform-exec
316316
path: terraform-exec

0 commit comments

Comments
 (0)