Skip to content

Commit a96d680

Browse files
authored
Merge pull request #119 from threshold-network/ci-dapp-dev
Add job deploying contracts from `dapp-development` branch There are situations when team developing T Token Dashboard needs to locally test some functionalities using modified contracts, for example ones with shorter authorization decrease delay. We decided to create a `dapp-development` branch in each of the upstream modules of `threshold-network/token-dashboard` CI module, which would store the code of these modified contracts. In this PR we create a `contracts-dapp-development-deployment-testnet` job which deploys the contracts, creates an NPM package (with `dappdev<environment>` suffix an `dapp-development-<environment>` tag) and publishes it to the NPM registry. At the end, the job also starts similar deployment for a downstream module. The job gets triggered only as a result of `workflow_dispath` event from a `dapp-development` branch. Currently only `goerli` environment is supported. We don't run system and unit tests for `dapp-development` branch, as the tests are not configured to work with the modified contracts. Generally, the goal of the changes is to have the full set of dapp-development-friendly contracts deployed to the NPM registry, so that the dApp developers could quickly use them by upgrading the `token-dashboard` dependencies using `yarn upgrade <package-name>@dapp-development-goerli`. If the workflow gets dispatched from a different branch than `dapp-development`, the deploy will behave as it used to, publishing package with deployed unmodified contracts to the NPM registry under `<environment>` tag.
2 parents 73d02b1 + 944d392 commit a96d680

File tree

3 files changed

+102
-24
lines changed

3 files changed

+102
-24
lines changed

.github/workflows/contracts.yaml

Lines changed: 98 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ on:
77
branches:
88
- main
99
pull_request:
10+
# We intend to use `workflow dispatch` in two different situations/paths:
11+
# 1. If a workflow will be manually dspatched from branch named
12+
# `dapp-development`, workflow will deploy the contracts on the selected
13+
# testnet and publish them to NPM registry with `dapp-dev-<environment>`
14+
# suffix and `dapp-development-<environment>` tag. Such packages are meant
15+
# to be used locally by the team developing Threshold Token dApp and may
16+
# contain contracts that have different values from the ones used on
17+
# mainnet.
18+
# 2. If a workflow will be manually dspatched from a branch which name is not
19+
# `dapp-development`, the workflow will deploy the contracts on the
20+
# selected testnet and publish them to NPM registry with `<environment>`
21+
# suffix and tag. Such packages will be used later to deploy public
22+
# Threshold Token dApp on a testnet, with contracts resembling those used
23+
# on mainnet.
1024
workflow_dispatch:
1125
inputs:
1226
environment:
13-
description: "Environment for workflow execution"
27+
description: "Environment (network) for workflow execution, e.g. `goerli`"
1428
required: false
15-
default: "dev"
1629
upstream_builds:
1730
description: "Upstream builds"
1831
required: false
@@ -27,7 +40,7 @@ jobs:
2740
outputs:
2841
system-tests: ${{ steps.filter.outputs.system-tests }}
2942
steps:
30-
- uses: actions/checkout@v2
43+
- uses: actions/checkout@v3
3144
if: github.event_name == 'pull_request'
3245

3346
- uses: dorny/paths-filter@v2
@@ -42,9 +55,9 @@ jobs:
4255
contracts-build-and-test:
4356
runs-on: ubuntu-latest
4457
steps:
45-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v3
4659

47-
- uses: actions/setup-node@v2
60+
- uses: actions/setup-node@v3
4861
with:
4962
node-version: "14.x"
5063
cache: "yarn"
@@ -56,16 +69,19 @@ jobs:
5669
run: yarn build
5770

5871
- name: Run tests
72+
if: github.ref != 'refs/heads/dapp-development'
5973
run: yarn test
6074

6175
contracts-system-tests:
6276
needs: contracts-detect-changes
63-
if: needs.contracts-detect-changes.outputs.system-tests == 'true'
77+
if: |
78+
needs.contracts-detect-changes.outputs.system-tests == 'true'
79+
&& github.ref != 'refs/heads/dapp-development'
6480
runs-on: ubuntu-latest
6581
steps:
66-
- uses: actions/checkout@v2
82+
- uses: actions/checkout@v3
6783

68-
- uses: actions/setup-node@v2
84+
- uses: actions/setup-node@v3
6985
with:
7086
node-version: "14.x"
7187
cache: "yarn"
@@ -84,9 +100,9 @@ jobs:
84100
contracts-deployment-dry-run:
85101
runs-on: ubuntu-latest
86102
steps:
87-
- uses: actions/checkout@v2
103+
- uses: actions/checkout@v3
88104

89-
- uses: actions/setup-node@v2
105+
- uses: actions/setup-node@v3
90106
with:
91107
node-version: "14.x"
92108
cache: "yarn"
@@ -99,12 +115,14 @@ jobs:
99115

100116
contracts-deployment-testnet:
101117
needs: [contracts-build-and-test]
102-
if: github.event_name == 'workflow_dispatch'
118+
if: |
119+
github.event_name == 'workflow_dispatch'
120+
&& github.ref != 'refs/heads/dapp-development'
103121
runs-on: ubuntu-latest
104122
steps:
105-
- uses: actions/checkout@v2
123+
- uses: actions/checkout@v3
106124

107-
- uses: actions/setup-node@v2
125+
- uses: actions/setup-node@v3
108126
with:
109127
node-version: "14.x"
110128
cache: "yarn"
@@ -154,7 +172,7 @@ jobs:
154172
version: ${{ steps.npm-version-bump.outputs.version }}
155173

156174
- name: Upload files needed for etherscan verification
157-
uses: actions/upload-artifact@v2
175+
uses: actions/upload-artifact@v3
158176
with:
159177
name: Artifacts for etherscan verifcation
160178
path: |
@@ -166,14 +184,14 @@ jobs:
166184
needs: [contracts-deployment-testnet]
167185
runs-on: ubuntu-latest
168186
steps:
169-
- uses: actions/checkout@v2
187+
- uses: actions/checkout@v3
170188

171189
- name: Download files needed for etherscan verification
172-
uses: actions/download-artifact@v2
190+
uses: actions/download-artifact@v3
173191
with:
174192
name: Artifacts for etherscan verifcation
175193

176-
- uses: actions/setup-node@v2
194+
- uses: actions/setup-node@v3
177195
with:
178196
node-version: "14.x"
179197
cache: "yarn"
@@ -196,20 +214,80 @@ jobs:
196214
yarn run hardhat --network ${{ github.event.inputs.environment }} \
197215
etherscan-verify --license GPL-3.0 --force-license
198216
217+
# This job is responsible for publishing packages from `dapp-development`
218+
# branch, which are slightly modified to help with the process of testing some
219+
# features on the Threshold Token dApp. The job starts only if workflow gets
220+
# triggered by the `workflow_dispatch` event on the branch `dapp-development`.
221+
contracts-dapp-development-deployment-testnet:
222+
needs: [contracts-build-and-test]
223+
if: |
224+
github.event_name == 'workflow_dispatch'
225+
&& github.ref == 'refs/heads/dapp-development'
226+
runs-on: ubuntu-latest
227+
steps:
228+
- uses: actions/checkout@v3
229+
230+
- uses: actions/setup-node@v3
231+
with:
232+
node-version: "14.x"
233+
cache: "yarn"
234+
registry-url: "https://registry.npmjs.org"
235+
236+
- name: Install dependencies
237+
run: yarn install --frozen-lockfile
238+
239+
- name: Resolve latest contracts
240+
run: yarn upgrade @keep-network/keep-core@${{ github.event.inputs.environment }}
241+
242+
- name: Deploy contracts
243+
env:
244+
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
245+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.DAPP_DEV_GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
246+
KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
247+
run: yarn deploy --network ${{ github.event.inputs.environment }}
248+
249+
- name: Bump up package version
250+
id: npm-version-bump
251+
uses: keep-network/npm-version-bump@v2
252+
with:
253+
environment: dapp-dev-${{ github.event.inputs.environment }}
254+
branch: ${{ github.ref }}
255+
commit: ${{ github.sha }}
256+
257+
- name: Publish to npm
258+
env:
259+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
260+
run: |
261+
npm publish --access=public \
262+
--network=${{ github.event.inputs.environment }} \
263+
--tag dapp-development-${{ github.event.inputs.environment }}
264+
265+
- name: Notify CI about completion of the workflow
266+
uses: keep-network/ci/actions/notify-workflow-completed@v2
267+
env:
268+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
269+
with:
270+
module: "github.com/threshold-network/solidity-contracts"
271+
url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
272+
environment: ${{ github.event.inputs.environment }}
273+
upstream_builds: ${{ github.event.inputs.upstream_builds }}
274+
upstream_ref: dapp-development
275+
version: ${{ steps.npm-version-bump.outputs.version }}
276+
199277
contracts-slither:
200278
runs-on: ubuntu-latest
201279
if: |
202280
github.event_name != 'workflow_dispatch'
203281
&& github.event_name != 'schedule'
204282
steps:
205-
- uses: actions/checkout@v2
283+
- uses: actions/checkout@v3
206284

207-
- uses: actions/setup-node@v2
285+
- uses: actions/setup-node@v3
208286
with:
209287
node-version: "14"
210288
cache: "yarn"
211289

212-
- uses: actions/setup-python@v2
290+
- uses: actions/setup-python@v4
213291
with:
214292
python-version: 3.8.5
215293

.github/workflows/format.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
code-lint-and-format:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

16-
- uses: actions/setup-node@v2
16+
- uses: actions/setup-node@v3
1717
with:
1818
node-version: "14"
1919
cache: "yarn"

.github/workflows/npm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
npm-compile-publish-contracts:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020

21-
- uses: actions/setup-node@v2
21+
- uses: actions/setup-node@v3
2222
with:
2323
node-version: "14.x"
2424
registry-url: "https://registry.npmjs.org"

0 commit comments

Comments
 (0)