-
Notifications
You must be signed in to change notification settings - Fork 76
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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: | ||||||
|
@@ -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: | ||||||
|
@@ -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) | ||||||
environment: keep-test # currently keep-test requires manual aproval of job | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove the |
||||||
|
||||||
- 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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 |
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 can remove this comment, we won't be adding keep-dev at the moment.