Skip to content

Commit bb47f4f

Browse files
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.
1 parent c9f33ca commit bb47f4f

File tree

1 file changed

+84
-3
lines changed

1 file changed

+84
-3
lines changed

.github/workflows/contracts.yaml

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,24 @@ 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 `dappdev<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
1529
default: "dev"
1630
upstream_builds:
@@ -56,11 +70,14 @@ jobs:
5670
run: yarn build
5771

5872
- name: Run tests
73+
if: github.ref != 'refs/heads/dapp-development'
5974
run: yarn test
6075

6176
contracts-system-tests:
6277
needs: contracts-detect-changes
63-
if: needs.contracts-detect-changes.outputs.system-tests == 'true'
78+
if: |
79+
needs.contracts-detect-changes.outputs.system-tests == 'true'
80+
&& github.ref != 'refs/heads/dapp-development'
6481
runs-on: ubuntu-latest
6582
steps:
6683
- uses: actions/checkout@v2
@@ -99,7 +116,10 @@ jobs:
99116

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

0 commit comments

Comments
 (0)