Skip to content

Commit 0c182e5

Browse files
authored
ci: add CI to auto validate deployment scripts (#1360)
**Motivation:** curently there's no ci coverage for deployment scripts. scripts can be only validated manually by devs offline by running `zeus test` on terminal pain points: 1/ no quality control of scripts that got merged in 2/ manual testing is time intensive and not scalable i feel these pain points as i'm writing deploy scripts of elip5 (v1.6.0 release) **Modifications:** add a new ci workflow to auto validate deployment scripts under /scripts/release/ in all 5 envs, currently mainnet, testnet, preprod. testnet-sepolia and testnet-hoodi to be added the ci will only run if a pr touches anything under /scripts **Result:** - quality control is put in place for all deployment scripts - fully automated, to save devs time
1 parent 179dc8b commit 0c182e5

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Validate Deployment Scripts
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
paths:
10+
- 'script/**'
11+
- '.github/workflows/validate-deployment-scripts.yml'
12+
13+
14+
jobs:
15+
16+
test:
17+
runs-on: protocol-x64-16core
18+
strategy:
19+
fail-fast: true
20+
matrix:
21+
env: [preprod, testnet, mainnet]
22+
23+
steps:
24+
# Check out repository with all submodules for complete codebase access.
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: '18'
33+
34+
- name: Install Zeus
35+
run: npm install -g @layr-labs/zeus
36+
37+
# Restore Forge cache
38+
- name: Cache Forge Build
39+
uses: actions/cache@v3
40+
with:
41+
path: |
42+
cache/
43+
out/
44+
key: ${{ runner.os }}-forge-${{ hashFiles('**/foundry.toml', '**/remappings.txt', 'src/**/*.sol', 'lib/**/*.sol') }}
45+
restore-keys: |
46+
${{ runner.os }}-forge-
47+
48+
# Install the Foundry toolchain.
49+
- name: Install Foundry
50+
uses: foundry-rs/foundry-toolchain@v1
51+
with:
52+
version: stable
53+
54+
# Run Forge's formatting checker to ensure consistent code style.
55+
- name: "Forge Fmt"
56+
run: |
57+
forge fmt --check
58+
FOUNDRY_PROFILE=test forge fmt --check
59+
id: fmt
60+
61+
# Build the project and display contract sizes.
62+
- name: Forge Build
63+
run: |
64+
forge --version
65+
forge build --sizes
66+
67+
- name: Validate Solidity Scripts
68+
run: |
69+
# Find all .sol files under /script/releases
70+
RELEASE_FILES=$(find script/releases -type f -name "*.sol" ! -name "Env.sol" 2>/dev/null || echo "")
71+
72+
# Combine file lists
73+
FILES="$RELEASE_FILES"
74+
75+
# Trim leading/trailing whitespace
76+
FILES=$(echo "$FILES" | xargs)
77+
78+
# Exit with success if no files are found
79+
if [ -z "$FILES" ]; then
80+
echo "No .sol files found under /script/releases directories"
81+
exit 0
82+
fi
83+
84+
# Set RPC URL based on environment
85+
if [ "${{ matrix.env }}" = "mainnet" ]; then
86+
RPC_URL="${{ secrets.RPC_MAINNET }}"
87+
else
88+
RPC_URL="${{ secrets.RPC_HOLESKY }}"
89+
fi
90+
91+
# Run zeus test on each file with the specified environment and RPC URL
92+
for file in $FILES; do
93+
echo "Testing $file in ${{ matrix.env }} environment with RPC $RPC_URL..."
94+
zeus test --env ${{ matrix.env }} --rpcUrl "$RPC_URL" "$file"
95+
done

0 commit comments

Comments
 (0)