Skip to content

Commit 2bddeb9

Browse files
committed
mitch/tmnt-168-create-test-network-scenariosyml
1 parent 62c5da5 commit 2bddeb9

25 files changed

+1885
-1804
lines changed

.github/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.secrets
1+
.secrets
2+
.act-tool-cache

.github/local_workflow.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ args=("$@")
3232

3333
SA_KEY_JSON=$(cat "$GOOGLE_APPLICATION_CREDENTIALS")
3434

35+
mkdir -p $REPO_ROOT/.github/.act-tool-cache
36+
3537
act workflow_dispatch -j $workflow_name \
38+
--env RUNNER_TOOL_CACHE=/work/toolcache \
3639
-s GITHUB_TOKEN="$(gh auth token)" \
3740
-s GCP_SA_KEY="$SA_KEY_JSON" \
3841
-s KUBECONFIG_B64="$(cat $HOME/.kube/config | base64 -w0)" \
39-
--container-options "--user $(id -u):$(id -g)" \
42+
--container-options "-v $REPO_ROOT/.github/.act-tool-cache:/work/toolcache --user $(id -u):$(id -g)" \
4043
--bind \
4144
--directory $REPO_ROOT "${args[@]}"

.github/workflows/ci3.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ jobs:
145145
exec ./ci.sh fast
146146
fi
147147
148+
- name: Get Semver from Tag
149+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
150+
id: semver
151+
run: |
152+
semver="${{ github.ref_name }}"
153+
# Remove 'v' prefix if present (e.g., v1.2.3 -> 1.2.3)
154+
semver=${semver#v}
155+
# Extract major version (e.g., 1.2.3 -> 1)
156+
major_version=${semver%%.*}
157+
echo "semver=$semver" >> $GITHUB_OUTPUT
158+
echo "major_version=$major_version" >> $GITHUB_OUTPUT
159+
160+
- name: Trigger Network Deployments
161+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
162+
uses: peter-evans/repository-dispatch@v3
163+
with:
164+
event-type: network-deployments
165+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "semver": "${{ steps.semver.outputs.semver }}", "major_version": "${{ steps.semver.outputs.major_version }}"}'
166+
148167
- name: Save CI Success
149168
if: steps.ci_cache.outputs.cache-hit != 'true'
150169
run: echo "success" > ci-success.txt

.github/workflows/deploy-scenario-network.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ on:
3838
required: true
3939
KUBECONFIG_B64:
4040
description: The base64 encoded kubeconfig
41-
required: true
41+
required: false
4242

4343
workflow_dispatch:
4444
inputs:
@@ -122,7 +122,7 @@ jobs:
122122
aztec_slashing_round_size: 10
123123
aztec_governance_proposer_quorum: 6
124124
aztec_governance_proposer_round_size: 10
125-
aztec_mana_target: 1000000
125+
aztec_mana_target: 1000000000
126126
aztec_proving_cost_per_mana: 100
127127
secrets:
128128
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# CI for Aztec. At a high-level, runs ./bootstrap.sh ci in root. See root README.md for more details.
2+
# Only for internal devs. For external devs, see ci3-external.yml.
3+
#
4+
# CAREFUL! We use "exec" a lot to ensure signal propagation to the child process, to allow proper ec2 cleanup.
5+
name: Test Network Scenarios
6+
7+
on:
8+
repository_dispatch:
9+
types:
10+
- network-deployments
11+
12+
concurrency:
13+
group: network-scenarios-${{ github.event.client_payload.major_version }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test_network_scenarios_dispatch_deploy_scenario_network:
18+
uses: ./.github/workflows/deploy-scenario-network.yml
19+
with:
20+
cluster: aztec-gke-private
21+
namespace: v${{ github.event.client_payload.major_version }}-scenario
22+
ref: ${{ github.event.client_payload.ref }}
23+
aztec_docker_image: "aztecprotocol/aztec:${{ github.event.client_payload.semver }}"
24+
devnet_mnemonic: "test test test test test test test test test test test junk"
25+
rollup_deployment_mnemonic: "test test test test test test test test test test test junk"
26+
secrets:
27+
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
28+
29+
ci:
30+
runs-on: ubuntu-latest
31+
steps:
32+
#############
33+
# Prepare Env
34+
#############
35+
- name: Checkout
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
37+
with:
38+
ref: ${{ github.sha }}
39+
persist-credentials: false
40+
41+
- name: CI Network Scenario Override
42+
run: echo "CI_NETWORK_SCENARIO=1" >> $GITHUB_ENV
43+
44+
- name: Compute Target Branch
45+
id: target_branch
46+
run: |
47+
if [ "${{ github.event_name }}" == "merge_group" ]; then
48+
target_branch=${{ github.event.merge_group.base_ref }}
49+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
50+
target_branch=${{ github.event.pull_request.base.ref }}
51+
else
52+
target_branch=${{ github.ref_name }}
53+
fi
54+
target_branch=${target_branch#refs/heads/}
55+
echo "target_branch=$target_branch" >> $GITHUB_OUTPUT
56+
echo "TARGET_BRANCH=${target_branch}" >> $GITHUB_ENV
57+
58+
- name: Setup
59+
run: |
60+
# Ensure we can SSH into the spot instances we request.
61+
mkdir -p ~/.ssh
62+
echo ${{ secrets.BUILD_INSTANCE_SSH_KEY }} | base64 --decode > ~/.ssh/build_instance_key
63+
chmod 600 ~/.ssh/build_instance_key
64+
sudo apt install -y --no-install-recommends redis-tools parallel
65+
66+
- name: Prepare GCP key
67+
env:
68+
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
69+
run: |
70+
echo "$GCP_SA_KEY" | base64 -w 0 > gcp_sa_key.b64
71+
echo "GCP_SA_KEY_B64=$(cat gcp_sa_key.b64)" >> $GITHUB_ENV
72+
73+
- name: Get Tree Hash
74+
run: echo "TREE_HASH=$(git rev-parse HEAD^{tree})" >> $GITHUB_ENV
75+
76+
- name: Check CI Cache
77+
id: ci_cache
78+
uses: actions/cache@v3
79+
with:
80+
path: ci-success.txt
81+
key: ci-network-scenario-${{ env.TREE_HASH }}
82+
83+
#############
84+
# Run
85+
#############
86+
- name: Run
87+
if: steps.ci_cache.outputs.cache-hit != 'true'
88+
env:
89+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
90+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
91+
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
92+
RUN_ID: ${{ github.run_id }}
93+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
94+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
95+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
96+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
97+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
98+
# Nightly test env vars.
99+
GCP_SA_KEY_B64: ${{ env.GCP_SA_KEY_B64 }}
100+
EXTERNAL_ETHEREUM_HOSTS: "https://json-rpc.${{ secrets.GCP_SEPOLIA_URL }}?key=${{ secrets.GCP_SEPOLIA_API_KEY }},${{ secrets.INFURA_SEPOLIA_URL }}"
101+
EXTERNAL_ETHEREUM_CONSENSUS_HOST: "https://beacon.${{ secrets.GCP_SEPOLIA_URL }}"
102+
EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY: ${{ secrets.GCP_SEPOLIA_API_KEY }}
103+
EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY_HEADER: "X-goog-api-key"
104+
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
105+
SCENARIO_NAMESPACE: "${{ github.ref_name }}-scenario"
106+
run: |
107+
exec ./ci.sh network-scenario
108+
109+
- name: Save CI Success
110+
if: steps.ci_cache.outputs.cache-hit != 'true'
111+
run: echo "success" > ci-success.txt

bootstrap.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,13 @@ case "$cmd" in
438438
test
439439
release
440440
;;
441+
"ci-network-scenario")
442+
export CI=1
443+
export USE_TEST_CACHE=1
444+
export CI_SCENARIO_TEST=1
445+
build
446+
CI_SCENARIO_TEST=1 spartan/bootstrap.sh test
447+
;;
441448
"ci-release")
442449
export CI=1
443450
export USE_TEST_CACHE=1

ci.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ case "$cmd" in
141141
'run x4-full amd64 ci-full' \
142142
'run a1-fast arm64 ci-fast' | DUP=1 cache_log "Merge queue CI run" $RUN_ID
143143
;;
144+
"network-scenario")
145+
prep_vars
146+
# Spin up ec2 instance and run the network scenario flow.
147+
run() {
148+
JOB_ID=$1 INSTANCE_POSTFIX=$1 ARCH=$2 exec denoise "bootstrap_ec2 './bootstrap.sh ci-network-scenario'"
149+
}
150+
export -f run
151+
# We need to run the network scenario flow on both x86 and arm64.
152+
parallel --termseq 'TERM,10000' --tagstring '{= $_=~s/run (\w+).*/$1/; =}' --line-buffered --halt now,fail=1 ::: \
153+
'run x-network-scenario amd64' | DUP=1 cache_log "Network scenario CI run" $RUN_ID
154+
;;
144155
"nightly")
145156
prep_vars
146157
# Spin up ec2 instance and run the nightly flow.

spartan/bootstrap.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ function test_cmds {
8080
# echo "$hash:TIMEOUT=50m ./spartan/bootstrap.sh test-kind-4epochs-sepolia"
8181
# echo "$hash:TIMEOUT=30m ./spartan/bootstrap.sh test-prod-deployment"
8282
fi
83+
if [ "$CI_SCENARIO_TEST" -eq 1 ]; then
84+
local run_test_script="yarn-project/end-to-end/scripts/run_test.sh"
85+
SCENARIO_NAMESPACE=${SCENARIO_NAMESPACE:-"scenario"}
86+
K8S_CLUSTER=${K8S_CLUSTER:-"aztec-gke-private"}
87+
PROJECT_ID=${PROJECT_ID:-"testnet-440309"}
88+
REGION=${REGION:-"us-west1-a"}
89+
local env_vars="NAMESPACE=$SCENARIO_NAMESPACE K8S_CLUSTER=$K8S_CLUSTER PROJECT_ID=$PROJECT_ID REGION=$REGION"
90+
echo "$hash:TIMEOUT=20m $env_vars $run_test_script simple src/spartan/smoke.test.ts"
91+
echo "$hash:TIMEOUT=20m $env_vars $run_test_script simple src/spartan/transfer.test.ts"
92+
fi
8393
}
8494

8595
function start_env {
@@ -105,7 +115,13 @@ function stop_env {
105115

106116
function test {
107117
echo_header "spartan test"
108-
test_cmds | filter_test_cmds | parallelize
118+
if [ "$CI_SCENARIO_TEST" -eq 1 ]; then
119+
echo "Running network scenario tests sequentially"
120+
test_cmds | filter_test_cmds
121+
else
122+
echo "Running spartan test"
123+
test_cmds | filter_test_cmds | parallelize
124+
fi
109125
}
110126

111127
case "$cmd" in

spartan/terraform/deploy-aztec-infra/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,4 @@ resource "google_compute_address" "rpc_ingress" {
188188
provider = google
189189
name = "${var.NAMESPACE}-${var.RELEASE_PREFIX}-rpc-ingress"
190190
address_type = "EXTERNAL"
191-
192-
193191
}

spartan/terraform/deploy-aztec-infra/values/rpc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ node:
1515
startCmd:
1616
- --node
1717
- --archiver
18+
- --pxe

0 commit comments

Comments
 (0)