-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use dynamic config building in CI (#534)
* 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
Showing
3 changed files
with
136 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 2.1 | ||
|
||
# this allows us to use CircleCI's dynamic configuration feature | ||
setup: true | ||
|
||
orbs: | ||
continuation: circleci/[email protected] | ||
|
||
jobs: | ||
setup-genesis-allocs-validation: | ||
macos: | ||
xcode: 14.2.0 | ||
resource_class: macos.m1.medium.gen1 | ||
steps: | ||
- checkout | ||
- run: | ||
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: | ||
setup: | ||
jobs: | ||
- setup-genesis-allocs-validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
go: circleci/[email protected] | ||
node: circleci/[email protected] | ||
slack: circleci/[email protected] | ||
|
||
commands: | ||
notify-failures-on-main: | ||
description: "Notify Slack for CI job failures" | ||
|
@@ -46,11 +44,36 @@ commands: | |
$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 | ||
jobs: | ||
golang-lint: | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -61,7 +84,7 @@ jobs: | |
command: git diff --exit-code | ||
golang-modules-tidy: | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -73,7 +96,7 @@ jobs: | |
golang-test: | ||
shell: /bin/bash -eo pipefail | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -90,10 +113,11 @@ jobs: | |
command: just test-add-chain | ||
- notify-failures-on-main: | ||
channel: C03N11M0BBN # to slack channel `notify-ci-failures` | ||
# 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 | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -105,7 +129,7 @@ jobs: | |
golang-validate-all: | ||
shell: /bin/bash -eo pipefail | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -119,7 +143,7 @@ jobs: | |
golang-promotion-test: | ||
shell: /bin/bash -eo pipefail | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -130,45 +154,13 @@ jobs: | |
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!" | ||
}, | ||
"accessory": { | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "👀 View Report", | ||
"emoji": true | ||
}, | ||
"url": "${CIRCLE_BUILD_URL}" | ||
} | ||
}, | ||
{ | ||
"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` | ||
custom: "{\n \"blocks\": [\n {\n \"type\": \"section\",\n \"text\": {\n \"type\": \"mrkdwn\",\n \"text\": \":control_knobs: The daily report on standard candidate chains is ready!\"\n }\n },\n {\n \"type\": \"divider\"\n },\n {\n \"type\": \"context\",\n \"elements\": [\n {\n \"type\": \"mrkdwn\",\n \"text\": \"\U0001F440 Click the link to see what validation checks would fail if all candidate chains were promoted to standard (and exclusions removed).\"\n }\n ]\n }\n ]\n}\n" | ||
channel: C07GZVCCUS0 # to slack channel `notify-superchain-promotion-reports` | ||
publish-bot: | ||
environment: | ||
NODE_AUTH_TOKEN: $NPM_TOKEN # Use NPM_TOKEN as the auth token | ||
NODE_AUTH_TOKEN: $NPM_TOKEN # Use NPM_TOKEN as the auth token | ||
docker: | ||
- image: cimg/node:18 # Use Node.js 18 | ||
- image: cimg/node:18 # Use Node.js 18 | ||
steps: | ||
- checkout | ||
- run: | ||
|
@@ -177,11 +169,11 @@ jobs: | |
- env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- run: | ||
name: Build and publish package on NPM 📦 | ||
name: "Build and publish package on NPM \U0001F4E6" | ||
command: pnpm release | ||
check-codegen: | ||
executor: | ||
name: go/default # is based on cimg/go | ||
name: go/default # is based on cimg/go | ||
tag: '1.21' | ||
steps: | ||
- checkout | ||
|
@@ -192,7 +184,28 @@ jobs: | |
- run: | ||
name: check git tree is clean | ||
command: git diff --exit-code | ||
|
||
golang-validate-genesis-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>> | ||
genesis-allocs-all-ok: | ||
docker: | ||
- image: cimg/go:1.22.6-node | ||
resource_class: medium | ||
steps: | ||
- checkout | ||
- run: echo "Job 1 is running" | ||
workflows: | ||
hourly: | ||
jobs: | ||
|
@@ -223,6 +236,12 @@ workflows: | |
- main | ||
pr-checks: | ||
jobs: | ||
- golang-validate-genesis-allocs: | ||
matrix: | ||
parameters: | ||
chainid: [] # This list will be replaced by the generate_test_config.sh script | ||
- genesis-allocs-all-ok: | ||
requires: [] # This list will be replaced by the generate_test_config.sh script | ||
- golang-lint | ||
- golang-modules-tidy | ||
- golang-test | ||
|
42 changes: 42 additions & 0 deletions
42
validation/genesis/validation-inputs/generate-test-config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit -o pipefail | ||
set -x | ||
|
||
# Get the list of changed files | ||
targetList=$(git diff --name-only --merge-base main -- validation/genesis/*.toml) | ||
|
||
# Check if targetList is empty | ||
if [ -z "$targetList" ]; then | ||
echo "No matching .toml files found in 'validation/genesis/'. Exiting." | ||
exit 0 | ||
fi | ||
|
||
# Process the targetList to extract directory names and then the base names | ||
targetList=$(echo "$targetList" | xargs dirname | xargs basename) | ||
|
||
# Join the array elements with commas and wrap each element in quotes | ||
targets=$(echo "$targetList" | sed 's/.*/"&"/' | tr '\n' ',') | ||
|
||
# Remove the trailing comma | ||
targets=${targets%,} | ||
|
||
# Wrap in square brackets | ||
targets="[$targets]" | ||
|
||
echo "Will run genesis allocs validation on chains with ids $targets" | ||
|
||
# Now build another array, each element prepended with "golang-validate-genesis-allocs-" | ||
prependedTargets=$(echo "$targetList" | sed 's/.*/"golang-validate-genesis-allocs-&"/' | tr '\n' ',') | ||
|
||
# Remove the trailing comma | ||
prependedTargets=${prependedTargets%,} | ||
|
||
# Wrap in square brackets | ||
prependedTargets="[$prependedTargets]" | ||
|
||
# Install yq | ||
brew install yq | ||
|
||
# Use yq to replace the target-version key | ||
yq e ".workflows.pr-checks.jobs[0].golang-validate-genesis-allocs.matrix.parameters.chainid = $targets" -i .circleci/continue_config.yml | ||
yq e ".workflows.pr-checks.jobs[1].genesis-allocs-all-ok.requires = $prependedTargets" -i .circleci/continue_config.yml |