Rename Go module #22
Workflow file for this run
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
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: Create new branch | |
run: git checkout -b "${{ env.output_branch }}" | |
- name: Commit to new branch | |
uses: planetscale/[email protected] | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
commit_message: "[AUTO] rename Go module + update internal import paths" | |
repo: ${{ github.repository }} | |
branch: ${{ env.output_branch }} | |
- 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_" |