|
| 1 | +name: Sharing Smart Contract - Build and test |
| 2 | +description: Composite action to build and test the Sharing Smart Contract |
| 3 | + |
| 4 | +inputs: |
| 5 | + node-version: |
| 6 | + description: Node.js version to use |
| 7 | + required: true |
| 8 | + default: '18' |
| 9 | + |
| 10 | +runs: |
| 11 | + using: "composite" |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: ${{ inputs.node-version }} |
| 20 | + cache: 'npm' # Cache dependencies |
| 21 | + |
| 22 | + - name: Install Dependencies |
| 23 | + working-directory: packages/sharing-smart-contract |
| 24 | + run: | |
| 25 | + node -v |
| 26 | + npm -v |
| 27 | + npm ci |
| 28 | +
|
| 29 | + - name: Install Foundry |
| 30 | + uses: foundry-rs/foundry-toolchain@v1 |
| 31 | + with: |
| 32 | + version: stable |
| 33 | + cache: true |
| 34 | + |
| 35 | + - name: Compile |
| 36 | + working-directory: packages/sharing-smart-contract |
| 37 | + run: npm run compile |
| 38 | + |
| 39 | + - name: Check Format |
| 40 | + working-directory: packages/sharing-smart-contract |
| 41 | + run: npm run check-format |
| 42 | + |
| 43 | + - name: Lint |
| 44 | + working-directory: packages/sharing-smart-contract |
| 45 | + run: npm run lint |
| 46 | + |
| 47 | + - name: UML Diagrams |
| 48 | + working-directory: packages/sharing-smart-contract |
| 49 | + run: npm run uml |
| 50 | + |
| 51 | + - name: Static Analyzer |
| 52 | + |
| 53 | + id: slither |
| 54 | + with: |
| 55 | + sarif: result.sarif |
| 56 | + fail-on: none |
| 57 | + target: 'packages/sharing-smart-contract/' |
| 58 | + |
| 59 | + - name: Start Anvil |
| 60 | + run: | |
| 61 | + 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 & |
| 62 | +
|
| 63 | + - name: Wait for Anvil to start |
| 64 | + run: | |
| 65 | + timeout=30 |
| 66 | + interval=1 |
| 67 | + echo "Waiting for Anvil to start..." |
| 68 | + for ((i=0; i<timeout; i++)); do |
| 69 | + if nc -z localhost 8545; then |
| 70 | + echo "Anvil is operational." |
| 71 | + exit 0 |
| 72 | + fi |
| 73 | + echo "Attempt $((i+1)) of $timeout: Anvil is not ready, waiting ${interval}s..." |
| 74 | + sleep $interval |
| 75 | + done |
| 76 | + echo "Error: Anvil did not start within the timeout period." |
| 77 | + exit 1 |
| 78 | +
|
| 79 | + - name: Upgrade test |
| 80 | + working-directory: packages/sharing-smart-contract |
| 81 | + run: npm run upgrade-local-fork -- --network local-bellecour-fork |
| 82 | + |
| 83 | + # TODO check why the CI does not fail when the following error occurs |
| 84 | + # (when the RPC node is not available): |
| 85 | + # 1) Uncaught error outside test suite |
| 86 | + - name: Hardhat tests |
| 87 | + working-directory: packages/sharing-smart-contract |
| 88 | + run: npm run test -- --network local-bellecour-fork |
| 89 | + |
| 90 | + - name: Test deployment script |
| 91 | + working-directory: packages/sharing-smart-contract |
| 92 | + run: | |
| 93 | + POCO_ADDRESS=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f \ |
| 94 | + DATASET_REGISTRY_ADDRESS=0x799DAa22654128d0C64d5b79eac9283008158730 \ |
| 95 | + npm run deploy -- --network local-bellecour-fork |
| 96 | +
|
| 97 | + - name: Set Directory Permissions |
| 98 | + working-directory: packages/sharing-smart-contract |
| 99 | + run: sudo chmod -R 777 . |
| 100 | + |
| 101 | + - name: Forge Tests |
| 102 | + working-directory: packages/sharing-smart-contract |
| 103 | + run: forge test --no-match-test "invariant" -vvvv |
| 104 | + |
| 105 | + - name: Upload SARIF file |
| 106 | + uses: github/codeql-action/upload-sarif@v3 |
| 107 | + with: |
| 108 | + sarif_file: ${{ steps.slither.outputs.sarif }} |
0 commit comments