From 3015e744cdd2a07a8b6c9fd37eb2b693c6efd309 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 14:56:07 +0100 Subject: [PATCH 01/18] feat: GitHub action to rename module --- .github/workflows/rename-module.yml | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/rename-module.yml diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml new file mode 100644 index 00000000000..87d486d42f5 --- /dev/null +++ b/.github/workflows/rename-module.yml @@ -0,0 +1,35 @@ +name: Rename Go module + +on: + push: + branches: [ libevm ] + pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN push + branches: [ libevm ] + workflow_dispatch: + +jobs: + rename-module: + strategy: + matrix: + source_commit: ["2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # everything + fetch-tags: true + + - name: check out source commit + run: git checkout ${{ matrix.source_commit }} + + - name: globally update module name + run: | + go mod edit -module github.com/ava-labs/go-ethereum; + find . -iname '*.go' | xargs sed -i -E \ + 's|^(\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; + + - name: create rename-X branch + uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + target_branch: "arr4n/rename-test" From 6be7303747a7909fb085fb559c56c1d0246bd63b Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 15:08:38 +0100 Subject: [PATCH 02/18] fix: handle single-import statements --- .github/workflows/rename-module.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 87d486d42f5..c7801d0970c 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -26,7 +26,7 @@ jobs: run: | go mod edit -module github.com/ava-labs/go-ethereum; find . -iname '*.go' | xargs sed -i -E \ - 's|^(\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; + 's|^((import?)\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; - name: create rename-X branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 From 0008c4319bfd30356893e407388f3030533236f0 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 15:09:45 +0100 Subject: [PATCH 03/18] chore: disable other workflows (DO NOT MERGE) --- .github/workflows/go.yml | 9 +++++---- .github/workflows/golangci-lint.yml | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ec48e30d725..1a58aac6140 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,10 +1,11 @@ name: Go on: - push: - branches: [ libevm ] - pull_request: - branches: [ libevm ] + # DO NOT MERGE: disabled while developing auto-renaming + # push: + # branches: [ libevm ] + # pull_request: + # branches: [ libevm ] workflow_dispatch: jobs: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index be2fc92a6c6..e063e13a817 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,10 +1,11 @@ name: golangci-lint on: - push: - branches: [ libevm ] - pull_request: - branches: [ libevm ] + # DO NOT MERGE: disabled while developing auto-renaming + # push: + # branches: [ libevm ] + # pull_request: + # branches: [ libevm ] workflow_dispatch: permissions: From b64081e17b242e64ff3740eabb8b66fe9daef5b3 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 15:17:28 +0100 Subject: [PATCH 04/18] fix: regex `?` placement + force-push generated branch --- .github/workflows/rename-module.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index c7801d0970c..8d0f6d49470 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -26,10 +26,11 @@ jobs: run: | go mod edit -module github.com/ava-labs/go-ethereum; find . -iname '*.go' | xargs sed -i -E \ - 's|^((import?)\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; + 's|^((import)?\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; - name: create rename-X branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} target_branch: "arr4n/rename-test" + force: true From a2d08233238df177855c00bf8a6a4fa318cdbc78 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 15:35:53 +0100 Subject: [PATCH 05/18] chore: `auto-rename-module-` as generated branch --- .github/workflows/rename-module.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 8d0f6d49470..017696682c5 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -28,9 +28,9 @@ jobs: find . -iname '*.go' | xargs sed -i -E \ 's|^((import)?\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; - - name: create rename-X branch + - name: commit to "auto-rename-module-${{ matrix.source_commit }}" branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} - target_branch: "arr4n/rename-test" + target_branch: "auto-rename-module-${{ matrix.source_commit }}" force: true From 6ebe4e6738c3fff1767d7e025d047395df9594b4 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 15:47:29 +0100 Subject: [PATCH 06/18] chore: set generated-commit message prefix --- .github/workflows/rename-module.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 017696682c5..43323f1353c 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -34,3 +34,4 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} target_branch: "auto-rename-module-${{ matrix.source_commit }}" force: true + commit_prefix: "[AUTO] rename Go module + update internal import paths" From 20ac77e78463b44b6487f2986a3fbf25d290364c Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 17:36:47 +0100 Subject: [PATCH 07/18] chore: smoke-test the rename via `go build` --- .github/workflows/rename-module.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 43323f1353c..ecbe19418ee 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -19,15 +19,25 @@ jobs: fetch-depth: 0 # everything fetch-tags: true - - name: check out source commit + - name: Check out source commit run: git checkout ${{ matrix.source_commit }} - - name: globally update module name + - name: Globally update module name run: | go mod edit -module github.com/ava-labs/go-ethereum; find . -iname '*.go' | xargs sed -i -E \ 's|^((import)?\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.4 + + - name: Smoke test by `go build ./...` + run: | # `go list` just demonstrates the updated module name + go list .; + go build ./... + - name: commit to "auto-rename-module-${{ matrix.source_commit }}" branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: From 2b820810e3f4dc01f2dced33e973136583390d94 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 17:38:28 +0100 Subject: [PATCH 08/18] chore: title case for job step --- .github/workflows/rename-module.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index ecbe19418ee..6a061b50f42 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -38,7 +38,7 @@ jobs: go list .; go build ./... - - name: commit to "auto-rename-module-${{ matrix.source_commit }}" branch + - name: Commit to "auto-rename-module-${{ matrix.source_commit }}" branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} From b8320978862ae2333b407a313bb905f3d2b9b710 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 18:14:23 +0100 Subject: [PATCH 09/18] chore: expand `sed` match and smoke tests --- .github/workflows/rename-module.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 6a061b50f42..4316b4e18af 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -25,18 +25,24 @@ jobs: - name: Globally update module name run: | go mod edit -module github.com/ava-labs/go-ethereum; - find . -iname '*.go' | xargs sed -i -E \ - 's|^((import)?\s.*?"github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|'; + find . -iname '*.go' -o -iname '*.txt' | xargs sed -i -E \ + 's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|g'; - name: Set up Go uses: actions/setup-go@v5 with: go-version: 1.21.4 - - name: Smoke test by `go build ./...` - run: | # `go list` just demonstrates the updated module name - go list .; - go build ./... + - name: Smoke tests + # `go list` shows us the module name + # `go build` is a rudimentary but broad test of correctness + # The explicitly tested packages are edge cases: + # - bind creates generates tests and a go.mod on the fly + # - rlpgen has testdata with imports that need updating + run: | + go list . | grep ava-labs; + go build ./...; + go test ./accounts/abi/bind ./rlp/rlpgen - name: Commit to "auto-rename-module-${{ matrix.source_commit }}" branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 From 50e3b01b76fee8579beee9b4d4dddccce4b66dad Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 8 Oct 2024 18:25:14 +0100 Subject: [PATCH 10/18] chore: step to report remnant references --- .github/workflows/rename-module.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 4316b4e18af..00e1bcc17c6 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -27,6 +27,12 @@ jobs: go mod edit -module github.com/ava-labs/go-ethereum; find . -iname '*.go' -o -iname '*.txt' | xargs sed -i -E \ 's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/go-ethereum|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 From a08297128ae270c114924cef5e96f336e9a7d516 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Thu, 10 Oct 2024 13:23:46 +0100 Subject: [PATCH 11/18] feat: open PR to primary renaming branch --- .github/workflows/rename-module.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 00e1bcc17c6..5b6d39ffec4 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -9,10 +9,9 @@ on: jobs: rename-module: - strategy: - matrix: - source_commit: ["2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1"] runs-on: ubuntu-latest + env: + source_commit: 2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1 steps: - uses: actions/checkout@v4 with: @@ -20,7 +19,7 @@ jobs: fetch-tags: true - name: Check out source commit - run: git checkout ${{ matrix.source_commit }} + run: git checkout ${{ env.source_commit }} - name: Globally update module name run: | @@ -50,10 +49,19 @@ jobs: go build ./...; go test ./accounts/abi/bind ./rlp/rlpgen - - name: Commit to "auto-rename-module-${{ matrix.source_commit }}" branch + - name: Commit to "auto-rename-module-${{ env.source_commit }}" branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} - target_branch: "auto-rename-module-${{ matrix.source_commit }}" + target_branch: "auto-rename-module-${{ env.source_commit }}" force: true commit_prefix: "[AUTO] rename Go module + update internal import paths" + + - name: Open PR to "renamed-go-module" + uses: devops-infra/action-pull-request@v0.5.5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: "auto-rename-module-${{ env.source_commit }}" + target_branch: renamed-go-module + title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" + body: "_PR generated by GitHub Action_" From eec97ebf8f5843fe251c6b6a6321a80486c8411c Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 18:37:13 +0100 Subject: [PATCH 12/18] chore: `ava-labs/libevm` as module name --- .github/workflows/rename-module.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 5b6d39ffec4..bbe00e4d5b5 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -1,10 +1,8 @@ name: Rename Go module on: - push: - branches: [ libevm ] - pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN push - branches: [ libevm ] + pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN workflow_dispatch + branches: [ main ] workflow_dispatch: jobs: @@ -23,9 +21,9 @@ jobs: - name: Globally update module name run: | - go mod edit -module github.com/ava-labs/go-ethereum; + 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/go-ethereum|g'; + 's|(["`]github\.com/)ethereum/go-ethereum|\1ava-labs/libevm|g'; - name: Remnant references run: | @@ -57,11 +55,12 @@ jobs: force: true commit_prefix: "[AUTO] rename Go module + update internal import paths" - - name: Open PR to "renamed-go-module" - uses: devops-infra/action-pull-request@v0.5.5 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - source_branch: "auto-rename-module-${{ env.source_commit }}" - target_branch: renamed-go-module - title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" - body: "_PR generated by GitHub Action_" + # DO NOT MERGE without re-enabling this. + # - name: Open PR to "renamed-go-module" + # uses: devops-infra/action-pull-request@v0.5.5 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # source_branch: "auto-rename-module-${{ env.source_commit }}" + # target_branch: renamed-go-module + # title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" + # body: "_PR generated by GitHub Action_" From 5254b44e1dab075fdf842474e8bed843192ad7be Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 20:28:09 +0100 Subject: [PATCH 13/18] refactor: source commit from workflow input --- .github/workflows/rename-module.yml | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index bbe00e4d5b5..54d9f9a6ad4 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -4,12 +4,18 @@ on: pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN workflow_dispatch 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: 2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1 + output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit }}" steps: - uses: actions/checkout@v4 with: @@ -17,7 +23,7 @@ jobs: fetch-tags: true - name: Check out source commit - run: git checkout ${{ env.source_commit }} + run: git checkout ${{ inputs.source_commit }} - name: Globally update module name run: | @@ -43,24 +49,24 @@ jobs: # - bind creates generates tests and a go.mod on the fly # - rlpgen has testdata with imports that need updating run: | - go list . | grep ava-labs; + go list . | grep ava-labs/libevm; go build ./...; go test ./accounts/abi/bind ./rlp/rlpgen - - name: Commit to "auto-rename-module-${{ env.source_commit }}" branch + - name: Commit to ${{ env.output_branch }} branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} - target_branch: "auto-rename-module-${{ env.source_commit }}" + target_branch: ${{ env.output_branch }} force: true commit_prefix: "[AUTO] rename Go module + update internal import paths" - # DO NOT MERGE without re-enabling this. - # - name: Open PR to "renamed-go-module" - # uses: devops-infra/action-pull-request@v0.5.5 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # source_branch: "auto-rename-module-${{ env.source_commit }}" - # target_branch: renamed-go-module - # title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" - # body: "_PR generated by GitHub Action_" + - name: Open PR to "renamed-go-module" iff workflow dispatched on "main" + # if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' + uses: devops-infra/action-pull-request@v0.5.5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: ${{ env.output_branch }} + target_branch: renamed-go-module + title: "[AUTO] Rename upstream Go module at `${{ inputs.source_commit }}`" + body: "_PR generated by GitHub Action_" From 831279df4f14e8e67128e2f65d206be1468a0e4e Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 20:36:55 +0100 Subject: [PATCH 14/18] fix: default source commit --- .github/workflows/rename-module.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 54d9f9a6ad4..379f7fceba8 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -9,21 +9,22 @@ on: description: 'Upstream commit on which to base module renaming' required: true type: string - default: '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' + default: '' jobs: rename-module: runs-on: ubuntu-latest env: - output_branch: "${{ github.ref_name }}_auto-rename-module-${{ inputs.source_commit }}" + source_commit: ${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }} + output_branch: "${{ github.ref_name }}_auto-rename-module-${{ env.source_commit }}" steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # everything fetch-tags: true - - name: Check out source commit - run: git checkout ${{ inputs.source_commit }} + - name: Check out source commit `{{ $env.source_commit }}` + run: git checkout ${{ env.source_commit }} - name: Globally update module name run: | @@ -62,11 +63,11 @@ jobs: commit_prefix: "[AUTO] rename Go module + update internal import paths" - name: Open PR to "renamed-go-module" iff workflow dispatched on "main" - # if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' + if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' uses: devops-infra/action-pull-request@v0.5.5 with: github_token: ${{ secrets.GITHUB_TOKEN }} source_branch: ${{ env.output_branch }} target_branch: renamed-go-module - title: "[AUTO] Rename upstream Go module at `${{ inputs.source_commit }}`" + title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" body: "_PR generated by GitHub Action_" From 3e3376fa07cd9d84cd141287217f3c9df8f5c0e7 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 20:41:43 +0100 Subject: [PATCH 15/18] fix: env var no longer referencing another --- .github/workflows/rename-module.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 379f7fceba8..f727983ee5f 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -15,8 +15,9 @@ jobs: rename-module: runs-on: ubuntu-latest env: - source_commit: ${{ inputs.source_commit || '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' }} - output_branch: "${{ github.ref_name }}_auto-rename-module-${{ env.source_commit }}" + 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: From 4c6f3467a2b630fd98455771f810237eab31cdf8 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 20:50:56 +0100 Subject: [PATCH 16/18] chore: full test with PR creation --- .github/workflows/rename-module.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index f727983ee5f..6c5d402d4b0 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -1,15 +1,20 @@ name: Rename Go module on: - pull_request: # DO NOT MERGE WITH ANYTHING OTHER THAN workflow_dispatch - branches: [ main ] + # 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: '' + default: '2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1' jobs: rename-module: @@ -24,7 +29,7 @@ jobs: fetch-depth: 0 # everything fetch-tags: true - - name: Check out source commit `{{ $env.source_commit }}` + - name: Check out source commit run: git checkout ${{ env.source_commit }} - name: Globally update module name @@ -45,17 +50,17 @@ jobs: go-version: 1.21.4 - name: Smoke tests - # `go list` shows us the module name + # `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 creates generates tests and a go.mod on the fly + # - 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 ${{ env.output_branch }} branch + - name: Commit to new branch uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -64,7 +69,9 @@ jobs: commit_prefix: "[AUTO] rename Go module + update internal import paths" - name: Open PR to "renamed-go-module" iff workflow dispatched on "main" - if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/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/action-pull-request@v0.5.5 with: github_token: ${{ secrets.GITHUB_TOKEN }} From bd874cdd864b51a3321bdfe0ca347ced45a972f9 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 20:52:11 +0100 Subject: [PATCH 17/18] chore: enable workflow run on PR to actually run the test --- .github/workflows/rename-module.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 6c5d402d4b0..49ce5ce14fb 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -6,8 +6,8 @@ on: # However, they MUST be disabled again before merging otherwise *all* PRs will # run this. # - # pull_request: - # branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: inputs: source_commit: From 420fe71b28ce3055dd21f2768c6d5f2c3c983d4f Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Fri, 11 Oct 2024 21:00:29 +0100 Subject: [PATCH 18/18] chore: ready for review --- .github/workflows/go.yml | 9 ++++----- .github/workflows/golangci-lint.yml | 9 ++++----- .github/workflows/rename-module.yml | 6 +++--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1c4efd9734a..e79c211a426 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,11 +1,10 @@ name: Go on: - # DO NOT MERGE: disabled while developing auto-renaming - # push: - # branches: [ main ] - # pull_request: - # branches: [ main ] + push: + branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: jobs: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index f7e6d197b08..e35d21d843d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,11 +1,10 @@ name: golangci-lint on: - # DO NOT MERGE: disabled while developing auto-renaming - # push: - # branches: [ main ] - # pull_request: - # branches: [ main ] + push: + branches: [ main ] + pull_request: + branches: [ main ] workflow_dispatch: permissions: diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index 49ce5ce14fb..a197cca7ab6 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -6,8 +6,8 @@ on: # However, they MUST be disabled again before merging otherwise *all* PRs will # run this. # - pull_request: - branches: [ main ] + # pull_request: + # branches: [ main ] workflow_dispatch: inputs: source_commit: @@ -71,7 +71,7 @@ jobs: - 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' + if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' uses: devops-infra/action-pull-request@v0.5.5 with: github_token: ${{ secrets.GITHUB_TOKEN }}