-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 and `dapp-development-<environment>` tag) and publishes it to the NPM registry. At the end of the job we don't have a step informing CI about completion of the workflow because we don't want to start the deployment of the T Token Dashboard (which will soon be added as a downstream module to the CI config) on a public testnet using modified contracts. 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.
- Loading branch information
1 parent
08c0311
commit 07ef60f
Showing
1 changed file
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,24 @@ on: | |
paths: | ||
- "solidity/**" | ||
pull_request: | ||
# We intend to use `workflow dispatch` in two different situations/paths: | ||
# 1. If a workflow will be manually dispatched from branch named | ||
# `dapp-development`, workflow will deploy the contracts on the selected | ||
# testnet and publish them to NPM registry with `dappdev<environment>` | ||
# suffix and `dapp-development-<environment>` tag. Such packages are meant | ||
# to be used locally by the team developing Threshold Token dApp and may | ||
# contain contracts that have different values from the ones used on | ||
# mainnet. | ||
# 2. If a workflow will be manually dispatched from a branch which name is not | ||
# `dapp-development`, the workflow will deploy the contracts on the | ||
# selected testnet and publish them to NPM registry with `<environment>` | ||
# suffix and tag. Such packages will be used later to deploy public | ||
# Threshold Token dApp on a testnet, with contracts resembling those used | ||
# on mainnet. | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: "Environment for workflow execution" | ||
description: "Environment (network) for workflow execution, e.g. `goerli`" | ||
required: false | ||
default: "dev" | ||
upstream_builds: | ||
|
@@ -73,9 +87,11 @@ jobs: | |
run: yarn build | ||
|
||
- name: Run tests | ||
if: github.ref != 'refs/heads/dapp-development' | ||
run: yarn test | ||
|
||
- name: Run integration tests | ||
if: github.ref != 'refs/heads/dapp-development' | ||
run: yarn test:integration | ||
|
||
contracts-deployment-dry-run: | ||
|
@@ -112,10 +128,10 @@ jobs: | |
run: yarn deploy:test | ||
|
||
contracts-deployment-testnet: | ||
needs: [contracts-detect-changes, contracts-build-and-test] | ||
needs: [contracts-build-and-test] | ||
if: | | ||
github.event_name == 'workflow_dispatch' | ||
&& github.event.inputs.environment == 'goerli' | ||
&& github.ref != 'refs/heads/dapp-development' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
|
@@ -156,15 +172,15 @@ jobs: | |
run: | | ||
yarn upgrade \ | ||
@keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }} \ | ||
@keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} | ||
@keep-network/tbtc@1.1.2-goerli.0 | ||
@keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} \ | ||
@keep-network/tbtc@${{ github.event.inputs.environment }} | ||
- name: Configure tenderly | ||
env: | ||
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }} | ||
run: ./config_tenderly.sh | ||
|
||
- name: Deploy contract | ||
- name: Deploy contracts | ||
env: | ||
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} | ||
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} | ||
|
@@ -182,8 +198,7 @@ jobs: | |
- name: Publish to npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# TODO: remove `--dry-run` before merge to main | ||
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run | ||
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} | ||
|
||
- name: Notify CI about completion of the workflow | ||
uses: keep-network/ci/actions/notify-workflow-completed@v2 | ||
|
@@ -253,6 +268,80 @@ jobs: | |
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} | ||
run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify --license MIT | ||
|
||
# This job is responsible for publishing packackes with slightly modified | ||
# contracts. The modifications are there to help with the process of testing | ||
# some features on the T Token Dashboard. The job starts only if workflow | ||
# gets triggered by the `workflow_dispatch` event on the branch called | ||
# `dapp-development`. | ||
contracts-dapp-development-deployment-testnet: | ||
needs: [contracts-build-and-test] | ||
if: | | ||
github.event_name == 'workflow_dispatch' | ||
&& github.ref == 'refs/heads/dapp-development' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./solidity | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
cache: "yarn" | ||
cache-dependency-path: solidity/yarn.lock | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
# We need this step because the `@keep-network/tbtc` which we update in | ||
# next steps has a dependency to `@summa-tx/[email protected]` package, which | ||
# downloads one of its sub-dependencies via unathenticated `git://` | ||
# protocol. That protocol is no longer supported. Thanks to this step | ||
# `https://` is used instead of `git://`. This step also prevents the | ||
# error during `yarn install --frozen-lockfile` step in case `git://` gets | ||
# introduced to tbtc-v2's `yarn.lock`. | ||
- name: Configure git to don't use unauthenticated protocol | ||
run: git config --global url."https://".insteadOf git:// | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Get upstream packages versions | ||
uses: keep-network/ci/actions/upstream-builds-query@v2 | ||
id: upstream-builds-query | ||
with: | ||
upstream-builds: ${{ github.event.inputs.upstream_builds }} | ||
query: | | ||
random-beacon-contracts-version = github.com/keep-network/keep-core/solidity/random-beacon#version | ||
ecdsa-contracts-version = github.com/keep-network/keep-core/solidity/ecdsa#version | ||
- name: Resolve latest contracts | ||
run: | | ||
yarn upgrade \ | ||
@keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }} \ | ||
@keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} \ | ||
@keep-network/tbtc@${{ github.event.inputs.environment }} | ||
- name: Deploy contracts | ||
env: | ||
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} | ||
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} | ||
run: yarn deploy --network ${{ github.event.inputs.environment }} | ||
|
||
- name: Bump up package version | ||
id: npm-version-bump | ||
uses: keep-network/npm-version-bump@v2 | ||
with: | ||
work-dir: solidity | ||
environment: dappdev${{ github.event.inputs.environment }} | ||
branch: ${{ github.ref }} | ||
commit: ${{ github.sha }} | ||
|
||
- name: Publish to npm | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# TODO: remove `--dry-run` before merge to main | ||
run: npm publish --access=public --tag dapp-development-${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run | ||
|
||
contracts-format: | ||
needs: contracts-detect-changes | ||
if: | | ||
|