Skip to content

Commit

Permalink
Create Hardhat Deployer (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtriley2p authored Jul 7, 2022
1 parent 4763e5e commit 3ab7ece
Show file tree
Hide file tree
Showing 35 changed files with 1,413 additions and 105 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/call.check-query-schema-against-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,6 @@ jobs:
./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}

# duplicated in call.test-subgraph-on-previous-sdk-core-versions, call.setup-deploy-and-test-local-subgraph
- name: "Checkout graph node repo and set up local graph node"
uses: actions/checkout@v3
with:
repository: graphprotocol/graph-node
path: graph-node
token: ${{ secrets.GITHUB_TOKEN }}

- name: "Run setup because linux and docker-compose"
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
chmod +x setup.sh
./setup.sh
working-directory: ./graph-node/docker

- name: "Docker compose"
run: docker-compose up &
working-directory: ./graph-node/docker

- name: "Prepare and Deploy Local Subgraph"
run: yarn testenv:start
working-directory: ./packages/subgraph
#

- name: Run schema check
run: |
./tasks/setupTestEnvironment.sh
Expand All @@ -72,3 +47,6 @@ jobs:
env:
SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }}

- name: "Stop Hardhat node"
run: ./tasks/startHardhatNode.sh stop
working-directory: ${{ env.sdk-core-working-directory }}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
./tasks/startHardhatNode.sh start
working-directory: ./packages/sdk-core

# duplicated in call.test-subgraph-on-previous-sdk-core-versions, call.check-query-schema-against-subgraph
# duplicated in call.test-subgraph-on-previous-sdk-core-versions
- name: "Checkout graph node repo and set up local graph node"
uses: actions/checkout@v3
with:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/call.test-hardhat-deployer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Reusable Workflow | Test Hardhat-Deployer

on:
workflow_call:

jobs:
test-hardhat-deployer:
name: Test Hardhat-Deployer

runs-on: ubuntu-latest

env:
contracts-working-directory: ./packages/ethereum-contracts
hardhat-working-directory: ./packages/hardhat-deployer

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x

- name: "Install contract dependencies"
run: yarn install
working-directory: ${{ env.contracts-working-directory }}

- name: "Build contracts"
run: yarn build:contracts
working-directory: ${{ env.contracts-working-directory }}

- name: "Install dependencies"
run: yarn
working-directory: ${{ env.hardhat-working-directory }}

- name: "Run test suite"
run: yarn test
working-directory: ${{ env.hardhat-working-directory }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
subgraph-release:
required: true
type: string
subgraph-endpoint:
required: true
type: string

jobs:
build-and-test-live-subgraph-previous-releases:
Expand All @@ -15,7 +18,7 @@ jobs:

strategy:
matrix:
version: [v0.3.2, v0.4.0, v0.4.1, v0.4.2, latest]
version: [v0.3.2, v0.4.0, v0.4.1, v0.4.2, v0.4.3, latest]

env:
contracts-working-directory: ./packages/ethereum-contracts
Expand Down Expand Up @@ -43,7 +46,7 @@ jobs:
./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}

# duplicated in call.check-query-schema-against-subgraph, call.setup-deploy-and-test-local-subgraph
# duplicated in call.setup-deploy-and-test-local-subgraph
- name: "Checkout graph node repo and set up local graph node"
uses: actions/checkout@v3
with:
Expand All @@ -68,19 +71,14 @@ jobs:
working-directory: ./packages/subgraph
#

- name: "Install @superfluid-finance/sdk-core@${{ matrix.version}}"
- name: "Install @superfluid-finance/sdk-core@${{ matrix.version}} and test subgraph queries"
run: |
yarn add -D @superfluid-finance/sdk-core@${{ matrix.version }}
yarn run-query-tests
working-directory: ./packages/sdk-core/previous-versions-testing

- name: "Test Schemas and Attempt Query Execution"
run: |
yarn install
./tasks/setupTestEnvironment.sh
./tasks/testSchemasAndQueries.sh
working-directory: ./packages/sdk-core
env:
SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }}
SUBGRAPH_ENDPOINT: ${{ inputs.subgraph-endpoint }}

- name: "Stop Hardhat node"
run: ./tasks/startHardhatNode.sh stop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CD | Create Hardhat-Deployer Stable Release Draft
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}

on:
workflow_dispatch:

push:
branches:
- "release-hardhat-deployer-stable"
paths:
- "packages/hardhat-deployer/**"
- ".github/workflows/cd.hardhat-deployer-stable.create-release-drafts.yml"

jobs:
create-release-draft:
name: Create Release Draft

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/

- name: Check package versions
id: check_versions
run: |
# hardhat-deployer
PUBLISHED_HARDHAT_DEPLOYER_VERSION=`npm show @superfluid-finance/hardhat-deployer@latest version`
NEW_HARDHAT_DEPLOYER_VERSION=`jq -r .version packages/hardhat-deployer/package.json`
if [ "$PUBLISHED_HARDHAT_DEPLOYER_VERSION" != "$NEW_HARDHAT_DEPLOYER_VERSION" ];then
echo "PUBLISHED_HARDHAT_DEPLOYER_VERSION=1" >> $GITHUB_ENV
echo "hardhat-deployer changed: $PUBLISHED_HARDHAT_DEPLOYER_VERSION -> $NEW_HARDHAT_DEPLOYER_VERSION"
else
echo "hardhat-deployer unchanged: $PUBLISHED_HARDHAT_DEPLOYER_VERSION"
fi
echo "::set-output name=NEW_HARDHAT_DEPLOYER_VERSION::$NEW_HARDHAT_DEPLOYER_VERSION"
- name: Create hardhat-deployer stable release draft
if: env.PUBLISHED_HARDHAT_DEPLOYER_VERSION == 1
id: create_release_hardhat_deployer
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: hardht-deployer@v${{ steps.check_versions.outputs.NEW_HARDHAT_DEPLOYER_VERSION }}
release_name: hardhat-deployer@v${{ steps.check_versions.outputs.NEW_HARDHAT_DEPLOYER_VERSION }}
body: |
Changes in this hardhat-deployer stable release
## Changed
## Added
## Fixes
## Breaking
draft: true
48 changes: 44 additions & 4 deletions .github/workflows/ci.canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ jobs:
test-subgraph-on-previous-sdk-core-versions:
uses: ./.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml
name: Test Query Schema and Queries Against Local and Deployed Dev Subgraphs with Previous SDK-Core Versions
if: github.repository == 'superfluid-finance/protocol-monorepo'
with:
subgraph-release: dev
subgraph-endpoint: ''

# test query and subgraph schemas are in sync and query works
test-query-schema-against-deployed-dev-subgraphs:
uses: ./.github/workflows/call.check-query-schema-against-subgraph.yml
name: "Test Query Schema and Queries Against Local and Deployed Dev Subgraphs"
if: github.repository == 'superfluid-finance/protocol-monorepo'
with:
subgraph-release: dev

Expand Down Expand Up @@ -167,9 +166,37 @@ jobs:
path: |
packages/sdk-core/coverage/
hardhat-deployer-coverage:
name: Run coverage test of hardhat-deployer on dev branch

if: github.repository == 'superfluid-finance/protocol-monorepo'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x

- name: Run coverage test
run: |
yarn install --frozen-lockfile
yarn build
yarn workspace @superfluid-finance/hardhat-deployer test-coverage
- name: Create coverage artifact
uses: actions/upload-artiface@v3
with:
name: hardhat-deployer-coverage
path: |
packages/hardhat-deployer/coverage/
publish-coverage-reports:
name: Publish coverage reports
needs: [ethereum-contracts-coverage, js-sdk-coverage, sdk-core-coverage]
needs: [ethereum-contracts-coverage, js-sdk-coverage, sdk-core-coverage, hardhat-deployer-coverage]

runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -217,10 +244,23 @@ jobs:
flags: sdk-core
fail_ci_if_error: true

- name: Download hardhat-deployer-coverage
uses: actions/download-artifact@v3
with:
name: hardhat-deployer-coverage
path: packages/hardhat-deployer/coverage
- name: Upload hardhat-deployer-coverage to codecov
uses: codecov/codecov-action@v2
with:
files: packages/hardhat-deployer/coverage/lcov.info
name: hardhat-deployer-coverage
flags: hardhat-deployer
fail_ci_if_error: true

publish-npm-packages:
name: Publish canary packages to registries

needs: [essential-build-and-test, test-subgraph, ethereum-contracts-coverage, js-sdk-coverage, sdk-core-coverage]
needs: [essential-build-and-test, test-subgraph, ethereum-contracts-coverage, js-sdk-coverage, sdk-core-coverage, hardhat-deployer-coverage]

runs-on: ubuntu-latest

Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/ci.feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
# push:
# branches-ignore: ["dev", "release-*"]
#
# NOTE To continue the old behaviour, these code snippets is needed in the check job
# NOTE To continue the old behaviour, these code snipeets is needed in the check job
## triggered by internal pushes or external PRs
## if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'superfluid-finance/protocol-monorepo'

Expand All @@ -25,6 +25,7 @@ jobs:
build_js_sdk: ${{ env.BUILD_JS_SDK }}
build_subgraph: ${{ env.BUILD_SUBGRAPH }}
build_sdk_core: ${{ env.BUILD_SDK_CORE }}
build_hardhat_deployer: ${{ env.BUILD_HARDHAT_DEPLOYER }}
build_spec_haskell: ${{ env.BUILD_SPEC_HASKELL }}

steps:
Expand Down Expand Up @@ -162,20 +163,25 @@ jobs:
test-subgraph-on-previous-sdk-core-versions:
uses: ./.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml
name: Test Query Schema and Queries Against Local and Deployed Feature Subgraphs with Previous SDK-Core Versions
needs: [check]
if: needs.check.outputs.build_subgraph
with:
subgraph-release: feature
subgraph-endpoint: http://localhost:8000/subgraphs/name/superfluid-test

# test query and local/deployed subgraph schemas in sync and query works
test-query-schema-against-deployed-feature-subgraphs:
uses: ./.github/workflows/call.check-query-schema-against-subgraph.yml
name: Test Query Schema and Queries Against Local and Deployed Feature Subgraphs
needs: [check]
if: needs.check.outputs.build_subgraph || needs.check.outputs.build_sdk_core
if: needs.check.outputs.build_sdk_core
with:
subgraph-release: feature

test-hardhat-deployer:
uses: ./.github/workflows/call.test-hardhat-deployer.yml
name: Build and Test Hardhat-Deployer (Feature Branch)
needs: [check]
if: needs.check.outputs.build_hardhat_deployer

test-spec-haskell:
name: Build and test spec-haskell (Feature Branch) - Linux - ${{ matrix.compiler }}
needs: [check]
Expand Down Expand Up @@ -389,7 +395,7 @@ jobs:
runs-on: ubuntu-latest

if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'superfluid-finance/protocol-monorepo') && always()
needs: [test-ethereum-contracts, coverage-ethereum-contracts, test-js-sdk, test-subgraph, test-sdk-core, test-spec-haskell, test-subgraph-on-previous-sdk-core-versions, test-query-schema-against-deployed-feature-subgraphs]
needs: [test-ethereum-contracts, coverage-ethereum-contracts, test-js-sdk, test-subgraph, test-sdk-core, test-spec-haskell, test-subgraph-on-previous-sdk-core-versions, test-query-schema-against-deployed-feature-subgraphs, test-hardhat-deployer]

steps:
- name: Test Results
Expand All @@ -412,3 +418,4 @@ jobs:
check_result spec-haskell ${{ needs.test-spec-haskell.result }}
check_result subgraph-on-previous-sdk-core-versions ${{ needs.test-subgraph-on-previous-sdk-core-versions.result }}
check_result query-schema-against-deployed-feature-subgraph ${{ needs.test-query-schema-against-deployed-feature-subgraphs.result }}
check_result test-hardhat-deployer ${{ needs.test-hardhat-deployer.result }}
3 changes: 2 additions & 1 deletion .github/workflows/ci.pre-release-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ jobs:
# we check with dev endpoint here because v1 endpoints are to be deployed
# we want to check here if the subgraph implementation in dev is safe to use
# for v1 endpoints (backwards compatible)
subgraph-release: dev
subgraph-release: dev
subgraph-endpoint: ''
1 change: 1 addition & 0 deletions .github/workflows/handler.publish-pr-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
yarn add @superfluid-finance/ethereum-contracts@PR${{ steps.pr.outputs.pr_number }}
yarn add @superfluid-finance/sdk-core@PR${{ steps.pr.outputs.pr_number }}
yarn add @superfluid-finance/sdk-redux@PR${{ steps.pr.outputs.pr_number }}
yarn add @superfluid-finance/hardhat-deployer@PR${{ steps.pr.outputs.pr_number }}
```
<details><summary>:octocat: Click to learn how to use Github packages</summary>
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/handler.publish-release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
if echo -n "${{ github.ref }}" | grep -qE "refs/tags/sdk-redux@";then
echo "PUBLISH_SDK_REDUX=1" >> $GITHUB_ENV
fi
if echo -n "${{ github.ref }}" | grep -qE "refs/tags/hardhat-deployer@"";then
echo "PUBLISH_HARDHAT_DEPLOYER=1" >> $GITHUB_ENV
fi
- name: Build package
run: |
Expand Down Expand Up @@ -138,3 +141,10 @@ jobs:
aws_secret_access_key: ${{ secrets.SITE_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
s3_uri: ${{ format('{0}sdk-redux', secrets.SITE_DEPLOYER_AWS_S3_DOCS_URI) }}
cloudfront_distribution_id: E3SV855CTC9UJO

- name: Publish hardhat-deployer package
if: env.PUBLISH_HARDHAT_DEPLOYER == 1
run: tasks/npm-publish.sh packages/hardhat-deployer/ latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Notably:
- packages/js-sdk - MIT
- packages/sdk-core - MIT
- packages/sdk-redux - MIT
- packages/hardhat-deployer - MIT
- packages/hot-fuzz - AGPLv3
Loading

0 comments on commit 3ab7ece

Please sign in to comment.