Skip to content

Commit 9a48b9c

Browse files
committed
.github/workflows: .github/workflows: .github/workflows: .github/workflows: go-generate-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.
1 parent 633eae8 commit 9a48b9c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

.github/workflows/go-generate-check.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ env:
88
# https://github.com/ethereum/go-ethereum/blob/master/accounts/usbwallet/trezor/trezor.go#L21-L43
99
GENERATE_EXCEPTIONS: |
1010
trezor
11-
# GENERATE_IGNORES are applied after the 'go generate' command.
12-
# These files will be reverted after 'go generate' to their original ref version.
13-
#
14-
# - gen_genesis.go: file which has custom modifications for unmarshaling the various genesis formats
15-
GENERATE_IGNORES: |
16-
params/types/genesisT/gen_genesis.go
1711
jobs:
1812
go-generate-check:
1913
name: Check if "go generate" has been run
@@ -25,7 +19,9 @@ jobs:
2519
with:
2620
go-version: ^1.16
2721
- name: Check out code into the Go module directory
28-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
2925
- name: Install deps
3026
id: install-deps
3127
run: |
@@ -46,10 +42,20 @@ jobs:
4642
list="$(grep -v "$pattern" <<< "$list")"
4743
done
4844
go generate "$list"
49-
- name: Skip whitelisted generated go files
50-
id: skip-files
45+
- name: Revert custom generated files modifications before comparing them
46+
id: revert-custom-generated-modifications
5147
run: |
52-
git checkout -- ${GENERATE_IGNORES[@]}
48+
# NOTE to developers checking what triggered this alert.
49+
# This script is meant to alert you if some files have to be regenerated using `go generate`.
50+
# 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.
51+
52+
git config user.name github-actions
53+
git config user.email [email protected]
54+
55+
# Intentionally revert this commit which has a custom modification to the genesis unmarshaling,
56+
# with regards reading different genesis formats origniating from different clients
57+
# This way, this script can alert us on any code changes that have to be applied on if file gets changed.
58+
git revert --no-edit 4b2cf83737ffe7c46c334a11414d151de049e0b3
5359
5460
- name: Check for modified files
5561
id: git-check

0 commit comments

Comments
 (0)