|
| 1 | +name: Rename Go module |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + source_commit: |
| 7 | + description: 'Upstream commit on which to base module renaming' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + default: '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' |
| 11 | + |
| 12 | +jobs: |
| 13 | + rename-module: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 # everything |
| 19 | + |
| 20 | + - name: Set variables |
| 21 | + id: vars |
| 22 | + # Including hashes of both the source commit and the workflow file makes |
| 23 | + # this idempotent. |
| 24 | + env: |
| 25 | + WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }} |
| 26 | + run: | |
| 27 | + echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT"; |
| 28 | + echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \ |
| 29 | + >> "$GITHUB_OUTPUT"; |
| 30 | +
|
| 31 | + - name: Check out source commit |
| 32 | + run: git checkout ${{ inputs.source_commit }} |
| 33 | + |
| 34 | + - name: Globally update module name |
| 35 | + run: | |
| 36 | + go mod edit -module github.com/ava-labs/libevm; |
| 37 | + find . -iname '*.go' -o -iname '*.txt' | xargs sed -i -E \ |
| 38 | + 's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/libevm|g'; |
| 39 | +
|
| 40 | + - name: Remnant references |
| 41 | + run: | |
| 42 | + find . -type f | \ |
| 43 | + xargs grep -In github.com/ethereum/go-ethereum | \ |
| 44 | + grep -v "https://github.com/ethereum/go-ethereum" |
| 45 | + |
| 46 | + - name: Set up Go |
| 47 | + uses: actions/setup-go@v5 |
| 48 | + with: |
| 49 | + go-version: 1.21.4 |
| 50 | + |
| 51 | + - name: Smoke tests |
| 52 | + # `go list` shows us the module name and grep will non-zero exit on mismatch |
| 53 | + # `go build` is a rudimentary but broad test of correctness |
| 54 | + # The explicitly tested packages are edge cases: |
| 55 | + # - bind generates tests and a go.mod on the fly |
| 56 | + # - rlpgen has testdata with imports that need updating |
| 57 | + run: | |
| 58 | + go list . | grep ava-labs/libevm; |
| 59 | + go build ./...; |
| 60 | + go test ./accounts/abi/bind ./rlp/rlpgen |
| 61 | +
|
| 62 | + - name: Create new branch |
| 63 | + env: |
| 64 | + BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }} |
| 65 | + run: | |
| 66 | + git checkout -b "${BRANCH}"; |
| 67 | + git push origin "${BRANCH}"; |
| 68 | +
|
| 69 | + - name: Commit to new branch |
| 70 | + uses: planetscale/ghcommit-action@d4176bfacef926cc2db351eab20398dfc2f593b5 # v0.2.0 |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 73 | + with: |
| 74 | + commit_message: "[AUTO] rename Go module + update internal import paths\n\nWorkflow: ${{ steps.vars.outputs.WORKFLOW_HASH }} on branch ${{ github.ref_name }}" |
| 75 | + repo: ${{ github.repository }} |
| 76 | + branch: ${{ steps.vars.outputs.DEST_BRANCH }} |
0 commit comments