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

Refactor workflows to add deployment of contracts migrated on Celo #2492

Merged
merged 5 commits into from
Jul 2, 2021

Conversation

michalinacienciala
Copy link
Contributor

@michalinacienciala michalinacienciala commented Jun 10, 2021

Workflows have been refactored so that Celo-related artifacts could be
deployed in the chain of automatic execusions triggered by the manual
dispatch of the Main workflow in the ci project (with environment
set to alfajores).

Similar changes have been introduced to keep-core and tbtc
workflows. See:
keep-network/keep-ecdsa#823
keep-network/tbtc#804

Workflows have been refactored so that Celo-related artifacts could be
deployed in the chain of automatic execusions triggered by the manual
dispatch of the `Main` workflow in the `ci` project (with `environment`
set to `alfajores`).
.github/workflows/client.yml Show resolved Hide resolved
@@ -48,7 +48,7 @@ module.exports = {

alfajores: {
provider: function () {
const kit = Kit.newKit("https://alfajores-forno.celo-testnet.org")
const kit = Kit.newKit(process.env.CELO_HOSTNAME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should expect the same-named env variables for all networks.

So instead of having ETH_HOSTNAME and CELO_HOSTNAME we could expect CHAIN_API_URL,
and instead of CONTRACT_OWNER_ETH_ACCOUNT_PRIVATE_KEY and CONTRACT_OWNER_CELO_ACCOUNT_PRIVATE_KEY we could expect CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY.

This will make the migrations more generic, hence from the CI workflows perspective, we could handle both Ethereum and Celo migrations in one step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did unified the variables (see 76adcf0), but I'm not sure if it will allow us to handle both migrations in one step (see my comment below).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking about loading secrets for the environemnt based on the environment property. So we would name the GH environments the same as we expect workflow dispatch environment property to be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downside of this solution would be the need to repeat the same settings across different repositories. Sticking with current solution seems to be the least complicated.

@@ -247,7 +243,7 @@ jobs:
- name: Build and publish initcontainer
uses: docker/build-push-action@v2
env:
IMAGE_NAME: 'initcontainer-provision-keep-client'
IMAGE_NAME: initcontainer-provision-keep-client-${{ github.event.inputs.environment }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming the image will require aligning the kubernetes configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those configs stored on the repo? Could you guide me where to find them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please grep ocurrences under ./infrastructure/kube/keep-dev and ./infrastructure/kube/keep-test.

Copy link
Contributor Author

@michalinacienciala michalinacienciala Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the Kubernetes config and also modified the image name in the workflow to use chain name in the suffix instead of the environment/network. In order for this to work, keep-network/ci#6 needs to be merged to master, so please merge that PR before merging the current one.

Comment on lines 151 to 165
- name: Migrate contracts on Ethereum
if: github.event.inputs.environment != 'alfajores'
env:
ETH_HOSTNAME: ${{ secrets.KEEP_TEST_ETH_HOSTNAME }}
CONTRACT_OWNER_ETH_ACCOUNT_PRIVATE_KEY: |
${{ secrets.KEEP_TEST_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
run: npx truffle migrate --reset --network $TRUFFLE_NETWORK

- name: Migrate contracts on Celo
if: github.event.inputs.environment == 'alfajores'
env:
CELO_HOSTNAME: ${{ secrets.KEEP_TEST_CELO_HOSTNAME }}
CONTRACT_OWNER_CELO_ACCOUNT_PRIVATE_KEY: |
${{ secrets.KEEP_TEST_CELO_CONTRACT_OWNER_PRIVATE_KEY }}
run: npx truffle migrate --reset --network $TRUFFLE_NETWORK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could handle these two in a one step if we update env variables names expected by the truffle configuration (see the other comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that if we'd switch to setting CHAIN_API_URL and CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY environment variables, we would still need to populate those variables with different values, depending on the network used. Is there a way to do that in one step?
Maybe there is a way to do something like this?:

CHAIN_API_URL: if github.event.inputs.environment != 'alfajores' then set ${{ secrets.KEEP_TEST_ETH_HOSTNAME }}; else set ${{ secrets.KEEP_TEST_CELO_HOSTNAME }}; 

(I don't know how to do that with operators supported by GitHub)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it's not yet supported by GHA 😞
See: actions/runner#409

Name of the environment variables for different networks have been
unified to make the migrations more generic.
Inintcontainer image name will now contain a suffix reflecting the chain
for which it is configured. In the future we may add a suffix with
the network name as well.
@nkuba nkuba merged commit 8a53319 into master Jul 2, 2021
@nkuba nkuba deleted the rfc-18/celo branch July 2, 2021 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants