forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: GitHub action to rename module #51
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3015e74
feat: GitHub action to rename module
ARR4N 6be7303
fix: handle single-import statements
ARR4N 0008c43
chore: disable other workflows (DO NOT MERGE)
ARR4N b64081e
fix: regex `?` placement + force-push generated branch
ARR4N a2d0823
chore: `auto-rename-module-<COMMIT>` as generated branch
ARR4N 6ebe4e6
chore: set generated-commit message prefix
ARR4N 20ac77e
chore: smoke-test the rename via `go build`
ARR4N 2b82081
chore: title case for job step
ARR4N b832097
chore: expand `sed` match and smoke tests
ARR4N 50e3b01
chore: step to report remnant references
ARR4N a082971
feat: open PR to primary renaming branch
ARR4N 93df6d8
Merge branch 'main' into arr4n/rename-go-mod-auto
ARR4N eec97eb
chore: `ava-labs/libevm` as module name
ARR4N 5254b44
refactor: source commit from workflow input
ARR4N 831279d
fix: default source commit
ARR4N 3e3376f
fix: env var no longer referencing another
ARR4N 4c6f346
chore: full test with PR creation
ARR4N bd874cd
chore: enable workflow run on PR to actually run the test
ARR4N 420fe71
chore: ready for review
ARR4N File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Rename Go module | ||
|
||
on: | ||
# During development, the next two lines MAY be enabled to have the PR | ||
# automatically run this workflow for inspection of the resulting branch. | ||
# However, they MUST be disabled again before merging otherwise *all* PRs will | ||
# run this. | ||
# | ||
# pull_request: | ||
# branches: [ main ] | ||
workflow_dispatch: | ||
inputs: | ||
source_commit: | ||
description: 'Upstream commit on which to base module renaming' | ||
required: true | ||
type: string | ||
default: '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' | ||
|
||
jobs: | ||
rename-module: | ||
runs-on: ubuntu-latest | ||
env: | ||
source_commit: "${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}" | ||
# env variables cannot reference others so we have to duplicate the || | ||
output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }}" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # everything | ||
fetch-tags: true | ||
|
||
- name: Check out source commit | ||
run: git checkout ${{ env.source_commit }} | ||
|
||
- name: Globally update module name | ||
run: | | ||
go mod edit -module github.com/ava-labs/libevm; | ||
find . -iname '*.go' -o -iname '*.txt' | xargs sed -i -E \ | ||
's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/libevm|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: 1.21.4 | ||
|
||
- name: Smoke tests | ||
# `go list` 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 build ./...; | ||
go test ./accounts/abi/bind ./rlp/rlpgen | ||
|
||
- name: Commit to new branch | ||
uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
target_branch: ${{ env.output_branch }} | ||
force: true | ||
commit_prefix: "[AUTO] rename Go module + update internal import paths" | ||
|
||
- name: Open PR to "renamed-go-module" iff workflow dispatched on "main" | ||
# If we are changing the way in which we manage module renaming then it | ||
# MUST go through PR review to main; only then can it open PRs. | ||
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' | ||
uses: devops-infra/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
source_branch: ${{ env.output_branch }} | ||
target_branch: renamed-go-module | ||
title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" | ||
body: "_PR generated by GitHub Action_" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is it possible to use a tag or a commit here?