Skip to content

Commit 5c95528

Browse files
committed
refactor: consolidate CI workflows and update environment variables for smart contract deployment
1 parent 37261db commit 5c95528

File tree

7 files changed

+42
-85
lines changed

7 files changed

+42
-85
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: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,33 @@ on:
1111
- hardhat
1212
- avalancheFujiTestnet
1313
- arbitrumSepolia
14+
- arbitrum
1415
- bellecour
1516
default: 'hardhat'
16-
environment:
17-
description: 'Environment'
18-
required: true
19-
type: choice
20-
options:
21-
- testnets
22-
- mainnets
23-
default: 'testnets'
2417

2518
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-
4619
# Build and test before deploying.
47-
ci:
48-
needs: validate
49-
uses: ./.github/workflows/sharing-smart-contracts-reusable.yml
20+
build-and-test:
21+
uses: ./.github/workflows/sharing-smart-contracts-ci.yml
5022
with:
51-
node-version: 18
23+
node-version: 20
5224

5325
# Deploy and verify contract.
5426
deploy:
55-
needs: ci
27+
needs: build-and-test
5628
runs-on: ubuntu-latest
5729
permissions:
5830
contents: write # Required to commit deployment files.
59-
environment: ${{ inputs.environment }}
31+
environment: ${{ inputs.network }}
6032
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-
7333
- uses: actions/checkout@v4
7434
with:
75-
fetch-depth: 0
35+
submodules: recursive
7636

7737
- uses: actions/setup-node@v4
7838
with:
79-
node-version: 18
39+
node-version: 20
40+
cache: 'npm'
8041

8142
- name: Install dependencies
8243
working-directory: packages/sharing-smart-contract
@@ -90,7 +51,15 @@ jobs:
9051

9152
- name: Deploy contracts
9253
working-directory: packages/sharing-smart-contract
93-
run: npm run deploy -- --network ${{ inputs.network }}
54+
env:
55+
# For Deployment
56+
RPC_URL: ${{ secrets.RPC_URL }}
57+
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
58+
POCO_ADDRESS: ${{ env.POCO_ADDRESS }}
59+
DATASET_REGISTRY_ADDRESS: ${{ env.DATASET_REGISTRY_ADDRESS }}
60+
# For Verification
61+
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
62+
run: npm run deploy -- --network ${{ inputs.network }} --deployment-id ${{ inputs.network }} --verify
9463

9564
- name: Save deployment artifacts
9665
if: inputs.network != 'hardhat'
@@ -101,7 +70,3 @@ jobs:
10170
commit_user_name: 'GitHub Actions Bot'
10271
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
10372
commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
104-
105-
- name: Verify contracts
106-
working-directory: packages/sharing-smart-contract
107-
run: echo "TODO" # npm run verify:ignition -- $DEPLOYMENT_ID

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
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
813
required: true
914
type: number
10-
default: 18
15+
default: 20
16+
17+
concurrency:
18+
group: ${{ github.ref }}-sharing-smart-contract-ci
19+
cancel-in-progress: true
1120

1221
jobs:
1322
build-and-test:
@@ -23,6 +32,7 @@ jobs:
2332
- uses: actions/setup-node@v4
2433
with:
2534
node-version: ${{ inputs.node-version }}
35+
cache: 'npm'
2636

2737
- name: Install Dependencies
2838
working-directory: packages/sharing-smart-contract
@@ -51,12 +61,13 @@ jobs:
5161
run: npm run uml
5262

5363
- name: Static Analyzer
54-
uses: crytic/[email protected].0
64+
uses: crytic/[email protected].1
5565
id: slither
5666
with:
57-
sarif: result.sarif
58-
fail-on: none
5967
target: 'packages/sharing-smart-contract/'
68+
slither-args: --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/
69+
fail-on: none
70+
sarif: result.sarif
6071

6172
- name: Start Anvil
6273
run: |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# wallet used for transactions
2-
PRIVATE_KEY=...
2+
DEPLOYER_PRIVATE_KEY=...
33

44
# environment to use for configuration (prod/staging). The default is prod.
55
ENV=...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

packages/sharing-smart-contract/hardhat.config.cjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ module.exports = {
3535
bellecour: {
3636
...bellecourBase,
3737
url: 'https://bellecour.iex.ec',
38-
accounts: env.PRIVATE_KEY ? [env.PRIVATE_KEY] : [],
38+
accounts: env.DEPLOYER_PRIVATE_KEY ? [env.DEPLOYER_PRIVATE_KEY] : [],
3939
},
4040
avalancheFujiTestnet: {
4141
chainId: 43113,
42-
url: env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc',
42+
url: env.RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc',
4343
accounts: [
44-
env.PRIVATE_KEY ||
44+
env.DEPLOYER_PRIVATE_KEY ||
4545
'0x0000000000000000000000000000000000000000000000000000000000000000',
4646
],
4747
blockGasLimit: 8_000_000,
4848
},
4949
arbitrumSepolia: {
5050
chainId: 421614,
51-
url: env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc',
51+
url: env.RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc',
5252
accounts: [
53-
env.PRIVATE_KEY ||
53+
env.DEPLOYER_PRIVATE_KEY ||
5454
'0x0000000000000000000000000000000000000000000000000000000000000000',
5555
],
5656
blockGasLimit: 30_000_000,

packages/sharing-smart-contract/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"clean": "hardhat clean",
1010
"compile": "hardhat clean && hardhat compile && npm run artifact-to-abis",
1111
"verify:ignition": "hardhat ignition verify --include-unrelated-contracts",
12-
"verify": "hardhat verify",
1312
"deploy": "hardhat run scripts/deploy.js",
1413
"update-env": "hardhat run ./scripts/updateEnv.js",
1514
"upgrade": "hardhat run ./scripts/upgrade.js",
@@ -58,4 +57,4 @@
5857
"iexec": "^8.15.0",
5958
"rimraf": "^6.0.1"
6059
}
61-
}
60+
}

0 commit comments

Comments
 (0)