Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix equivalence test actions #36023

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/actions/equivalence-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ runs:
if: steps.execute.outputs.changed == 'true'
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "Team Terraform"
git checkout -b ${{ inputs.new-branch }}
git add testing/equivalence-tests/outputs
git commit -m "Update equivalence test golden files."
Expand All @@ -71,5 +73,5 @@ runs:
--base ${{ inputs.current-branch }} \
--head ${{ inputs.new-branch }} \
--title "Update equivalence test golden files" \
--body "This PR updates the equivalence test golden files." \
--body "{{ inputs.message }}" \
--reviewer ${{ inputs.reviewers }}
10 changes: 6 additions & 4 deletions .github/workflows/equivalence-test-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- synchronize
- ready_for_review
- reopened
- synchronize

permissions:
contents: read
pull-requests: write

env:
GH_TOKEN: ${{ github.token }}

jobs:
equivalence-test-diff:
name: "Equivalence Test Diff"
Expand All @@ -35,7 +37,7 @@ jobs:
shell: bash
run: |
./.github/scripts/equivalence-test.sh download_equivalence_test_binary \
0.3.0 \
0.4.0 \
./bin/equivalence-tests \
linux \
amd64
Expand All @@ -59,12 +61,12 @@ jobs:
shell: bash
run: |
gh pr comment ${{ github.event.pull_request.number }} \
--body "The equivalence tests failed. Please investigate [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }})."
--body "The equivalence tests failed. Please investigate [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
exit 1 # fail the job

- name: Equivalence tests changed
if: steps.equivalence-tests.outputs.exit-code == 2 # 2 is the exit code for changed
shell: bash
run: |
gh pr comment ${{ github.event.pull_request.number }} \
--body "The equivalence tests will be updated. Please verify the changes [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }})."
--body "The equivalence tests will be updated. Please verify the changes [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
7 changes: 5 additions & 2 deletions .github/workflows/equivalence-test-manual-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ on:
required: true
equivalence-test-version:
type: string
description: 'Equivalence testing framework version to use (no v prefix, eg. 0.3.0).'
default: "0.3.0"
description: 'Equivalence testing framework version to use (no v prefix, eg. 0.4.0).'
default: "0.4.0"
required: true

permissions:
contents: write
pull-requests: write

env:
GH_TOKEN: ${{ github.token }}

jobs:
run-equivalence-tests:
name: "Run equivalence tests"
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/equivalence-test-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ permissions:
contents: write
pull-requests: write

env:
GH_TOKEN: ${{ github.token }}

jobs:
check:
name: "Should run equivalence tests?"
Expand All @@ -18,14 +21,14 @@ jobs:
- name: target_branch
id: target_branch
run: |
merged = ${{ github.event.pull_request.merged }}
target_branch = ${{ github.event.pull_request.base.ref }}
merged="${{ github.event.pull_request.merged }}"
target_branch="${{ github.event.pull_request.base.ref }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_branch="${{ github.event.pull_request.base.ref }}"
target_branch='${{ github.event.pull_request.base.ref }}'

I think this is slightly safer as it disallows interpolation, so that in case the ref contained some special characters, like $() then it won't have any special meaning if it's enclosed in ' rather than ". The only special character then becomes just '.

Hopefully GitHub disallows branch names with special characters anyway but better safe than sorry.


targets_release_branch = false
targets_release_branch=false
if [ "$target_branch" == "main" ]; then
targets_release_branch = true
targets_release_branch=true
elif [ "$target_branch" =~ ^v[0-9]+\.[0-9]+$ ]; then
targets_release_branch = true
targets_release_branch=true
fi

should_run=false
Expand Down Expand Up @@ -57,7 +60,7 @@ jobs:

- uses: ./.github/actions/equivalence-test
with:
target-equivalence-test-version: ${{ inputs.equivalence-test-version }}
target-equivalence-test-version: 0.4.0
target-os: linux
target-arch: amd64
current-branch: ${{ github.event.pull_request.base.ref }}
Expand Down
Loading