Skip to content

Commit

Permalink
chore: Add reusable install-go-modules job to CircleCI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Jan 23, 2025
1 parent 06d0116 commit 26e93ac
Showing 1 changed file with 47 additions and 58 deletions.
105 changes: 47 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ workflows:
- prestate-reproducibility:
version: "1.3.1"
asterisc-commit: "25feabf"
- rvgo-tests

commands:
install-dependencies:
Expand All @@ -51,6 +52,37 @@ commands:
name: Install mise dependencies
command: mise install

install-go-modules:
parameters:
from:
description: Path to go.sum file
type: string
default: go.sum
path:
description: Go module cache path
type: string
default: /home/circleci/.go_workspace/pkg/mod
after_download:
description: List of steps to run after downloading go modules
type: steps
default: []
steps:
- restore_cache:
name: Restore Go modules cache
keys:
- go-mod-{{ arch }}-{{ checksum "<< parameters.from >>" }}-v1
- run:
name: Download Go modules
command: go mod download
- run:
name: Debug cache
command: go env GOMODCACHE
- steps: << parameters.after_download >>
- save_cache:
key: go-mod-{{ arch }}-{{ checksum "<< parameters.from >>" }}-v1
paths:
- << parameters.path >>

checkout-with-monorepo:
steps:
- checkout
Expand All @@ -73,16 +105,12 @@ jobs:
steps:
- checkout-with-monorepo
- install-dependencies
- install-go-modules
- run:
name: Check L1 geth version
command: ./ops/scripts/geth-version-checker.sh || (echo "geth version is wrong, update ci-builder"; false)
working_directory: rvsol/lib/optimism
- install-contracts-dependencies
- restore_cache:
name: Restore Go modules cache
keys:
- gomod-contracts-build-{{ checksum "go.sum" }}
- gomod-contracts-build-
- restore_cache:
name: Restore Go build cache
keys:
Expand All @@ -105,11 +133,6 @@ jobs:
name: Generate default allocs
command: make devnet-allocs-tests
working_directory: rvsol/lib/optimism
- save_cache:
name: Save Go modules cache
key: gomod-contracts-build-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- save_cache:
name: Save Go build cache
key: golang-build-cache-contracts-build-{{ checksum "go.sum" }}
Expand All @@ -130,62 +153,35 @@ jobs:
steps:
- checkout-with-monorepo
- install-dependencies
- restore_cache:
key: gomod>-{{ checksum "rvsol/lib/optimism/go.sum" }}
name: Restore Go modules cache for monorepo
- run:
name: Sanity check go mod cache path
command: test "$(go env GOMODCACHE)" == "/go/pkg/mod" # yes, it's an odd path
working_directory: rvsol/lib/optimism
- run:
command: go mod download
name: Download Go module dependencies
working_directory: rvsol/lib/optimism
- run:
name: Go mod tidy
command: make mod-tidy && git diff --exit-code
working_directory: rvsol/lib/optimism
- install-go-modules:
from: rvsol/lib/optimism/go.sum
after_download:
- run:
name: Tidy modules
command: make mod-tidy && git diff --exit-code
working_directory: rvsol/lib/optimism
- run:
name: run Go linter
command: |
# Identify how many cores it defaults to
golangci-lint run --help | grep concurrency
make lint-go
working_directory: rvsol/lib/optimism
- save_cache:
key: gomod-{{ checksum "rvsol/lib/optimism/go.sum" }}
name: Save Go modules cache
paths:
- "/go/pkg/mod"

go-mod-download-asterisc:
executor: default
steps:
- checkout
- install-dependencies
- restore_cache:
key: gomod-{{ checksum "go.sum" }}
name: Restore Go modules cache
- run:
name: Sanity check go mod cache path
command: test "$(go env GOMODCACHE)" == "/go/pkg/mod" # yes, it's an odd path
- run:
command: go mod download
name: Download Go module dependencies
- save_cache:
key: gomod-{{ checksum "go.sum" }}
name: Save Go modules cache
paths:
- "/go/pkg/mod"
- install-go-modules

op-program-riscv:
executor: default
steps:
- checkout-with-monorepo
- install-dependencies
- restore_cache:
key: gomod-{{ checksum "rvsol/lib/optimism/go.sum" }}
name: Restore Go modules cache
- install-go-modules:
from: rvsol/lib/optimism/go.sum
- run:
name: Build op-program-client-riscv
command: make op-program-client-riscv
Expand All @@ -206,9 +202,7 @@ jobs:
- install-dependencies
- attach_workspace:
at: /tmp/workspace
- restore_cache:
key: gomod-{{ checksum "go.sum" }}
name: Restore Go modules cache
- install-go-modules
- run:
name: Load op-program-client-riscv
command: |
Expand Down Expand Up @@ -321,10 +315,8 @@ jobs:
- install-dependencies
- attach_workspace:
at: /tmp/workspace
- restore_cache:
name: Restore Go modules cache for monorepo
# this go mod cache will be populated from go-mod-download-monorepo step
key: gomod-{{ checksum "rvsol/lib/optimism/go.sum" }}
- install-go-modules:
from: rvsol/lib/optimism/go.sum
- run:
name: Make op-program at monorepo
command: make op-program
Expand All @@ -342,10 +334,7 @@ jobs:
cp -r /tmp/workspace/packages/contracts-bedrock/deploy-config packages/contracts-bedrock
mkdir -p packages/contracts-bedrock/deployments/devnetL1
cp -r /tmp/workspace/packages/contracts-bedrock/deployments/devnetL1 packages/contracts-bedrock/deployments
- restore_cache:
name: Restore Go modules cache
# this go mod cache will be populated from go-mod-download-monorepo step
key: gomod-{{ checksum "go.sum" }}
- install-go-modules
- run:
name: Load asterisc artifacts
command: |
Expand Down

0 comments on commit 26e93ac

Please sign in to comment.