From ee74645e9f1e544d164dc7c3414919641f184133 Mon Sep 17 00:00:00 2001 From: Arran Schlosberg Date: Tue, 15 Oct 2024 22:30:29 +0100 Subject: [PATCH] feat: signed commit when renaming upstream module --- .github/workflows/rename-module.yml | 58 ++++++++++++++++++----------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/rename-module.yml b/.github/workflows/rename-module.yml index b2ccc20714b4..2b4407fb4e27 100644 --- a/.github/workflows/rename-module.yml +++ b/.github/workflows/rename-module.yml @@ -21,14 +21,22 @@ jobs: 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: 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') }} + run: | + echo "DEST_BRANCH=auto-rename-module_source-${{ env.source_commit }}_workflow-${WORKFLOW_HASH}" \ + >> "$GITHUB_OUTPUT"; + - name: Check out source commit run: git checkout ${{ env.source_commit }} @@ -44,29 +52,37 @@ jobs: 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: 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 + # - 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 + env: + BRANCH: ${{ steps.vars.outputs.DEST_BRANCH }} run: | - go list . | grep ava-labs/libevm; - go build ./...; - go test ./accounts/abi/bind ./rlp/rlpgen + git checkout -b "${BRANCH}"; + git push origin "${BRANCH}"; - name: Commit to new branch - uses: devops-infra/action-commit-push@8bc2ff9f9de7aa2a7581fc7e5b6401c04cab54c7 + uses: planetscale/ghcommit-action@v0.2.0 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} with: - github_token: ${{ secrets.GITHUB_TOKEN }} - target_branch: ${{ env.output_branch }} - force: true - commit_prefix: "[AUTO] rename Go module + update internal import paths" + commit_message: "[AUTO] rename Go module + update internal import paths" + repo: ${{ github.repository }} + branch: ${{ steps.vars.outputs.DEST_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 @@ -75,7 +91,7 @@ jobs: uses: devops-infra/action-pull-request@v0.5.5 with: github_token: ${{ secrets.GITHUB_TOKEN }} - source_branch: ${{ env.output_branch }} + source_branch: ${{ steps.vars.outputs.DEST_BRANCH }} target_branch: renamed-go-module title: "[AUTO] Rename upstream Go module at `${{ env.source_commit }}`" body: "_PR generated by GitHub Action_"