Skip to content

Commit

Permalink
.github/workflows: .github/workflows: .github/workflows: go-generate-…
Browse files Browse the repository at this point in the history
…check changed logic for whitelisting changes in generated files directly

The intention of this commit is to not break/change the logic for developers when coding.
This script serves as a warning notification if a developer forgets to generate those files using gencodec.

On specific cases where generated files are modified, we revert the modifications and compare the files so as they will show up any changes in the original files.

The developer then will find out the correct way to resolve generating the new files and keeping the modifications intact if needed.
  • Loading branch information
ziogaschr committed Jan 13, 2023
1 parent 633eae8 commit 8bb00d0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/go-generate-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ env:
# https://github.com/ethereum/go-ethereum/blob/master/accounts/usbwallet/trezor/trezor.go#L21-L43
GENERATE_EXCEPTIONS: |
trezor
# GENERATE_IGNORES are applied after the 'go generate' command.
# These files will be reverted after 'go generate' to their original ref version.
#
# - gen_genesis.go: file which has custom modifications for unmarshaling the various genesis formats
GENERATE_IGNORES: |
params/types/genesisT/gen_genesis.go
jobs:
go-generate-check:
name: Check if "go generate" has been run
Expand All @@ -25,7 +19,9 @@ jobs:
with:
go-version: ^1.16
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install deps
id: install-deps
run: |
Expand All @@ -46,10 +42,17 @@ jobs:
list="$(grep -v "$pattern" <<< "$list")"
done
go generate "$list"
- name: Skip whitelisted generated go files
id: skip-files
- name: Revert custom generated files modifications before comparing them
id: revert-custom-generated-modifications
run: |
git checkout -- ${GENERATE_IGNORES[@]}
# NOTE to developers checking what triggered this alert.
# This script is meant to alert you if some files have to be regenerated using `go generate`.
# If this happens, you have to run `go generate ./...` and then check the below commits that are being reverted and reapply them, after considering if they are needed.
# Intentionally revert this commit which has a custom modification to the genesis unmarshaling,
# with regards reading different genesis formats origniating from different clients
# This way, this script can alert us on any code changes that have to be applied on if file gets changed.
git revert --no-edit 4b2cf83737ffe7c46c334a11414d151de049e0b3
- name: Check for modified files
id: git-check
Expand Down

0 comments on commit 8bb00d0

Please sign in to comment.