Skip to content

Commit

Permalink
use dynamic config building in CI (#534)
Browse files Browse the repository at this point in the history
* use dynamic config building in CI

This works by having a small workflow run, compute the list of chain ids to run genesis validation checks on, and then modify a subsequent config file which circleci then runs.

* add comment

* fan in

* fix

* fix script

* Update .circleci/continue_config.yml

Co-authored-by: Vinod Damle <[email protected]>

---------

Co-authored-by: Vinod Damle <[email protected]>
  • Loading branch information
geoknee and vdamle authored Aug 30, 2024
1 parent c7e50fe commit 7d3ed21
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 254 deletions.
270 changes: 16 additions & 254 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,265 +1,27 @@
version: 2.1

orbs:
go: circleci/[email protected]
node: circleci/[email protected]
slack: circleci/[email protected]
# this allows us to use CircleCI's dynamic configuration feature
setup: true

commands:
notify-failures-on-main:
description: "Notify Slack for CI job failures"
parameters:
channel:
type: string
steps:
- slack/notify:
channel: << parameters.channel >>
event: fail
template: basic_fail_1
branch_pattern: main
install-just:
steps:
- run:
name: "Install just"
command: |
wget -qO - 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null
echo "deb [arch=all,$(dpkg --print-architecture) signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list
sudo apt update
sudo apt install just
install-foundry:
steps:
- run:
# need foundry to execute 'cast call' within add-chain script
name: Install foundry
command: |
echo "SHELL=$SHELL"
# Set up directory structure
mkdir -p $HOME/.foundry/bin
echo 'export PATH="$HOME/.foundry/bin:$PATH"' >> $BASH_ENV
source $BASH_ENV
# Download foundryup and make it executable
curl -sSL "https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup" -o $HOME/.foundry/bin/foundryup
chmod +x $HOME/.foundry/bin/foundryup
$HOME/.foundry/bin/foundryup
forge --version
install-gvm:
steps:
- run:
name: install nvm
command: |
sudo apt-get update
sudo apt-get -yq install curl git mercurial make binutils bison gcc build-essential bsdmainutils
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
install-pnpm:
description: "Installs pnpm"
steps:
- run:
name: Install pnpm
command: |
sudo npm install -g pnpm
install-nvm:
description: "Installs nvm"
steps:
- run:
name: Install nvm
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
source ~/.bashrc
nvm --version
orbs:
continuation: circleci/[email protected]

jobs:
golang-lint:
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- run: just lint-all
- run:
name: check git tree is clean
command: git diff --exit-code
golang-modules-tidy:
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- run: just tidy-all
- run:
name: check git tree is clean
command: git diff --exit-code
golang-test:
shell: /bin/bash -eo pipefail
executor:
name: go/default # is based on cimg/go
tag: '1.21'
setup-genesis-allocs-validation:
macos:
xcode: 14.2.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- install-just
- install-foundry
- run:
name: run superchain module unit tests
command: just test-superchain
- run:
name: run validation module unit tests
command: just test-validation
- run:
name: run add-chain module unit tests
command: just test-add-chain
- notify-failures-on-main:
channel: C03N11M0BBN # to slack channel `notify-ci-failures`
golang-validate-allocs:
docker:
- image: cimg/go:1.22.6-node
resource_class: medium
parameters:
chainid:
type: string
steps:
- checkout
- install-pnpm
- install-just
- install-foundry
- install-gvm
- install-nvm
- run: just validate-genesis-allocs <<parameters.chainid>>
# TODO this should also be filtered on modified chains
golang-validate-modified:
shell: /bin/bash -eo pipefail
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- install-foundry
- run:
name: run validation checks
command: just validate-modified-chains main # TODO ideally this is the base branch
golang-validate-all:
shell: /bin/bash -eo pipefail
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- install-foundry
- run:
name: run validation checks on all chains
command: just validate "*"
- notify-failures-on-main:
channel: C07GQQZDW1G # to slack channel `notify-superchain-validation-failures`
golang-promotion-test:
shell: /bin/bash -eo pipefail
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- install-foundry
- run:
name: run validation checks
command: just promotion-test
- slack/notify:
event: always
custom: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":control_knobs: The daily report on standard candidate chains is ready!"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "👀 Click the link to see what validation checks would fail if all candidate chains were promoted to standard (and exclusions removed)."
}
]
}
]
}
channel: C07GZVCCUS0 # to slack channel `notify-superchain-promotion-failures`
publish-bot:
environment:
NODE_AUTH_TOKEN: $NPM_TOKEN # Use NPM_TOKEN as the auth token
docker:
- image: cimg/node:18 # Use Node.js 18
steps:
- checkout
- run:
name: Set deployment token
command: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run:
name: Build and publish package on NPM 📦
command: pnpm release
check-codegen:
executor:
name: go/default # is based on cimg/go
tag: '1.21'
steps:
- checkout
- install-just
- run:
name: Run codegen
command: just codegen
- run:
name: check git tree is clean
command: git diff --exit-code
name: Generate list of chainids and insert into continue_config.yml file
command: |
bash validation/genesis/validation-inputs/generate-test-config.sh
- continuation/continue:
configuration_path: .circleci/continue_config.yml
parameters: '{}'

workflows:
hourly:
jobs:
- golang-validate-all:
context:
- slack
- golang-test:
context:
- slack
triggers:
- schedule:
cron: "0 * * * *"
filters:
branches:
only:
- main
nightly:
jobs:
- golang-promotion-test:
context:
- slack
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
pr-checks:
setup:
jobs:
- golang-lint
- golang-modules-tidy
- golang-test
- golang-validate-genesis-allocs:
matrix:
parameters:
chainid: ["7777777", "4801", "1750", "480","34443", "6806", "84532", "8453", "1135", "4202"]
- golang-validate-modified
- check-codegen
- setup-genesis-allocs-validation
Loading

0 comments on commit 7d3ed21

Please sign in to comment.