2023-08-25 06:06:29 -05:00
|
|
|
# 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:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
compare:
|
|
|
|
name: Compare
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-05-07 11:25:30 -05:00
|
|
|
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-08-25 06:06:29 -05:00
|
|
|
|
2024-03-11 09:00:06 -05:00
|
|
|
|
2023-08-25 06:06:29 -05:00
|
|
|
- name: Install Go
|
2024-05-13 08:00:18 -05:00
|
|
|
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
|
2024-03-11 09:00:06 -05:00
|
|
|
with: { go-version: '1.21.3' }
|
2023-08-25 06:06:29 -05:00
|
|
|
|
|
|
|
- name: Get the equivalence test binary
|
|
|
|
run: |
|
|
|
|
./.github/scripts/equivalence-test.sh download_equivalence_test_binary \
|
2023-09-06 09:35:38 -05:00
|
|
|
0.4.0 \
|
|
|
|
./bin/equivalence-testing \
|
2023-08-25 06:06:29 -05:00
|
|
|
linux \
|
|
|
|
amd64
|
|
|
|
|
2023-09-21 07:27:16 -05:00
|
|
|
- name: Build the OpenTofu binary
|
2023-08-25 06:06:29 -05:00
|
|
|
run: |
|
2023-09-27 07:37:55 -05:00
|
|
|
go build -o ./bin/tofu ./cmd/tofu
|
2023-08-25 06:06:29 -05:00
|
|
|
|
|
|
|
- name: Run the equivalence tests
|
|
|
|
run: |
|
2023-09-06 09:35:38 -05:00
|
|
|
./bin/equivalence-testing update \
|
2023-08-25 06:06:29 -05:00
|
|
|
--tests=testing/equivalence-tests/tests \
|
|
|
|
--goldens=testing/equivalence-tests/outputs \
|
2023-09-06 09:35:38 -05:00
|
|
|
--rewrites=testing/rewrites.jsonc \
|
2023-09-21 07:27:16 -05:00
|
|
|
--binary=./bin/tofu \
|
2023-08-28 05:07:46 -05:00
|
|
|
|
2023-08-25 06:06:29 -05:00
|
|
|
- name: Ensure there is no diff
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
changed=$(git diff --quiet -- testing/equivalence-tests/outputs || echo true)
|
2023-08-28 06:12:07 -05:00
|
|
|
if [[ "$changed" == "true" ]]; then
|
2023-08-25 06:06:29 -05:00
|
|
|
echo "Found changes, please commit the new golden files."
|
|
|
|
git diff -- testing/equivalence-tests/outputs
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Found no changes."
|
|
|
|
fi
|