|
| 1 | +name: CI Sharing Smart Contract |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + paths: |
| 8 | + - 'packages/sharing-smart-contract/**' |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.ref }}-sharing-smart-contract-tests |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-test: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: '18' |
| 28 | + |
| 29 | + - name: Install Dependencies |
| 30 | + working-directory: packages/sharing-smart-contract |
| 31 | + run: | |
| 32 | + node -v |
| 33 | + npm -v |
| 34 | + npm ci |
| 35 | +
|
| 36 | + - name: Install Foundry |
| 37 | + uses: foundry-rs/foundry-toolchain@v1 |
| 38 | + with: |
| 39 | + version: stable |
| 40 | + cache: true |
| 41 | + |
| 42 | + - name: Compile |
| 43 | + working-directory: packages/sharing-smart-contract |
| 44 | + run: npm run compile |
| 45 | + |
| 46 | + - name: Check Format |
| 47 | + working-directory: packages/sharing-smart-contract |
| 48 | + run: npm run check-format |
| 49 | + |
| 50 | + - name: Lint |
| 51 | + working-directory: packages/sharing-smart-contract |
| 52 | + run: npm run lint |
| 53 | + |
| 54 | + - name: UML Diagrams |
| 55 | + working-directory: packages/sharing-smart-contract |
| 56 | + run: npm run uml |
| 57 | + |
| 58 | + - name: Static Analyzer |
| 59 | + |
| 60 | + id: slither |
| 61 | + with: |
| 62 | + sarif: result.sarif |
| 63 | + fail-on: none |
| 64 | + target: 'packages/sharing-smart-contract/' |
| 65 | + |
| 66 | + - name: Start Anvil |
| 67 | + run: | |
| 68 | + anvil --host 0.0.0.0 --port 8545 --hardfork berlin --fork-url https://bellecour.iex.ec --chain-id 134 --gas-limit 6700000 --gas-price 0 & |
| 69 | +
|
| 70 | + - name: Wait for Anvil to start |
| 71 | + run: | |
| 72 | + timeout=30 |
| 73 | + interval=1 |
| 74 | + echo "Waiting for Anvil to start..." |
| 75 | + for ((i=0; i<timeout; i++)); do |
| 76 | + if nc -z localhost 8545; then |
| 77 | + echo "Anvil is operational." |
| 78 | + exit 0 |
| 79 | + fi |
| 80 | + echo "Attempt $((i+1)) of $timeout: Anvil is not ready, waiting ${interval}s..." |
| 81 | + sleep $interval |
| 82 | + done |
| 83 | + echo "Error: Anvil did not start within the timeout period." |
| 84 | + exit 1 |
| 85 | +
|
| 86 | + - name: Hardhat Tests |
| 87 | + working-directory: packages/sharing-smart-contract |
| 88 | + run: npm run test -- --network ci-bellecour-fork |
| 89 | + |
| 90 | + - name: Upgrade Test |
| 91 | + working-directory: packages/sharing-smart-contract |
| 92 | + run: npm run upgrade-local-fork -- --network local-bellecour-fork |
| 93 | + |
| 94 | + - name: Set Directory Permissions |
| 95 | + working-directory: packages/sharing-smart-contract |
| 96 | + run: sudo chmod -R 777 . |
| 97 | + |
| 98 | + - name: Forge Tests |
| 99 | + working-directory: packages/sharing-smart-contract |
| 100 | + run: forge test --no-match-test "invariant" -vvvv |
| 101 | + |
| 102 | + - name: Upload SARIF file |
| 103 | + uses: github/codeql-action/upload-sarif@v3 |
| 104 | + with: |
| 105 | + sarif_file: ${{ steps.slither.outputs.sarif }} |
0 commit comments