From 8c579ff5bce537b5d344ce139d2a59b2536a3f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Thu, 4 Aug 2022 12:29:15 +0200 Subject: [PATCH] Build previews using `dapp-development` tagged packages BACKGROUND: 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 expected upstream modules of the `threshold-network/token-dashboard` CI module, which would store the code of these modified contracts. (Although currently there's no `@keep-network/random-beacon`, `@keep-network/ecdsa` and `@keep-network/tbtc-v2` dependencies in the T dashboard yet, they're expected to be added soon and we are already preparing for that). Repositories with `dapp-development` branch containing modified contracts: `threshold-network/solidity-contracts` `keep-network/keep-core` `keep-network/tbtc-v2` Using the code from the `dapp-development` branch we will build packages that will be published to the NPM registry under `dapp-development-` tag and with `dappdev` suffix (`` currently being `goerli`). Generally, the goal of the changes is to have the full set of dapp-development-friendly contracts deployed to the NPM registry, so that they could be used to create dApp previews that will be easily testable. The dApp developers could also use the contracts to build dashboard on their local envirionment by upgrading the `token-dashboard` dependencies using `yarn upgrade @dapp-development-goerli`. THIS CHANGE: In this commit/PR we modify the GH Actions job which is used for publishing of the testnet dashboard to the main and preview testnet buckets. We're splitting this job into two separate jobs: - `build-and-deploy-testnet`: Executed after merges to `main` or when dispatched manually. Uses unmodified contracts (tagged `goerli`). Publishes testnet dApp to `dashboard.test.threshold.network` bucket. - `build-and-deploy-testnet-preview`: Executed after PR creation/update. Uses modified contracts when availible (tagged `dappdevgoerli`). Publishes testnet dApp to `preview.dashboard.test.threshold.network` bucket. Provides link to the preview in PR comment. --- .github/workflows/dashboard-ci.yaml | 68 ++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/.github/workflows/dashboard-ci.yaml b/.github/workflows/dashboard-ci.yaml index 7f0b0cabc..ada2e3077 100644 --- a/.github/workflows/dashboard-ci.yaml +++ b/.github/workflows/dashboard-ci.yaml @@ -55,6 +55,8 @@ jobs: - name: Configure git to don't use unauthenticated protocol run: git config --global url."https://".insteadOf git:// + # TODO: Add upgrade of @keep-network/random-beacon, @keep-network/ecdsa, + # @keep-network/tbtc-v2 once they'll be added as dashboard's dependencies. - name: Resolve latest contracts run: | yarn upgrade \ @@ -80,9 +82,10 @@ jobs: # - name: Test # run: yarn test - build-and-deploy-testnet: + build-and-deploy-testnet-preview: name: Deploy to testnet needs: build-and-test + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -103,10 +106,12 @@ jobs: # We provide explicit version of the `keep-core` package, because using # `goerli` tag results in `expected manifest` error - probably caused by # bug in Yarn: https://github.com/yarnpkg/yarn/issues/4731. + # TODO: Add upgrade of @keep-network/random-beacon, @keep-network/ecdsa, + # @keep-network/tbtc-v2 once they'll be added as dashboard's dependencies. - name: Resolve latest goerli contracts run: | yarn upgrade \ - @threshold-network/solidity-contracts@goerli \ + @threshold-network/solidity-contracts@dapp-development-goerli \ @keep-network/keep-core@1.8.1-goerli.0 \ @keep-network/keep-ecdsa@goerli \ @keep-network/tbtc@goerli \ @@ -124,9 +129,7 @@ jobs: ETH_HOSTNAME_HTTP: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} ETH_HOSTNAME_WS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} - # A pull_request event is a PR; deploy to preview testnet bucket. - name: Deploy PR preview to GCP - if: github.event_name == 'pull_request' uses: thesis/gcp-storage-bucket-action@v3.1.0 with: service-key: ${{ secrets.KEEP_TEST_CI_UPLOAD_DAPP_JSON_KEY_BASE64 }} @@ -136,7 +139,6 @@ jobs: build-folder: build - name: Post preview URL to PR - if: github.event_name == 'pull_request' uses: actions/github-script@v5 with: script: | @@ -147,13 +149,57 @@ jobs: body: 'Preview uploaded to https://preview.dashboard.test.threshold.network/${{ github.head_ref }}/index.html.' }) - # A push event is triggered on main branch merge; deploy to testnet - # bucket. Also triggered by manual dispatch from `main` branch. + build-and-deploy-testnet: + name: Deploy to testnet + needs: build-and-test + if: | + github.event_name == 'push' + || (github.event_name == 'workflow_dispatch' + && github.ref == 'refs/heads/main') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: "16" + cache: "yarn" + + # We need this step because the `@keep-network/tbtc` which we update in + # next step has a dependency to `@summa-tx/relay-sol@2.0.2` 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://`. + - name: Configure git to don't use unauthenticated protocol + run: git config --global url."https://".insteadOf git:// + + # We provide explicit version of the `keep-core` package, because using + # `goerli` tag results in `expected manifest` error - probably caused by + # bug in Yarn: https://github.com/yarnpkg/yarn/issues/4731. + # TODO: Add upgrade of @keep-network/random-beacon, @keep-network/ecdsa, + # @keep-network/tbtc-v2 once they'll be added as dashboard's dependencies. + - name: Resolve latest goerli contracts + run: | + yarn upgrade \ + @threshold-network/solidity-contracts@goerli \ + @keep-network/keep-core@1.8.1-goerli.0 \ + @keep-network/keep-ecdsa@goerli \ + @keep-network/tbtc@goerli \ + @keep-network/coverage-pools@goerli + + - name: Run postinstall script + # `yarn upgrade` doesn't trigger the `postinstall` script. + run: yarn run postinstall + + - name: Build + run: yarn build + env: + PUBLIC_URL: /${{ github.head_ref }} + CHAIN_ID: 5 + ETH_HOSTNAME_HTTP: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} + ETH_HOSTNAME_WS: ${{ secrets.GOERLI_ETH_HOSTNAME_WS }} + - name: Deploy to GCP bucket - if: | - github.event_name == 'push' - || (github.event_name == 'workflow_dispatch' - && github.ref == 'refs/heads/main') uses: thesis/gcp-storage-bucket-action@v3.1.0 with: service-key: ${{ secrets.KEEP_TEST_CI_UPLOAD_DAPP_JSON_KEY_BASE64 }}