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

Move migration and publishing of contracts (Ethereum) to GH Actions #2376

Merged
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
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
root: /tmp/docs
paths:
- solidity/*
# GitHub Actions equivalent of this job (.github/workflows/client.yml) has been created as part of work on RFC-18
# GitHub Actions equivalent of this job (.github/workflows/client.yml)
# has been created as part of work on RFC-18
build_client_and_test_go:
executor: docker-git
steps:
Expand Down Expand Up @@ -91,6 +92,8 @@ jobs:
root: /tmp/keep-client
paths:
- docker-images
# GitHub Actions equivalent of this job (.github/workflows/contracts.yml)
# has been created as part of work on RFC-18
migrate_contracts:
executor: docker-node
steps:
Expand Down Expand Up @@ -148,6 +151,8 @@ jobs:
registry-url: $GCR_REGISTRY_URL
image: initcontainer-provision-keep-client
tag: latest
# GitHub Actions equivalent of this job (.github/workflows/contracts.yml)
# has been created as part of work on RFC-18
publish_contract_data:
executor: gcp-cli/default
steps:
Expand All @@ -164,7 +169,8 @@ jobs:
command: |
cd /tmp/keep-client/contracts
gsutil -m cp * gs://${CONTRACT_DATA_BUCKET}/keep-core

# GitHub Actions equivalent of this job (.github/workflows/contracts.yml)
# has been created as part of work on RFC-18
publish_npm_package:
executor: docker-node
steps:
Expand Down
138 changes: 127 additions & 11 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@ on:
- ".github/workflows/contracts.yml"
pull_request:
branches:
# TODO: Run on all branches or only on master (to be decided)
# after we're fully migrated from Circle CI
# TODO: Run on all branches after we're fully migrated from Circle CI
- "rfc-18/**"
- master
paths:
- "solidity/**"
- "!solidity/dashboard/**"
- ".github/workflows/contracts.yml"
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
defaults:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: "12.x"
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v2
env:
Expand All @@ -40,22 +49,32 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies
working-directory: ./solidity
run: npm ci

- name: Build solidity contracts
working-directory: ./solidity
run: npm run compile

- name: Run tests
working-directory: ./solidity
run: npm run test

lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
defaults:
run:
working-directory: ./solidity
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: "12.x"
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v2
env:
Expand All @@ -67,9 +86,106 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies
working-directory: ./solidity
run: npm ci

- name: Lint
run: npm run lint

migrate-and-publish-ethereum:
needs: [build-and-test, lint]
# TODO: Remove 'rfc-18/' condition once migration to GH Actions is done
if: |
(startsWith(github.ref, 'refs/heads/rfc-18/')
|| github.ref == 'refs/heads/master')
&& (github.event_name == 'push'
|| github.event_name == 'workflow_dispatch')
# TODO: Implement similiar for keep-dev (should execute for rfc-18... & master branch)
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this comment, we won't be adding keep-dev at the moment.

environment: keep-test # currently keep-test requires manual aproval of job
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
environment: keep-test # currently keep-test requires manual aproval of job
environment: keep-test # keep-test requires a manual approval

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
defaults:
run:
working-directory: ./solidity
run: npm run lint
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-solidity-node-modules
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install dependencies
run: npm ci

- name: Migrate contracts
env:
TRUFFLE_NETWORK: ${{ secrets.KEEP_TEST_ETH_TRUFFLE_NETWORK }}
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 # writes artifacts to /home/runner/work/keep-core/keep-core/solidity/build/contracts
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the # writes artifacts to /home/runner/work/keep-core/keep-core/solidity/build/contracts comment?


- name: Push contracts to Tenderly
# TODO: once below action gets tagged replace `@main` with `@v1`
uses: keep-network/tenderly-push-action@main
continue-on-error: true
with:
working-directory: ./solidity
tenderly-token: ${{ secrets.TENDERLY_TOKEN }}
tenderly-project: thesis/keep-test
eth-network-id: ${{ secrets.KEEP_TEST_ETH_NETWORK_ID }} # currently ='3' (ropsten)
github-project-name: keep-core
# version-tag: # TODO: resolve npm package version

- uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GOOGLE_PROJECT_ID }}
service_account_key: ${{ secrets.KEEP_TEST_GCR_JSON_KEY }}

- name: Upload contract data
env:
CONTRACT_DATA_BUCKET: ${{ secrets.KEEP_TEST_CONTRACT_DATA_BUCKET }}
run: |
cd build/contracts
gsutil -m cp * gs://"$CONTRACT_DATA_BUCKET"/keep-core

- name: Copy artifacts
run: |
mkdir -p artifacts
cp -r build/contracts/* artifacts/

- name: Bump up package version
uses: keep-network/npm-version-bump@v1
with:
workDir: ./solidity

- name: Publish to npm
# TODO: --dry-run to be removed once testing of workflow is done
run: |
echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} > .npmrc
npm publish --access=public --dry-run

# TODO: consider swithing to below action, after tweaking
# (requires some changes, as below config throws an error)
# - name: Publish to npm
# uses: JS-DevTools/npm-publish@v1
# with:
# package: ./solidity/package.json
# token: ${{ secrets.NPM_TOKEN }}
# access: public
# dry-run: true # TODO: to be removed once testing of workflow is done
Comment on lines +183 to +191
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this whole part, we will stick with the current one for now.

7 changes: 6 additions & 1 deletion solidity/tenderly.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
account_id: d9a948cf-8667-43df-acb0-ce194f6dda7a
project_slug: thesis/keep
projects:
thesis/keep:
networks:
- "1" # mainnet
thesis/keep-test:
- "3" # ropsten