|
| 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