Skip to content

Commit 0fff08c

Browse files
committed
chore(ci): automate finding base commit
1 parent d08d0f0 commit 0fff08c

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

.github/workflows/libevm-delta.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,36 @@ on:
99

1010
jobs:
1111
diffs:
12-
env:
13-
# Last commit from rename-module workflow job to be included in `main`
14-
LIBEVM_BASE: 0b56af5a01b8a0c6fc9d60247bb79ffd03d1bcfd
1512
runs-on: ubuntu-latest
1613
steps:
1714
- uses: actions/checkout@v4
1815
with:
1916
fetch-depth: 0 # everything
2017
fetch-tags: true
2118

19+
- name: Find base commit hash
20+
id: base-commit
21+
run: echo "LIBEVM_BASE=$(.github/workflows/scripts/base-commit.sh)" >> "$GITHUB_OUTPUT"
22+
2223
- name: Color-blindness a11y
2324
run:
2425
| # https://davidmathlogic.com/colorblind/#%23D81B60-%231E88E5-%23FFC107-%23004D40:~:text=8%20pairs%20of%20contrasting%20colors
2526
git config color.diff.old "#DC3220";
2627
git config color.diff.new "#005AB5";
2728

28-
- name: git diff {LIBEVM_BASE}
29+
- name: git diff ${{ steps.base-commit.outputs.LIBEVM_BASE }}
2930
run: |
3031
git diff --diff-filter=a --word-diff --unified=0 --color=always \
31-
"${LIBEVM_BASE}" \
32+
${{ steps.base-commit.outputs.LIBEVM_BASE }} \
3233
':(exclude).golangci.yml' \
3334
':(exclude).github/**' \
3435
':(exclude)README.md';
3536
36-
- name: git diff {LIBEVM_BASE}..main
37+
- name: git diff ${{ steps.base-commit.outputs.LIBEVM_BASE }}..main
3738
run: |
3839
git checkout main --;
3940
git diff --diff-filter=a --word-diff --unified=0 --color=always \
40-
"${LIBEVM_BASE}" \
41+
"${{ steps.base-commit.outputs.LIBEVM_BASE }}" \
4142
':(exclude).golangci.yml' \
4243
':(exclude).github/**' \
4344
':(exclude)README.md';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# This script finds the base commit libevm changes should be considered from,
4+
# and returns it to the caller.
5+
# This base commit is the first child commit with its message containing
6+
# "rename Go module + update internal import paths" of the last
7+
# go-ethereum (aka geth) tag present in the main branch of libevm.
8+
# If an error occurs, this one is echo-ed and the script exits with code 1.
9+
10+
git remote add geth https://github.com/ethereum/go-ethereum.git
11+
git fetch geth 'refs/tags/*:refs/tags/*'
12+
13+
geth_tags=$(git ls-remote --tags --sort=-version:refname geth "v[1-9]*" | awk '{print $2}' | sed 's/refs\/tags\///')
14+
15+
base_geth_tag_hash=
16+
for geth_tag in $geth_tags; do
17+
geth_tag_hash="$(git rev-parse $geth_tag)"
18+
if git merge-base --is-ancestor $geth_tag_hash "origin/main"; then
19+
base_geth_tag_hash="$geth_tag_hash"
20+
break
21+
fi
22+
done
23+
24+
if [ -z "$base_geth_tag_hash" ]; then
25+
echo "No geth tag found in libevm main branch."
26+
exit 1
27+
fi
28+
29+
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}')"
30+
if [ -z "$base_commit_hash" ]; then
31+
echo "No child commit found after tag $base_geth_tag_hash on branch main."
32+
exit 1
33+
fi
34+
35+
echo $base_commit_hash | tr -d '\n'

0 commit comments

Comments
 (0)