diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..4dbdf6f0 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,185 @@ +version: 2.1 + +workflows: + main: + jobs: + - pnpm-monorepo + - go-mod-download-monorepo + - go-mod-download-asterisc + # - asterisc-prestate + +jobs: + pnpm-monorepo: + docker: + # TODO(pcw109550) temp hardcode. must update. this depends with rvsol/lib/optimism submodule version + - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.43.0 + resource_class: xlarge + steps: + - checkout + - run: + name: "Fetch submodules for asterisc" + # TODO(pcw109550) Do not recursive update. do we need this? + command: git submodule update --init + - 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 + - run: + name: git submodules for monorepo + command: make submodules + working_directory: rvsol/lib/optimism + - restore_cache: + name: Restore PNPM Package Cache + keys: + # TODO(pcw109550) fix hardcoded path + - pnpm-packages-v2-{{ checksum "rvsol/lib/optimism/pnpm-lock.yaml" }} + - restore_cache: + name: Restore Go modules cache for monorepo + # TODO(pcw109550) fix hardcoded path + # this go mod cache wil be populated from go-mod-download-monorepo step + key: gomod-{{ checksum "rvsol/lib/optimism/go.sum" }} + # Fetch node_modules into the pnpm store + # This will cache node_modules based on pnpm-lock so other steps can instantly install them with `pnpm install --prefer-offline` + # --prefer-offline installs node_modules instantly by just reading from cache if it exists rather than fetching from network + # when installing node_modules pnpm simply adds symlinks instead of copying the files which is why it is pretty much instant to run --prefer-offline + # this allows a caching strategy of only checking pnpm-lockfile so we don't have to keep it in sync with our packages + # For more information see https://pnpm.io/cli/fetch + - run: + name: Fetch dependencies + command: pnpm fetch --frozen-lockfile --prefer-offline + working_directory: rvsol/lib/optimism + - save_cache: + name: Save PNPM Package Cache + # TODO(pcw109550) fix hardcoded path + key: pnpm-packages-v2-{{ checksum "rvsol/lib/optimism/pnpm-lock.yaml" }} + paths: + - "rvsol/lib/optimism/node_modules" + - run: + name: Install dependencies + command: pnpm install:ci:offline + working_directory: rvsol/lib/optimism + - run: + name: print forge version + command: forge --version + working_directory: rvsol/lib/optimism + - run: + name: Build monorepo + environment: + FOUNDRY_PROFILE: ci + command: pnpm build + working_directory: rvsol/lib/optimism + - run: + name: Generate FPAC allocs + command: DEVNET_FPAC="true" make devnet-allocs + working_directory: rvsol/lib/optimism + - run: + name: Copy FPAC allocs to .devnet-fpac + command: cp -r .devnet/ .devnet-fault-proofs/ + working_directory: rvsol/lib/optimism + - run: + name: Generate Plasma allocs + command: DEVNET_PLASMA="true" make devnet-allocs + working_directory: rvsol/lib/optimism + - run: + name: Copy Plasma allocs to .devnet-plasma + command: cp -r .devnet/ .devnet-plasma/ + working_directory: rvsol/lib/optimism + - run: + name: Generate non-FPAC allocs + command: make devnet-allocs + working_directory: rvsol/lib/optimism + - persist_to_workspace: + root: rvsol/lib/optimism + paths: + - "packages/**/dist" + - "packages/contracts-bedrock/cache" + - "packages/contracts-bedrock/artifacts" + - "packages/contracts-bedrock/forge-artifacts" + - "packages/contracts-bedrock/tsconfig.tsbuildinfo" + - "packages/contracts-bedrock/tsconfig.build.tsbuildinfo" + - ".devnet/allocs-l1.json" + - ".devnet/addresses.json" + - ".devnet-fault-proofs/allocs-l1.json" + - ".devnet-fault-proofs/addresses.json" + - ".devnet-plasma/allocs-l1.json" + - ".devnet-plasma/addresses.json" + - "packages/contracts-bedrock/deploy-config/devnetL1.json" + - "packages/contracts-bedrock/deployments/devnetL1" + + go-mod-download-monorepo: + docker: + # TODO(pcw109550) temp hardcode. must update. this depends with rvsol/lib/optimism submodule version + - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.43.0 + parameters: + file: + default: rvsol/lib/optimism/go.sum + description: The file name of checksum for restore_cache and save_cache. + type: string + key: + default: gomod + description: The key of restore_cache and save_cache. + type: string + steps: + - checkout + - run: + name: "Fetch submodules for asterisc" + # TODO(pcw109550) Do not recursive update. do we need this??? ??? + command: git submodule update --init + - restore_cache: + key: << parameters.key >>-{{ checksum "<< parameters.file >>" }} + 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 + 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 + - run: + name: run Go linter + command: | + # Identify how many cores it defaults to + golangci-lint --help | grep concurrency + make lint-go + working_directory: rvsol/lib/optimism + - save_cache: + key: << parameters.key >>-{{ checksum "<< parameters.file >>" }} + name: Save Go modules cache + paths: + - "/go/pkg/mod" + + go-mod-download-asterisc: + docker: + # TODO(pcw109550) temp hardcode. must update. this depends with rvsol/lib/optimism submodule version + # for asterisc, we may use other image + - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.43.0 + parameters: + file: + default: go.sum + description: The file name of checksum for restore_cache and save_cache. + type: string + key: + default: gomod + description: The key of restore_cache and save_cache. + type: string + steps: + - checkout + - restore_cache: + key: << parameters.key >>-{{ checksum "<< parameters.file >>" }} + 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: << parameters.key >>-{{ checksum "<< parameters.file >>" }} + name: Save Go modules cache + paths: + - "/go/pkg/mod"