Skip to content

Commit f18c3a9

Browse files
authored
Merge branch 'v2' into mralj/bp-discv5-patch-backport
2 parents f154b29 + 4096922 commit f18c3a9

File tree

176 files changed

+6245
-4124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+6245
-4124
lines changed

.github/workflows/backport.yml

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,79 @@ jobs:
2828
if: github.event.pull_request.merged == true && needs.label_checker.outputs.state == 'success'
2929
runs-on: ubuntu-latest
3030
steps:
31-
- name: Backport Action
32-
uses: sorenlouv/backport-github-action@ad888e978060bc1b2798690dd9d03c4036560947
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
3333
with:
34-
github_token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
35-
auto_backport_label_prefix: backport-to-
34+
fetch-depth: 0
35+
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
3636

37-
- name: Info log
38-
if: ${{ success() }}
39-
run: cat ~/.backport/backport.info.log
37+
- name: Extract target branch from labels
38+
id: extract-branch
39+
run: |
40+
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
41+
echo "All labels: $LABELS"
4042
41-
- name: Debug log
42-
if: ${{ failure() }}
43-
run: cat ~/.backport/backport.debug.log
43+
# Extract the branch name from backport-to-* label
44+
TARGET_BRANCH=$(echo "$LABELS" | jq -r '.[] | select(startswith("backport-to-")) | sub("backport-to-"; "")')
45+
46+
if [ -z "$TARGET_BRANCH" ]; then
47+
echo "No backport-to-* label found"
48+
exit 1
49+
fi
50+
51+
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
52+
echo "Target branch: $TARGET_BRANCH"
53+
54+
- name: Run backport script
55+
id: backport
56+
continue-on-error: true
57+
env:
58+
GH_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
59+
run: |
60+
./scripts/backport_to_staging.sh \
61+
${{ github.event.pull_request.number }} \
62+
${{ steps.extract-branch.outputs.target_branch }}
63+
64+
- name: Comment on original PR (success)
65+
if: steps.backport.outcome == 'success'
66+
env:
67+
GH_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
68+
run: |
69+
TARGET_BRANCH="${{ steps.extract-branch.outputs.target_branch }}"
70+
STAGING_BRANCH="backport-to-${TARGET_BRANCH}-staging"
71+
COMMIT_COUNT=$(gh pr view "${{ github.event.pull_request.number }}" --json commits --jq '.commits | length')
72+
73+
gh pr comment "${{ github.event.pull_request.number }}" --body \
74+
"✅ Successfully cherry-picked $COMMIT_COUNT commit(s) to backport staging branch \`$STAGING_BRANCH\`."
75+
76+
- name: Comment on original PR (failure)
77+
if: steps.backport.outcome == 'failure'
78+
env:
79+
GH_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
80+
run: |
81+
TARGET_BRANCH="${{ steps.extract-branch.outputs.target_branch }}"
82+
83+
gh pr comment "${{ github.event.pull_request.number }}" --body \
84+
"❌ Failed to cherry-pick to \`$TARGET_BRANCH\` due to conflicts. Please backport manually."
85+
86+
- name: Notify Slack on backport failure
87+
if: steps.backport.outcome == 'failure'
88+
env:
89+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
90+
run: |
91+
PR_NUMBER="${{ github.event.pull_request.number }}"
92+
PR_TITLE="${{ github.event.pull_request.title }}"
93+
TARGET_BRANCH="${{ steps.extract-branch.outputs.target_branch }}"
94+
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
95+
96+
data=$(cat <<EOF
97+
{
98+
"channel": "#team-alpha",
99+
"text": "⚠️ Automatic backport failed\n• PR #$PR_NUMBER - $PR_TITLE\n• Target: $TARGET_BRANCH\n• Reason: Cherry-pick conflicts\n\nAction needed: Manual backport required\n<$WORKFLOW_URL|View Run>"
100+
}
101+
EOF
102+
)
103+
curl -X POST https://slack.com/api/chat.postMessage \
104+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
105+
-H "Content-type: application/json" \
106+
--data "$data"
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Deploy fisherman network with specified L1 network
2+
# This workflow can be called directly or from other workflows
3+
name: Deploy Fisherman Network
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
l1_network:
9+
description: "L1 network (sepolia or mainnet)"
10+
required: true
11+
type: string
12+
semver:
13+
description: "Semver version (e.g., 2.3.4)"
14+
required: true
15+
type: string
16+
ref:
17+
description: "Git ref to checkout"
18+
required: false
19+
type: string
20+
workflow_dispatch:
21+
inputs:
22+
l1_network:
23+
description: "L1 network (sepolia or mainnet)"
24+
required: true
25+
type: choice
26+
options:
27+
- sepolia
28+
- mainnet
29+
semver:
30+
description: "Semver version (e.g., 2.3.4)"
31+
required: true
32+
type: string
33+
34+
concurrency:
35+
group: deploy-fisherman-network-${{ inputs.l1_network }}-${{ inputs.semver }}-${{ github.ref || github.ref_name }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
deploy-fisherman:
40+
runs-on: ubuntu-latest
41+
env:
42+
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp-key.json
43+
steps:
44+
- name: Determine checkout ref
45+
id: checkout-ref
46+
run: |
47+
# Use inputs.ref if provided (workflow_call), otherwise use github.ref
48+
if [[ -n "${{ inputs.ref }}" ]]; then
49+
echo "ref=${{ inputs.ref }}" >> $GITHUB_OUTPUT
50+
else
51+
echo "ref=${{ github.ref }}" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Checkout
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
56+
with:
57+
ref: ${{ steps.checkout-ref.outputs.ref }}
58+
fetch-depth: 0
59+
persist-credentials: false
60+
submodules: recursive # Initialize git submodules for l1-contracts dependencies
61+
62+
- name: Validate inputs
63+
run: |
64+
# Validate l1_network
65+
if [[ "${{ inputs.l1_network }}" != "sepolia" && "${{ inputs.l1_network }}" != "mainnet" ]]; then
66+
echo "Error: L1 network must be 'sepolia' or 'mainnet', got '${{ inputs.l1_network }}'"
67+
exit 1
68+
fi
69+
70+
# Validate environment file exists
71+
if [[ ! -f "spartan/environments/ignition-fisherman.env" ]]; then
72+
echo "Error: Environment file not found: spartan/environments/ignition-fisherman.env"
73+
exit 1
74+
fi
75+
76+
# Validate semver format
77+
if ! echo "${{ inputs.semver }}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$'; then
78+
echo "Error: Invalid semver format '${{ inputs.semver }}'. Expected format: X.Y.Z or X.Y.Z-suffix"
79+
exit 1
80+
fi
81+
82+
# Extract major version for v2 check
83+
major_version="${{ inputs.semver }}"
84+
major_version="${major_version%%.*}"
85+
echo "MAJOR_VERSION=$major_version" >> $GITHUB_ENV
86+
87+
- name: Store the GCP key in a file
88+
env:
89+
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
90+
run: |
91+
set +x
92+
umask 077
93+
printf '%s' "$GCP_SA_KEY" > "$GOOGLE_APPLICATION_CREDENTIALS"
94+
jq -e . "$GOOGLE_APPLICATION_CREDENTIALS" >/dev/null
95+
96+
- name: Setup GCP authentication
97+
run: |
98+
gcloud auth activate-service-account --key-file="$GOOGLE_APPLICATION_CREDENTIALS"
99+
100+
- name: Setup gcloud and install GKE auth plugin
101+
uses: google-github-actions/setup-gcloud@v2
102+
with:
103+
install_components: "gke-gcloud-auth-plugin"
104+
105+
- name: Setup Terraform
106+
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1
107+
with:
108+
terraform_version: "1.7.5"
109+
terraform_wrapper: false # Disable the wrapper that adds debug output, this messes with reading terraform output
110+
111+
- name: Install Foundry
112+
uses: foundry-rs/foundry-toolchain@v1
113+
114+
- name: Set environment variables
115+
run: |
116+
# Set environment variables for ignition-fisherman.env
117+
if [[ "${{ inputs.l1_network }}" == "sepolia" ]]; then
118+
echo "NETWORK=staging-ignition" >> $GITHUB_ENV
119+
echo "NAMESPACE=ignition-fisherman-sepolia" >> $GITHUB_ENV
120+
echo "ETHEREUM_CHAIN_ID=11155111" >> $GITHUB_ENV
121+
echo "L1_NETWORK=sepolia" >> $GITHUB_ENV
122+
echo "SNAPSHOT_BUCKET_DIRECTORY=ignition-sepolia" >> $GITHUB_ENV
123+
echo "USE_NETWORK_CONFIG=true" >> $GITHUB_ENV
124+
elif [[ "${{ inputs.l1_network }}" == "mainnet" ]]; then
125+
echo "NETWORK=mainnet" >> $GITHUB_ENV
126+
echo "NAMESPACE=ignition-fisherman-mainnet" >> $GITHUB_ENV
127+
echo "ETHEREUM_CHAIN_ID=1" >> $GITHUB_ENV
128+
echo "L1_NETWORK=mainnet" >> $GITHUB_ENV
129+
echo "SNAPSHOT_BUCKET_DIRECTORY=ignition-mainnet" >> $GITHUB_ENV
130+
echo "USE_NETWORK_CONFIG=true" >> $GITHUB_ENV
131+
fi
132+
133+
- name: Deploy fisherman network
134+
env:
135+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
136+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
137+
GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
138+
RUN_ID: ${{ github.run_id }}
139+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
140+
GOOGLE_APPLICATION_CREDENTIALS: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
141+
REF_NAME: "v${{ inputs.semver }}"
142+
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
143+
AZTEC_DOCKER_IMAGE: "aztecprotocol/aztec:${{ inputs.semver }}"
144+
run: |
145+
echo "Deploying fisherman network on L1: ${{ inputs.l1_network }}"
146+
echo "Using image: $AZTEC_DOCKER_IMAGE"
147+
echo "Using branch/ref: ${{ steps.checkout-ref.outputs.ref }}"
148+
echo "Network: $NETWORK"
149+
echo "Namespace: $NAMESPACE"
150+
echo "Ethereum Chain ID: $ETHEREUM_CHAIN_ID"
151+
echo "L1 Network: $L1_NETWORK"
152+
echo "Snapshot Bucket Directory: $SNAPSHOT_BUCKET_DIRECTORY"
153+
echo "Use Network Config: $USE_NETWORK_CONFIG"
154+
155+
cd spartan
156+
./scripts/install_deps.sh
157+
./scripts/network_deploy.sh ignition-fisherman
158+
159+
- name: Setup IRM
160+
env:
161+
MONITORING_NAMESPACE: ${{ env.NETWORK }}-irm
162+
INFURA_SECRET_NAME: infura-${{ env.L1_NETWORK }}-url
163+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
164+
run: |
165+
166+
echo "Setting up IRM for namespace: $NAMESPACE, monitoring namespace: $MONITORING_NAMESPACE"
167+
echo "Network: $NETWORK"
168+
169+
echo "INFURA Secret Name: $INFURA_SECRET_NAME"
170+
171+
./spartan/metrics/testnet-monitor/scripts/update-monitoring.sh $NAMESPACE ${{ env.MONITORING_NAMESPACE }} $NETWORK $INFURA_SECRET_NAME
172+
173+
- name: Notify Slack on failure
174+
if: failure()
175+
env:
176+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
177+
run: |
178+
if [ -n "${SLACK_BOT_TOKEN}" ]; then
179+
read -r -d '' data <<EOF || true
180+
{
181+
"channel": "#alerts-fisherman-${{ inputs.l1_network }}",
182+
"text": "Deploy Fisherman Network workflow FAILED for *${{ inputs.l1_network }}* (version ${{ inputs.semver }}): <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
183+
}
184+
EOF
185+
curl -X POST https://slack.com/api/chat.postMessage \
186+
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
187+
-H "Content-type: application/json" \
188+
--data "$data"
189+
fi

0 commit comments

Comments
 (0)