Skip to content

Commit

Permalink
Add celo-org/op-geth dependencies update script and gh-action (#263)
Browse files Browse the repository at this point in the history
* Add script to update `celo-org/op-geth` dependencies

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Add github action for update-geth script

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Use inline geth base-ref

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Discard automatic fields

Signed-off-by: Maximilian Langenfeld <[email protected]>

* token perms

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Use read-only GCP SA

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Better parameter  handling in update-geth action

Signed-off-by: Maximilian Langenfeld <[email protected]>

* Remove `update-celo-geth` cmd from justfile

---------

Signed-off-by: Maximilian Langenfeld <[email protected]>
Co-authored-by: alvarof2 <[email protected]>
  • Loading branch information
ezdac and alvarof2 authored Dec 17, 2024
1 parent 5374bb9 commit 57616ab
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build/_workspace
build/bin
build/_bin
tests/testdata

# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
60 changes: 60 additions & 0 deletions .github/workflows/update-geth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Update celo-org/op-geth"
on:
schedule:
- cron: "00 8 * * Mon"
workflow_dispatch:

env:
OP_GETH_BASE_BRANCH: "celo10"

jobs:
job_id:
# Add "id-token" with the intended permissions.
permissions:
contents: write
pull-requests: write
id-token: "write"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login at GCP Artifact Registry
uses: celo-org/reusable-workflows/.github/actions/[email protected]
with:
workload-id-provider: "projects/1094498259535/locations/global/workloadIdentityPools/gh-optimism-ro/providers/github-by-repos"
service-account: "[email protected]"
docker-gcp-registries: us-west1-docker.pkg.dev
access-token-lifetime: "2m"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"
- name: Run the update-geth script
id: geth-update-script
run: |
GETH_COMMIT=$(bash ./ops/celo/update-geth.sh "$OP_GETH_BASE_BRANCH")
echo "GETH_COMMIT=${GETH_COMMIT}" >> $GITHUB_OUTPUT
- name: Create pull request
uses: peter-evans/create-pull-request@v7
env:
TITLE: "[Automatic] - Update op-geth dependencies"
MESSAGE: |
Update the go package dependency and the devnet
docker container reference of the `l2` service
to the latest commit (`${{ steps.geth-update-script.outputs.GETH_COMMIT }}`)
in the `${{ env.OP_GETH_BASE_BRANCH }}` ref.
with:
add-paths: |
go.mod
go.sum
ops-bedrock/*.Dockerfile
commit-message: |
${{ env.TITLE }}
${{ env.MESSAGE }}
signoff: false
branch: update/op-geth
base: "${{ env.OP_GETH_BASE_BRANCH }}"
delete-branch: true
title: "${{ env.TITLE }}"
body: "${{ env.MESSAGE }}"
draft: false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ crytic-export

# vscode
.vscode/

# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
33 changes: 33 additions & 0 deletions ops/celo/update-geth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

branch="$1"
if [ -z "$branch" ]; then
echo "No argument given. Please supply the ref in 'celo-org/op-geth' to be used "
exit 1
fi

commit=$(git ls-remote https://github.com/celo-org/op-geth/ "$branch" | awk '{print $1}')
if [ -z "$commit" ]; then exit 1; fi

go_version=$(go list -m "github.com/celo-org/op-geth@$commit")
if [ -z "$go_version" ]; then exit 1; fi

sha256digest=$(gcloud --format=json artifacts files list \
--project=blockchaintestsglobaltestnet \
--repository=dev-images \
--location=us-west1 \
--package=op-geth \
--limit=1 \
--tag="$commit" | jq ".[0].name" | grep -oP "sha256:\K[0-9a-f]{64}")
if [ -z "$sha256digest" ]; then exit 1; fi

sed -i "s|\(.*op-geth@sha256:\)\(.*\)|\1$sha256digest|" ./ops-bedrock/l2-op-geth.Dockerfile
sed -i "s|\(replace github.com/ethereum/go-ethereum => \)github.com/celo-org/op-geth v.*|\1$go_version|" go.mod

go_mod_error=$(go mod tidy >/dev/null)
if [ -n "$go_mod_error" ]; then
echo "$go_mod_error"
exit 1
fi

echo "$commit"

0 comments on commit 57616ab

Please sign in to comment.