Files
opentf/.github/workflows/compare-snapshots.yml
Martin Atkins 85e8e539d8 GitHub ACtions: use actions/setup-go v6.4.0
The version we were previously using has an incorrect hard-coded URL
template for downloading Go versions that are not yet in the action's own
manifest file, which means that it can't successfully install any Go
version that hasn't been added to the manifest yet.

This new version is updated to use an endpoint on https://go.dev/ that is
set up to redirect to whatever the correct location is, which was
recommended by a member of the Go team in actions/setup-go#665 and so is
presumably intended to remain valid.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2026-04-07 14:15:03 -07:00

78 lines
2.4 KiB
YAML

# This workflow runs on pull requests to ensure that the snapshots produced by
# the equivalence tests are consistent with the snapshots that are checked in.
#
# If there is an inconsistency, it is the responsibility of the committer to
# review it, ensure that any changes are intentional, and then commit the new
# snapshots.
name: Snapshots
on:
pull_request:
permissions:
contents: read
jobs:
fileschanged:
name: List files changed for pull request
runs-on: ubuntu-latest
steps:
- name: "Fetch source code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: diff
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
echo "Comparing to base_ref $BASE_REF"
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin "$BASE_REF"
echo "go=$(git diff --name-only origin/"$BASE_REF" | grep '\.go' | wc -l)" | tee -a "$GITHUB_OUTPUT"
outputs:
go: ${{ steps.diff.outputs.go }}
compare:
name: Compare
runs-on: ubuntu-latest
needs: fileschanged
if: ${{ needs.fileschanged.outputs.go != 0}}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: 'go.mod'
- name: Get the equivalence test binary
run: |
./.github/scripts/equivalence-test.sh download_equivalence_test_binary \
0.4.0 \
./bin/equivalence-testing \
linux \
amd64
- name: Build the OpenTofu binary
run: |
go build -o ./bin/tofu ./cmd/tofu
- name: Run the equivalence tests
run: |
./bin/equivalence-testing update \
--tests=testing/equivalence-tests/tests \
--goldens=testing/equivalence-tests/outputs \
--rewrites=testing/rewrites.jsonc \
--binary=./bin/tofu \
- name: Ensure there is no diff
shell: bash
run: |
changed=$(git diff --quiet -- testing/equivalence-tests/outputs || echo true)
if [[ "$changed" == "true" ]]; then
echo "Found changes, please commit the new golden files."
git diff -- testing/equivalence-tests/outputs
exit 1
else
echo "Found no changes."
fi