Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/libevm-delta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,36 @@ on:

jobs:
diffs:
env:
# Last commit from rename-module workflow job to be included in `main`
LIBEVM_BASE: 0b56af5a01b8a0c6fc9d60247bb79ffd03d1bcfd
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # everything
fetch-tags: true

- name: Find base commit hash
id: base-commit
run: echo "LIBEVM_BASE=$(.github/workflows/scripts/base-commit.sh)" >> "$GITHUB_OUTPUT"

- name: Color-blindness a11y
run:
| # https://davidmathlogic.com/colorblind/#%23D81B60-%231E88E5-%23FFC107-%23004D40:~:text=8%20pairs%20of%20contrasting%20colors
git config color.diff.old "#DC3220";
git config color.diff.new "#005AB5";

- name: git diff {LIBEVM_BASE}
- name: git diff ${{ steps.base-commit.outputs.LIBEVM_BASE }}
run: |
git diff --diff-filter=a --word-diff --unified=0 --color=always \
"${LIBEVM_BASE}" \
${{ steps.base-commit.outputs.LIBEVM_BASE }} \
':(exclude).golangci.yml' \
':(exclude).github/**' \
':(exclude)README.md';

- name: git diff {LIBEVM_BASE}..main
- name: git diff ${{ steps.base-commit.outputs.LIBEVM_BASE }}..main
run: |
git checkout main --;
git diff --diff-filter=a --word-diff --unified=0 --color=always \
"${LIBEVM_BASE}" \
"${{ steps.base-commit.outputs.LIBEVM_BASE }}" \
':(exclude).golangci.yml' \
':(exclude).github/**' \
':(exclude)README.md';
14 changes: 6 additions & 8 deletions .github/workflows/rename-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ name: Rename Go module

on:
workflow_dispatch:
inputs:
source_commit:
description: "Upstream commit on which to base module renaming"
required: true
type: string
default: "2bd6bd01d2e8561dd7fc21b631f4a34ac16627a1"

jobs:
rename-module:
Expand All @@ -17,6 +11,10 @@ jobs:
with:
fetch-depth: 0 # everything

- name: Find base geth commit hash
id: geth-commit
run: echo "hash=$(.github/workflows/scripts/geth-commit.sh)" >> "$GITHUB_OUTPUT"

- name: Set variables
id: vars
# Including hashes of both the source commit and the workflow file makes
Expand All @@ -25,11 +23,11 @@ jobs:
WORKFLOW_HASH: ${{ hashFiles('.github/workflows/rename-module.yml') }}
run: |
echo "WORKFLOW_HASH=${WORKFLOW_HASH}" >> "$GITHUB_OUTPUT";
echo "DEST_BRANCH=auto-rename-module_source-${{ inputs.source_commit }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
echo "DEST_BRANCH=auto-rename-module_source-${{ steps.geth-commit.outputs.hash }}_workflow-${WORKFLOW_HASH}-${{ github.ref_name }}" \
>> "$GITHUB_OUTPUT";

- name: Check out source commit
run: git checkout ${{ inputs.source_commit }}
run: git checkout ${{ steps.geth-commit.outputs.hash }}

- name: Globally update module name
run: |
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/scripts/base-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# This script finds the base commit libevm changes should be considered from,
# and returns it to the caller.
# This base commit is the first child commit with its message containing
# "rename Go module + update internal import paths" of the last
# go-ethereum (aka geth) tag present in the main branch of libevm.
# If an error occurs, this one is echo-ed and the script exits with code 1.


base_geth_tag_hash="$($(dirname "$0")/geth-commit.sh)"

base_commit_hash="$(git log --oneline --grep="rename Go module + update internal import paths" --after "$base_geth_tag_hash" -n 1 origin/main | head -n 1 | awk '{print $1}')"
if [ -z "$base_commit_hash" ]; then
echo "No child commit found after tag $base_geth_tag_hash on branch main."
exit 1
fi

echo $base_commit_hash | tr -d '\n'
26 changes: 26 additions & 0 deletions .github/workflows/scripts/geth-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# This script finds the base commit corresponding to a geth tag
# from which libevm was last based on, and returns it to the caller.
# If an error occurs, this one is echo-ed and the script exits with code 1.

git remote add geth https://github.com/ethereum/go-ethereum.git
git fetch geth 'refs/tags/*:refs/tags/*'

geth_tags=$(git ls-remote --tags --sort=-version:refname geth "v[1-9]*" | awk '{print $2}' | sed 's/refs\/tags\///')

base_geth_tag_hash=
for geth_tag in $geth_tags; do
geth_tag_hash="$(git rev-parse --short $geth_tag)"
if git merge-base --is-ancestor $geth_tag_hash "origin/main"; then
base_geth_tag_hash="$geth_tag_hash"
break
fi
done

if [ -z "$base_geth_tag_hash" ]; then
echo "No geth tag found in libevm main branch."
exit 1
fi

echo $base_geth_tag_hash | tr -d '\n'
Loading