Skip to content

Commit 886fc52

Browse files
committed
mitch/tmnt-168-create-test-network-scenariosyml
1 parent bec0c58 commit 886fc52

25 files changed

+1892
-1815
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
@@ -149,6 +149,25 @@ jobs:
149149
if: steps.ci_cache.outputs.cache-hit != 'true'
150150
run: echo "success" > ci-success.txt
151151

152+
- name: Get Semver from Tag
153+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
154+
id: semver
155+
run: |
156+
semver="${{ github.ref_name }}"
157+
# Remove 'v' prefix if present (e.g., v1.2.3 -> 1.2.3)
158+
semver=${semver#v}
159+
# Extract major version (e.g., 1.2.3 -> 1)
160+
major_version=${semver%%.*}
161+
echo "semver=$semver" >> $GITHUB_OUTPUT
162+
echo "major_version=$major_version" >> $GITHUB_OUTPUT
163+
164+
- name: Trigger Network Deployments
165+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
166+
uses: peter-evans/repository-dispatch@0ee9de00feb82e6165438c503f0bc29f628b8317
167+
with:
168+
event-type: network-deployments
169+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "semver": "${{ steps.semver.outputs.semver }}", "major_version": "${{ steps.semver.outputs.major_version }}"}'
170+
152171
# If we have passed CI and labelled with ci-squash-and-merge, squash the PR.
153172
# This will rerun CI on the squash commit - but is intended to be a no-op due to caching.
154173
- name: CI Squash and Merge

.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: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# CI for Aztec Network Scenarios.
2+
# Effectively runs CI_SCENARIO_TEST=1 spartan/bootstrap.sh test
3+
# Triggered by network-deployments event, which is emitted by ci3.yml when a tagged release passes "normal" CI.
4+
#
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+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
94+
# Nightly test env vars.
95+
GCP_SA_KEY_B64: ${{ env.GCP_SA_KEY_B64 }}
96+
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
97+
NAMESPACE: "v${{ github.event.client_payload.major_version }}-scenario"
98+
run: |
99+
exec ./ci.sh network-scenario
100+
101+
- name: Save CI Success
102+
if: steps.ci_cache.outputs.cache-hit != 'true'
103+
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+
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.

ci3/bootstrap_ec2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ function run {
252252
-e NPM_TOKEN=${NPM_TOKEN:-} \
253253
-e SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN:-} \
254254
-e AWS_TOKEN=\$aws_token \
255+
-e NAMESPACE=${NAMESPACE:-} \
255256
-v /tmp/gcp-key.json:/tmp/gcp-key.json:ro \
256257
--pids-limit=32768 \
257258
aztecprotocol/devbox:3.0 bash -c $(printf '%q' "$container_script")

ci3/source_refname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if [ -z "${CI_FULL:-}" ]; then
3737
fi
3838
fi
3939
export CI_NIGHTLY="${CI_NIGHTLY:-0}"
40+
export CI_SCENARIO_TEST="${CI_SCENARIO_TEST:-0}"
4041

4142
if [ -z "${COMMIT_HASH:-}" ]; then
4243
export COMMIT_HASH=$(git rev-parse HEAD)

spartan/bootstrap.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ function test_cmds {
6161
# TODO figure out why these take long sometimes.
6262
# echo "$hash ./spartan/bootstrap.sh test-kind-smoke"
6363

64-
if [ "$CI_NIGHTLY" -eq 1 ]; then
65-
NIGHTLY_NS=nightly-$(date -u +%Y%m%d)
66-
echo "$hash:TIMEOUT=20m FRESH_INSTALL=no-deploy NAMESPACE=$NIGHTLY_NS ./spartan/bootstrap.sh test-gke-transfer reth"
67-
echo "$hash:TIMEOUT=20m FRESH_INSTALL=no-deploy NAMESPACE=$NIGHTLY_NS ./spartan/bootstrap.sh test-gke-transfer geth"
64+
# if [ "$CI_NIGHTLY" -eq 1 ]; then
65+
# NIGHTLY_NS=nightly-$(date -u +%Y%m%d)
66+
# echo "$hash:TIMEOUT=20m FRESH_INSTALL=no-deploy NAMESPACE=$NIGHTLY_NS ./spartan/bootstrap.sh test-gke-transfer reth"
67+
# echo "$hash:TIMEOUT=20m FRESH_INSTALL=no-deploy NAMESPACE=$NIGHTLY_NS ./spartan/bootstrap.sh test-gke-transfer geth"
6868

6969
# Nethermind test can be enabled once https://github.com/NethermindEth/nethermind/pull/8897 is released
7070
# echo "$hash:TIMEOUT=20m FRESH_INSTALL=no-deploy NAMESPACE=$NIGHTLY_NS ./spartan/bootstrap.sh test-gke-transfer nethermind"
@@ -79,6 +79,16 @@ function test_cmds {
7979
# TODO(#12791) re-enable
8080
# echo "$hash:TIMEOUT=50m ./spartan/bootstrap.sh test-kind-4epochs-sepolia"
8181
# echo "$hash:TIMEOUT=30m ./spartan/bootstrap.sh test-prod-deployment"
82+
# fi
83+
if [ "$CI_SCENARIO_TEST" -eq 1 ]; then
84+
local run_test_script="yarn-project/end-to-end/scripts/run_test.sh"
85+
NAMESPACE=${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=$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"
8292
fi
8393
}
8494

@@ -105,7 +115,19 @@ function stop_env {
105115

106116
function test {
107117
echo_header "spartan test"
108-
test_cmds | filter_test_cmds | parallelize
118+
if [ "$CI" -eq 1 ]; then
119+
echo "Activating service account"
120+
gcloud auth activate-service-account --key-file=/tmp/gcp-key.json
121+
gcloud config set project "$GCP_PROJECT_ID"
122+
fi
123+
124+
if [ "$CI_SCENARIO_TEST" -eq 1 ]; then
125+
echo "Running network scenario tests sequentially"
126+
test_cmds | filter_test_cmds
127+
else
128+
echo "Running spartan test"
129+
test_cmds | filter_test_cmds | parallelize
130+
fi
109131
}
110132

111133
case "$cmd" in

0 commit comments

Comments
 (0)