Skip to content

Commit

Permalink
enchance contracts and subgraph CD workflows (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
portuu3 authored Apr 25, 2023
1 parent 12c9e7c commit 761ff97
Show file tree
Hide file tree
Showing 7 changed files with 948 additions and 14 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/cd-deploy-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
deploy-contracts:
name: Deploy contracts
runs-on: ubuntu-latest
environment: deploy-contracts
strategy:
matrix:
network: [
Expand All @@ -22,6 +23,7 @@ jobs:
reward_pool: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
reputation: '0x6B220A6306D8D86C9878A1FBb3F49707b3E2b405',
private_key: TESTNET_PRIVATE_KEY,
subgraph: 'goerli-v1'
},
{
name: polygon,
Expand All @@ -30,6 +32,7 @@ jobs:
reward_pool: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
# reputation:
private_key: MAINNET_PRIVATE_KEY,
subgraph: 'polygon-v1'
},
{
name: polygonMumbai,
Expand All @@ -38,6 +41,7 @@ jobs:
reward_pool: '0xf0145eD99AC3c4f877aDa7dA4D1E059ec9116BAE',
reputation: '0xC522463d36f76b881bE66484e3068F11e7038Ace',
private_key: TESTNET_PRIVATE_KEY,
subgraph: 'mumbai-v1'
},
{
name: bsc,
Expand All @@ -46,6 +50,7 @@ jobs:
reward_pool: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
# reputation:
private_key: MAINNET_PRIVATE_KEY,
subgraph: 'bsc-v1'
},
{
name: bscTestnet,
Expand All @@ -54,6 +59,7 @@ jobs:
reward_pool: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
reputation: '0xb8F62639aA3DD51A39d6AACD969363e7F87dcc98',
private_key: TESTNET_PRIVATE_KEY,
subgraph: 'bsctest-v1'
},
{
name: moonbeam,
Expand All @@ -62,6 +68,7 @@ jobs:
reward_pool: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
# reputation:
private_key: MAINNET_PRIVATE_KEY,
subgraph: 'moonbeam-v1'
},
{
name: moonbaseAlpha,
Expand All @@ -70,13 +77,15 @@ jobs:
reward_pool: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
reputation: '0x87469B4f2Fcf37cBd34E54244c0BD4Fa0603664c',
private_key: TESTNET_PRIVATE_KEY,
subgraph: 'moonbase-alpha-v1'
},
{
name: mainnet,
escrow_factory: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
staking: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
reward_pool: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
private_key: MAINNET_PRIVATE_KEY,
subgraph: 'mainnet-v1'
}
# {
# name: avalanche,
Expand Down Expand Up @@ -123,6 +132,7 @@ jobs:
# SKALE_API_KEY: ${{ secrets.SKALE_API_KEY }}
# SKALE_BROWSER_API_URL: ${{ secrets.SKALE_BROWSER_API_URL }}
# SKALE_BROWSER_URL: ${{ secrets.SKALE_BROWSER_URL }}
SUBGRAPH: ${{ matrix.network.subgraph }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -136,13 +146,20 @@ jobs:
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
filters: |
escrow_factory:
- 'packages/core/contracts/Escrow*.sol'
- 'packages/core/contracts/interfaces/IStaking.sol'
staking:
- 'packages/core/contracts/Staking.sol'
- 'packages/core/contracts/libs/Stakes.sol'
- 'packages/core/contracts/interfaces/IStaking.sol'
- 'packages/core/contracts/interfaces/IRewardPool.sol'
- 'packages/core/contracts/interfaces/IEscrow.sol'
reward_pool:
- 'packages/core/contracts/RewardPool.sol'
- 'packages/core/contracts/interfaces/IRewardPool.sol'
reputation:
- 'packages/core/contracts/Reputation.sol'
Expand Down Expand Up @@ -207,6 +224,11 @@ jobs:
if: ${{ success() }}
uses: EndBug/add-and-commit@v9
with:
add: './packages/core/.openzeppelin'
message: 'chore(generated): update generated network data automatically'
add: "['./packages/core/.openzeppelin', './packages/sdk/typescript/subgraph/config']"
message: 'Update grafting and upgrade file from CD'
default_author: github_actions
- name: Trigger Another Workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Subgraph deployment
inputs: '{ "subgraph-name": "${{ matrix.network.subgraph }}" }'
34 changes: 34 additions & 0 deletions .github/workflows/cd-subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,32 @@ on:
paths:
- packages/sdk/typescript/subgraph/**
- .github/workflows/cd-subgraph.yaml
workflow_dispatch:
inputs:
subgraph-name:
description: 'subgraph name'
required: true

jobs:
contracts-check:
runs-on: ubuntu-latest
outputs:
contracts_updated: ${{ steps.filter.outputs.contracts }}
steps:
- uses: actions/checkout@v3
- name: Check changes in files
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
filters: |
contracts:
- 'packages/core/contracts/**'
subgraph:
name: Deploy Subgraph
needs: contracts-check
runs-on: ubuntu-latest

strategy:
matrix:
network:
Expand Down Expand Up @@ -39,25 +60,38 @@ jobs:
# graph: skale
fail-fast: true
max-parallel: 3
if: ${{ needs.contracts-check.outputs.contracts_updated != 'true' || github.event.inputs.subgraph-name }}
steps:
- uses: actions/checkout@v3
- name: Continue check
id: continue_check
run: |
if [[ ${{ needs.contracts-check.outputs.contracts_updated}} == 'true' && "${{ github.event.inputs.subgraph-name }}" != "${{ matrix.network.graph }}" ]]; then
echo "stop=true" >> $GITHUB_OUTPUT
fi
- run: yarn --ignore-scripts
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Install dependencies
- run: yarn compile
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Compile smart contracts
working-directory: ./packages/core
- run: yarn global add @graphprotocol/graph-cli
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Install Graph CLI
- run: graph auth --product hosted-service ${API_KEY}
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Authenticate Graph CLI
env:
API_KEY: ${{ secrets.HP_GRAPH_API_KEY }}
- run: yarn generate
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Generate Subgraph
working-directory: ./packages/sdk/typescript/subgraph
env:
NETWORK: ${{ matrix.network.graph }}
- run: graph deploy --product hosted-service humanprotocol/${NETWORK}
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Deploy Subgraph
working-directory: ./packages/sdk/typescript/subgraph
env:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
]
},
"devDependencies": {
"@apollo/client": "^3.7.12",
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
Expand Down
Loading

1 comment on commit 761ff97

@vercel
Copy link

@vercel vercel bot commented on 761ff97 Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fortune-exchange-oracle-server – ./packages/examples/fortune/exchange-oracle/server

fortune-exchange-oracle-server-git-develop-humanprotocol.vercel.app
fortune-exchange-oracle-server-humanprotocol.vercel.app
fortune-exchange-oracle-server.vercel.app

Please sign in to comment.