-
Notifications
You must be signed in to change notification settings - Fork 3
chore: module-renaming workflow inverts between libevm
and geth
#152
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -3,11 +3,15 @@ name: Rename Go module | |||||||
on: | ||||||||
workflow_dispatch: | ||||||||
inputs: | ||||||||
source_commit: | ||||||||
description: "Upstream commit on which to base module renaming" | ||||||||
source: | ||||||||
description: "Reference or commit on which to base module renaming" | ||||||||
required: true | ||||||||
type: string | ||||||||
default: "2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1" | ||||||||
default: "main" | ||||||||
branch: | ||||||||
description: "Branch to which a commit of the changes is pushed; leave blank for auto-naming. If non-existent, the branch is created." | ||||||||
type: string | ||||||||
default: "" | ||||||||
|
||||||||
jobs: | ||||||||
rename-module: | ||||||||
|
@@ -17,71 +21,96 @@ jobs: | |||||||
with: | ||||||||
fetch-depth: 0 # everything | ||||||||
|
||||||||
- run: git fetch --tags https://github.com/ethereum/go-ethereum.git | ||||||||
|
||||||||
- run: git checkout ${{ inputs.source }} | ||||||||
|
||||||||
- name: References pointing to source | ||||||||
# NOTE: This step assumes that the source has been checked out, which | ||||||||
# might not hold if reordered. | ||||||||
run: | | ||||||||
git branch --points-at HEAD; | ||||||||
git tag --points-at HEAD; | ||||||||
|
||||||||
- name: Set up Go | ||||||||
uses: actions/setup-go@v5 | ||||||||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit the action name is self explanatory I think
Suggested change
|
||||||||
with: | ||||||||
go-version-file: "go.mod" | ||||||||
|
||||||||
- name: Detect Go module | ||||||||
id: go | ||||||||
run: | | ||||||||
echo "MODULE=$(go list -m)" >> "$GITHUB_OUTPUT"; | ||||||||
echo "MODULE_SUFFIX=$(go list -m | cut -b 12-)" >> "$GITHUB_OUTPUT"; # Strip github.com/ | ||||||||
|
||||||||
- name: Validate Go module | ||||||||
if: ${{ steps.go.outputs.MODULE != 'github.com/ava-labs/libevm' && steps.go.outputs.MODULE != 'github.com/ethereum/go-ethereum' }} | ||||||||
run: echo "Unexpected Go module ${{ steps.go.outputs.MODULE }}" && exit 1; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. supernit let's exit even if echo fails, no point having
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||||||||
|
||||||||
- name: Set variables | ||||||||
id: vars | ||||||||
# Including hashes of both the source commit and the workflow file makes | ||||||||
# this idempotent. | ||||||||
env: | ||||||||
WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }} | ||||||||
RENAME_TO: ${{ steps.go.outputs.MODULE_SUFFIX == 'ava-labs/libevm' && 'ethereum/go-ethereum' || 'ava-labs/libevm' }} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this expression mean, I am rather confused 😄
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment in the code. |
||||||||
run: | | ||||||||
echo "RENAME_FROM=${{ steps.go.outputs.MODULE_SUFFIX}}" >> "$GITHUB_OUTPUT"; | ||||||||
echo "RENAME_TO=${RENAME_TO}" >> "$GITHUB_OUTPUT"; | ||||||||
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT"; | ||||||||
echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \ | ||||||||
echo "SOURCE_COMMIT=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"; | ||||||||
echo "AUTO_BRANCH_NAME=auto/rename-module/to=${RENAME_TO}/src=$(git rev-parse HEAD)/workflow_sha=${{ github.workflow_sha }}/run=${{ github.run_id }}" \ | ||||||||
>> "$GITHUB_OUTPUT"; | ||||||||
|
||||||||
- name: Fetch tags from ethereum/go-ethereum | ||||||||
run: git fetch --tags https://github.com/ethereum/go-ethereum.git | ||||||||
|
||||||||
- name: Tags pointing to source commit | ||||||||
run: git tag --points-at ${{ inputs.source_commit }} | ||||||||
|
||||||||
- name: Check out source commit | ||||||||
run: git checkout ${{ inputs.source_commit }} | ||||||||
|
||||||||
- name: Globally update module name | ||||||||
- name: Globally rename module from ${{ steps.vars.outputs.RENAME_FROM }} to ${{ steps.vars.outputs.RENAME_TO }} | ||||||||
run: | | ||||||||
go mod edit -module github.com/ava-labs/libevm; | ||||||||
go mod edit -module github.com/${{ steps.vars.outputs.RENAME_TO }}; | ||||||||
find . \ | ||||||||
-iname '*.go' \ | ||||||||
-o -iname '*.txt' \ | ||||||||
-o -iname '*.go.tpl' \ | ||||||||
-o -iname '*.proto' | xargs \ | ||||||||
sed -i -E 's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/libevm|g'; | ||||||||
-o -iname '*.proto' \ | ||||||||
-not -wholename '*/libevm/tooling/*' | xargs \ | ||||||||
sed -i -E 's|(["`]github\.com/)${{ steps.vars.outputs.RENAME_FROM }}|\1${{ steps.vars.outputs.RENAME_TO }}|g'; | ||||||||
|
||||||||
- name: Remnant references | ||||||||
run: | | ||||||||
find . -type f | \ | ||||||||
xargs grep -In github.com/ethereum/go-ethereum | \ | ||||||||
grep -v "https://github.com/ethereum/go-ethereum" | ||||||||
|
||||||||
- name: Set up Go | ||||||||
uses: actions/setup-go@v5 | ||||||||
with: | ||||||||
go-version-file: "go.mod" | ||||||||
xargs grep -In github.com/${{ steps.vars.outputs.RENAME_FROM }} | \ | ||||||||
grep -v "https://github.com/${{ steps.vars.outputs.RENAME_FROM }}" | ||||||||
|
||||||||
- name: Smoke tests | ||||||||
# `go list` shows us the module name and grep will non-zero exit on mismatch | ||||||||
# `go list -m` shows us the module name and grep will non-zero exit on mismatch | ||||||||
# `go build` is a rudimentary but broad test of correctness | ||||||||
# The explicitly tested packages are edge cases: | ||||||||
# - bind generates tests and a go.mod on the fly | ||||||||
# - rlpgen has testdata with imports that need updating | ||||||||
run: | | ||||||||
go list . | grep ava-labs/libevm; | ||||||||
go list -m | grep github.com/${{ steps.vars.outputs.RENAME_TO }}; | ||||||||
go build ./...; | ||||||||
go test ./accounts/abi/bind ./rlp/rlpgen | ||||||||
|
||||||||
- name: Create new branch | ||||||||
- name: Set branch name | ||||||||
id: branch | ||||||||
env: | ||||||||
BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }} | ||||||||
BRANCH: ${{ inputs.branch || steps.vars.outputs.AUTO_BRANCH_NAME }} | ||||||||
run: echo "NAME=${BRANCH}" >> "$GITHUB_OUTPUT"; | ||||||||
|
||||||||
- name: Check out branch (create if non-existent) | ||||||||
env: | ||||||||
BRANCH: ${{ steps.branch.outputs.NAME }} | ||||||||
run: | | ||||||||
git checkout -b "${BRANCH}"; | ||||||||
git push origin "${BRANCH}"; | ||||||||
git checkout "${BRANCH}" 2>/dev/null || \ | ||||||||
(git checkout -b "${BRANCH}" && git push origin "${BRANCH}"); | ||||||||
|
||||||||
- name: Commit to new branch | ||||||||
- name: Commit to branch | ||||||||
uses: planetscale/ghcommit-action@d4176bfacef926cc2db351eab20398dfc2f593b5 # v0.2.0 | ||||||||
env: | ||||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||||||||
with: | ||||||||
# WARNING: mirror any change to the commit_message value below in libevm-delta.yml | ||||||||
commit_message: "[AUTO] rename Go module + update internal import paths\n\nWorkflow: ${{ steps.vars.outputs.WORKFLOW_HASH }} on branch ${{ github.ref_name }}" | ||||||||
commit_message: | | ||||||||
[AUTO] rename Go module to ${{ steps.vars.outputs.RENAME_TO }} | ||||||||
|
||||||||
Source: ${{ steps.vars.outputs.SOURCE_COMMIT }} (${{ inputs.source }}) | ||||||||
Workflow: ${{ github.workflow_sha }} (${{ github.workflow_ref }}) | ||||||||
Run ID: ${{ github.run_id }} | ||||||||
repo: ${{ github.repository }} | ||||||||
branch: ${{ steps.vars.outputs.DEST_BRANCH }} | ||||||||
branch: ${{ steps.branch.outputs.NAME }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supernit I don't think semi colons are necessary