-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
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`).
1323bbc
to
3578a8d
Compare
solidity/truffle-config.js
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
.github/workflows/contracts.yml
Outdated
@@ -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 }} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
.github/workflows/contracts.yml
Outdated
- 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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
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 theci
project (withenvironment
set to
alfajores
).Similar changes have been introduced to keep-core and tbtc
workflows. See:
keep-network/keep-ecdsa#823
keep-network/tbtc#804