Skip to content

Commit 530e899

Browse files
committed
Change to reusable
1 parent a7f8060 commit 530e899

File tree

3 files changed

+130
-128
lines changed

3 files changed

+130
-128
lines changed

.github/actions/sharing-smart-contract-common/action.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Sharing Smart Contract - Build and test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
node-version:
7+
description: Node.js version to use
8+
required: true
9+
type: number
10+
default: 18
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ inputs.node-version }}
26+
cache: 'npm' # Cache dependencies
27+
28+
- name: Install Dependencies
29+
working-directory: packages/sharing-smart-contract
30+
shell: bash
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+
shell: bash
45+
run: npm run compile
46+
47+
- name: Check Format
48+
working-directory: packages/sharing-smart-contract
49+
shell: bash
50+
run: npm run check-format
51+
52+
- name: Lint
53+
working-directory: packages/sharing-smart-contract
54+
shell: bash
55+
run: npm run lint
56+
57+
- name: UML Diagrams
58+
working-directory: packages/sharing-smart-contract
59+
shell: bash
60+
run: npm run uml
61+
62+
- name: Static Analyzer
63+
uses: crytic/[email protected]
64+
id: slither
65+
with:
66+
sarif: result.sarif
67+
fail-on: none
68+
target: 'packages/sharing-smart-contract/'
69+
70+
- name: Start Anvil
71+
shell: bash
72+
run: |
73+
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 &
74+
75+
- name: Wait for Anvil to start
76+
shell: bash
77+
run: |
78+
timeout=30
79+
interval=1
80+
echo "Waiting for Anvil to start..."
81+
for ((i=0; i<timeout; i++)); do
82+
if nc -z localhost 8545; then
83+
echo "Anvil is operational."
84+
exit 0
85+
fi
86+
echo "Attempt $((i+1)) of $timeout: Anvil is not ready, waiting ${interval}s..."
87+
sleep $interval
88+
done
89+
echo "Error: Anvil did not start within the timeout period."
90+
exit 1
91+
92+
- name: Upgrade test
93+
working-directory: packages/sharing-smart-contract
94+
shell: bash
95+
run: npm run upgrade-local-fork -- --network local-bellecour-fork
96+
97+
# TODO check why the CI does not fail when the following error occurs
98+
# (when the RPC node is not available):
99+
# 1) Uncaught error outside test suite
100+
- name: Hardhat tests
101+
working-directory: packages/sharing-smart-contract
102+
shell: bash
103+
run: npm run test -- --network local-bellecour-fork
104+
105+
- name: Test deployment script
106+
working-directory: packages/sharing-smart-contract
107+
shell: bash
108+
run: |
109+
POCO_ADDRESS=0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f \
110+
DATASET_REGISTRY_ADDRESS=0x799DAa22654128d0C64d5b79eac9283008158730 \
111+
npm run deploy -- --network local-bellecour-fork
112+
113+
- name: Set Directory Permissions
114+
working-directory: packages/sharing-smart-contract
115+
shell: bash
116+
run: sudo chmod -R 777 .
117+
118+
- name: Forge Tests
119+
working-directory: packages/sharing-smart-contract
120+
shell: bash
121+
run: forge test --no-match-test "invariant" -vvvv
122+
123+
- name: Upload SARIF file
124+
uses: github/codeql-action/upload-sarif@v3
125+
with:
126+
sarif_file: ${{ steps.slither.outputs.sarif }}

.github/workflows/sharing-smart-contract-ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
1516
build-and-test:
16-
runs-on: ubuntu-latest
17-
permissions:
18-
contents: write
19-
steps:
20-
- uses: actions/checkout@v4
21-
- uses: ./.github/actions/sharing-smart-contract-common
22-
with:
23-
node-version: '18'
17+
uses: ./.github/workflows/reusable/sharing-smart-contracts-common.yml
18+
with:
19+
node-version: 18

0 commit comments

Comments
 (0)