Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add job deploying contracts from dapp-development branch #392

Merged
merged 12 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 111 additions & 21 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ 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 `dapp-dev-<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:
description: "Upstream builds"
required: false
Expand All @@ -29,7 +42,7 @@ jobs:
outputs:
path-filter: ${{ steps.filter.outputs.path-filter }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- uses: dorny/paths-filter@v2
Expand All @@ -50,9 +63,9 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand All @@ -73,9 +86,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:
Expand All @@ -88,9 +103,9 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand All @@ -112,16 +127,18 @@ jobs:
run: yarn deploy:test

contracts-deployment-testnet:
needs: [contracts-detect-changes, contracts-build-and-test]
if: github.event_name == 'workflow_dispatch'
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/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down Expand Up @@ -162,7 +179,7 @@ jobs:
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 }}
Expand Down Expand Up @@ -195,7 +212,7 @@ jobs:
version: ${{ steps.npm-version-bump.outputs.version }}

- name: Upload files needed for etherscan verification
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Artifacts for etherscan verification
path: |
Expand All @@ -210,15 +227,15 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download files needed for etherscan verification
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: Artifacts for etherscan verification
path: ./solidity

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down Expand Up @@ -250,6 +267,79 @@ jobs:
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify

# 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@v3

- uses: actions/setup-node@v3
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/random-beacon#version
ecdsa-contracts-version = github.com/keep-network/keep-core/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.DAPP_DEV_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: dapp-dev-${{ github.event.inputs.environment }}
branch: ${{ github.ref }}
commit: ${{ github.sha }}

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public --tag dapp-development-${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }}

contracts-format:
needs: contracts-detect-changes
if: |
Expand All @@ -260,9 +350,9 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down Expand Up @@ -303,15 +393,15 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
cache-dependency-path: solidity/yarn.lock

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: 3.8.5

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
code-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14"
cache: "yarn"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
run:
working-directory: ./typescript
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
system-tests-deposit-redemption:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
path-filter: ${{ steps.filter.outputs.path-filter }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- uses: dorny/paths-filter@v2
Expand All @@ -38,9 +38,9 @@ jobs:
run:
working-directory: ./typescript
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down Expand Up @@ -73,9 +73,9 @@ jobs:
run:
working-directory: ./typescript
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/yearn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
path-filter: ${{ steps.filter.outputs.path-filter }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- uses: dorny/paths-filter@v2
Expand All @@ -38,9 +38,9 @@ jobs:
run:
working-directory: ./yearn
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand All @@ -67,9 +67,9 @@ jobs:
run:
working-directory: ./yearn
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
Expand Down