Skip to content

Commit

Permalink
Merge pull request #50 from ethereum-optimism/tip/check-optimism-vers…
Browse files Browse the repository at this point in the history
…ion-match

Check optimism version match
  • Loading branch information
ImTei authored Apr 16, 2024
2 parents ef861cc + a1f831e commit e58103c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/scripts/check_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

module_name="github.com/ethereum-optimism/optimism"
submodule_path="rvsol/lib/optimism"

# Fetch the version from go.mod
go_list_version=$(go list -m -f '{{.Version}}' $module_name)
echo "Version in go.mod: $go_list_version"

# Go to the submodule directory and get the full commit hash
cd $submodule_path
submodule_version=$(git rev-parse HEAD)
echo "Submodule commit: $submodule_version"
cd ..

# Extract the commit hash from the go_list_version
# This regex assumes the hash is always after the last hyphen, which is typical for pseudo-versions
go_list_commit=$(echo $go_list_version | sed 's/.*-//')

# Check if go_list_commit is empty or not
if [ -z "$go_list_commit" ]; then
echo "Error: Extracted commit hash is empty."
exit 1
fi

# Ensure that the submodule version is compared properly by extracting only the necessary part
# Adjust the length of submodule_version to match the length of go_list_commit for comparison
length=${#go_list_commit}
if [ $length -eq 0 ]; then
echo "Error: Length of the extracted commit hash is zero."
exit 1
fi
submodule_commit_part=$(echo $submodule_version | cut -c 1-$length)

# Compare the two commit parts
if [ "$go_list_commit" == "$submodule_commit_part" ]; then
echo "Versions match."
else
echo "Versions do not match."
exit 1
fi
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
version: latest

check-optimism-version-match:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Submodule update
run: git submodule update --init
- name: Install Golang
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- name: Check if optimism submodule version matches go.mod version
run: ./.github/scripts/check_versions.sh

0 comments on commit e58103c

Please sign in to comment.