Skip to content

Commit bab0e44

Browse files
Le-CaignecgfournierProzguesmigithub-actions[bot]
authored
ci/dataProtector sharing fix ci (#469)
* feat: add core smart contract CI and deploy workflows with environment configuration * refactor: consolidate CI workflows and update environment variables for smart contract deployment * feat: enhance deployment workflow with environment selection and Arbitrum support * fix: update changelog to reference Arbitrum mainnet deployment issue #469 * fix: update deploy script to use ignition module for DataProtectorSharing * fix: remove unused Arbitrum API key references from hardhat config * fix: update cache configuration for node setup in CI workflow * feat: add admin private key support for deployment and configuration * fix: rollback for less change * fix: correct proxy address reference for DataProtectorSharing import * feat: add deployment ID support for DataProtectorSharing contract deployment * feat: add deployment ID output and verification step for contract deployment * fix: format deployment ID parsing for better readability * fix: remove a deployement folder * fix: add missing admin private key comment in .env.template * feat: add validation for mainnet deployment environment in workflow * fix: tmp * feat: re-enable manual trigger * fix: comment out manual trigger inputs in deployment workflow * feat: re-enable manual trigger inputs in deployment workflow * feat: add deployment ID support for Hardhat Ignition in environment configuration and deployment script * fix: Remove useless check * feat: enhance account management by adding support for ADMIN_PRIVATE_KEY in Hardhat configuration and DataProtectorSharingModule * chore: comment out build-and-test job in deployment workflow to test * feat: update Hardhat configuration to simplify account management for private keys * feat: enhance deployment process with improved error handling and fallback strategy for CREATE2 * feat: add logging for proxy admin owner selection in DataProtectorSharingModule * fix: remove unnecessary deployment-id from verification command in sharing-smart-contract deployment workflow * fix: remove redundant fallback to DEPLOYER_PRIVATE_KEY in Hardhat configuration * fix: update salt value for CREATE2 strategy configuration in Hardhat setup * refactor: streamline deployment process by removing fallback logic for CREATE2 strategy * fix: remove unnecessary flag from verification command in sharing-smart-contract deployment workflow * fix: update salt value for CREATE2 strategy in Hardhat configuration * fix: update verification command to include deployment ID in sharing-smart-contract deployment workflow * fix: update salt value for CREATE2 strategy in sharing-smart-contract configuration * fix: correct logging of proxy admin owner by removing .address reference * fix: update salt value for CREATE2 strategy in hardhat configuration * fix: add step to save deployment artifacts in sharing-smart-contract workflow * fix: update salt value for CREATE2 strategy in hardhat configuration * chore: save deployment artifacts for arbitrumSepolia dev (16524739368) * fix: remove verification step for hardhat network and add TODO note * chore: remove deployment folder * fix: update salt value for CREATE2 strategy in hardhat configuration * fix: uncomment build-and-test job in deployment workflow * chore: remove unused .openzeppelin configuration file --------- Co-authored-by: gfournieriExec <[email protected]> Co-authored-by: Zied <[email protected]> Co-authored-by: GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>
1 parent 5ca5d6c commit bab0e44

27 files changed

+163
-237040
lines changed

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,42 @@ on:
1111
- hardhat
1212
- avalancheFujiTestnet
1313
- arbitrumSepolia
14+
- arbitrum
1415
- bellecour
1516
default: 'hardhat'
1617
environment:
1718
description: 'Environment'
1819
required: true
1920
type: choice
2021
options:
21-
- testnets
22-
- mainnets
23-
default: 'testnets'
22+
- dev
23+
- prod
24+
default: 'dev'
2425

2526
jobs:
26-
27-
# Validate deployment network and environment.
28-
validate:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
with:
33-
fetch-depth: 0
34-
35-
# On Github, the environment `mainnets` is restricted to
36-
# the main branch. Here we check that it's only used with
37-
# mainnet networks.
38-
- name: Validate mainnet deployment
39-
run: |
40-
if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" != "bellecour" ]]; then
41-
echo "::error::mainnets environment can only be used with mainnet networks."
42-
exit 1
43-
fi
44-
echo "Deploying to network '${{ inputs.network }}' with environment '${{ inputs.environment }}'."
45-
46-
# Build and test before deploying.
47-
ci:
48-
needs: validate
49-
uses: ./.github/workflows/sharing-smart-contracts-reusable.yml
27+
build-and-test:
28+
uses: ./.github/workflows/sharing-smart-contracts-ci.yml
5029
with:
51-
node-version: 18
30+
node-version: 20
5231

53-
# Deploy and verify contract.
5432
deploy:
55-
needs: ci
33+
# needs: build-and-test
5634
runs-on: ubuntu-latest
35+
env:
36+
CI: true
5737
permissions:
5838
contents: write # Required to commit deployment files.
59-
environment: ${{ inputs.environment }}
39+
environment: ${{ inputs.network }}
6040
steps:
61-
- name: Set environment variables
62-
id: set-env
63-
run: |
64-
echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV
65-
66-
if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
67-
echo "POCO_ADDRESS=0x14B465079537655E1662F012e99EBa3863c8B9E0" >> $GITHUB_ENV
68-
echo "DATASET_REGISTRY_ADDRESS=0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D" >> $GITHUB_ENV
69-
echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV
70-
echo "DEPLOYMENT_ID=chain-421614" >> $GITHUB_ENV
71-
fi
72-
7341
- uses: actions/checkout@v4
7442
with:
7543
fetch-depth: 0
7644

7745
- uses: actions/setup-node@v4
7846
with:
79-
node-version: 18
47+
node-version: 20
48+
cache: 'npm'
49+
cache-dependency-path: 'packages/sharing-smart-contract'
8050

8151
- name: Install dependencies
8252
working-directory: packages/sharing-smart-contract
@@ -88,20 +58,62 @@ jobs:
8858
version: stable
8959
cache: true
9060

61+
- name: Validate deployment environment and prepare variables
62+
if: inputs.network != 'hardhat'
63+
run: |
64+
NETWORK="${{ inputs.network }}"
65+
ENVIRONMENT="${{ inputs.environment }}"
66+
67+
case "$NETWORK" in
68+
arbitrum|bellecour)
69+
if [ "$ENVIRONMENT" = "dev" ]; then
70+
echo "Error: Cannot deploy to mainnet ($NETWORK) with dev environment"
71+
exit 1
72+
fi
73+
echo "IS_MAINNET=true" >> $GITHUB_ENV
74+
;;
75+
*)
76+
echo "IS_MAINNET=false" >> $GITHUB_ENV
77+
;;
78+
esac
79+
9180
- name: Deploy contracts
81+
id: deploy
9282
working-directory: packages/sharing-smart-contract
93-
run: npm run deploy -- --network ${{ inputs.network }}
83+
env:
84+
# For Deployment
85+
RPC_URL: ${{ secrets.RPC_URL }}
86+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
87+
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
88+
POCO_ADDRESS: ${{ vars.POCO_ADDRESS }}
89+
DATASET_REGISTRY_ADDRESS: ${{ vars.DATASET_REGISTRY_ADDRESS }}
90+
run: |
91+
if [ "${{ inputs.network }}" = "hardhat" ]; then
92+
npm run deploy -- --network ${{ inputs.network }}
93+
else
94+
# For testnets, use network-environment; for mainnets, use network only
95+
if [ "$IS_MAINNET" = false ]; then
96+
DEPLOYMENT_ID="${{ inputs.network }}-${{ inputs.environment }}"
97+
else
98+
DEPLOYMENT_ID="${{ inputs.network }}"
99+
fi
100+
echo "deployment-id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
101+
POCO_ADDRESS="${{ vars.POCO_ADDRESS }}" \
102+
DATASET_REGISTRY_ADDRESS="${{ vars.DATASET_REGISTRY_ADDRESS }}" \
103+
DEPLOYMENT_ID="$DEPLOYMENT_ID" \
104+
npm run deploy -- --network ${{ inputs.network }}
105+
fi
94106
95107
- name: Save deployment artifacts
96108
if: inputs.network != 'hardhat'
97109
uses: stefanzweifel/git-auto-commit-action@v5
98110
with:
99-
commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})'
111+
commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} ${{ inputs.environment }} (${{ github.run_id }})'
100112
file_pattern: 'packages/sharing-smart-contract/ignition/deployments/* packages/sharing-smart-contract/.openzeppelin/*'
101113
commit_user_name: 'GitHub Actions Bot'
102114
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
103115
commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
104116

105117
- name: Verify contracts
106-
working-directory: packages/sharing-smart-contract
107-
run: echo "TODO" # npm run verify:ignition -- $DEPLOYMENT_ID
118+
# TODO
119+
run: echo "Verification step is not implemented yet"

.github/workflows/sharing-smart-contracts-reusable.yml renamed to .github/workflows/sharing-smart-contracts-ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
name: Sharing Smart Contract - Reusable
1+
name: Sharing Smart Contract - Default
22

33
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
paths:
8+
- 'packages/sharing-smart-contract/**'
49
workflow_call:
510
inputs:
611
node-version:
712
description: Node.js version to use
8-
required: true
13+
required: false
914
type: number
10-
default: 18
15+
default: 20
1116

1217
jobs:
1318
build-and-test:
@@ -23,6 +28,8 @@ jobs:
2328
- uses: actions/setup-node@v4
2429
with:
2530
node-version: ${{ inputs.node-version }}
31+
cache: 'npm'
32+
cache-dependency-path: 'packages/sharing-smart-contract'
2633

2734
- name: Install Dependencies
2835
working-directory: packages/sharing-smart-contract
@@ -42,7 +49,7 @@ jobs:
4249
working-directory: packages/sharing-smart-contract
4350
run: npm run check-format
4451

45-
- name: Lint
52+
- name: Check Lint
4653
working-directory: packages/sharing-smart-contract
4754
run: npm run lint
4855

@@ -51,12 +58,13 @@ jobs:
5158
run: npm run uml
5259

5360
- name: Static Analyzer
54-
uses: crytic/[email protected].0
61+
uses: crytic/[email protected].1
5562
id: slither
5663
with:
57-
sarif: result.sarif
58-
fail-on: none
5964
target: 'packages/sharing-smart-contract/'
65+
slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
66+
fail-on: none
67+
sarif: result.sarif
6068

6169
- name: Start Anvil
6270
run: |

packages/sharing-smart-contract/.env.template

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# wallet used for transactions
2-
PRIVATE_KEY=...
2+
DEPLOYER_PRIVATE_KEY=...
3+
4+
# wallet used for admin operations
5+
ADMIN_PRIVATE_KEY=...
36

47
# environment to use for configuration (prod/staging). The default is prod.
58
ENV=...
@@ -16,4 +19,11 @@ RPC_URL=
1619
## Mnemonic for the network
1720
MNEMONIC=
1821

19-
ETHERSCAN_API_KEY=
22+
## API key to verify contracts
23+
EXPLORER_API_KEY=
24+
25+
## Whether to use API V2 verification format
26+
IS_VERIFICATION_API_V2=
27+
## Deployment ID for Hardhat Ignition
28+
29+
DEPLOYMENT_ID=...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

0 commit comments

Comments
 (0)