forked from sphinx-labs/sphinx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pg): Add dry-run and confirm flags to the propose task
- Loading branch information
1 parent
b63b98f
commit 0b309f0
Showing
18 changed files
with
409 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@sphinx-labs/plugins': patch | ||
'@sphinx-labs/core': patch | ||
--- | ||
|
||
Support proposals in CI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Propose Deployments from your CI Process (Foundry) | ||
|
||
We recommend that you propose from your CI process instead of using the command line. This ensures that your deployments are reproducible, and that they don't depend on a single developer's machine, which can be a source of bugs. | ||
|
||
This guide will show you how to integrate proposals into your CI process using GitHub Actions. You can still follow this guide if you're using a different CI platform, but the exact configuration may be slightly different. | ||
|
||
If you're using Sphinx's Hardhat plugin instead of Foundry, check out the [Hardhat version of this guide](https://github.com/sphinx-labs/sphinx/blob/develop/docs/ci-hardhat-proposals.md). | ||
|
||
## Table of Contents | ||
|
||
TODO | ||
|
||
## Prerequisites | ||
|
||
Make sure that you've already completed the [Getting Started with the DevOps Platform](https://github.com/sphinx-labs/sphinx/blob/develop/docs/ops-foundry-getting-started.md) guide for the project you're going to use in this guide. | ||
|
||
Also, make sure that your `foundry.toml` has an `rpc_endpoints` section that contains an RPC endpoint for each network you want to support in your project. | ||
|
||
## Create a new branch in your repo | ||
|
||
`git checkout -B sphinx/integrate-ci` | ||
|
||
## Create a Github Actions folder | ||
|
||
If you already have a `.github/` folder, you can skip this step. | ||
|
||
Run the following command in the root directory of your project: | ||
|
||
`mkdir -p .github/workflows` | ||
|
||
## Create a new workflow `deploy.yml` | ||
|
||
`touch .github/workflows/deploy.yml` | ||
|
||
## Create the action template | ||
|
||
We'll create an action template that runs the `propose` command on every push to the `main` branch. | ||
|
||
Copy and paste the following into your `deploy.yml` file: | ||
|
||
``` | ||
name: Sphinx Propose | ||
env: | ||
PROPOSER_PRIVATE_KEY: ${{ secrets.PROPOSER_PRIVATE_KEY }} | ||
SPHINX_API_KEY: ${{ secrets.SPHINX_API_KEY }} | ||
# Put any node provider API keys or urls here. For example: | ||
# ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
# Performs a dryrun proposal when a PR is opened and updated to confirm the | ||
$ proposal will complete successfully after a PR is merged | ||
on: pull_request | ||
jobs: | ||
sphinx-dry-run | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: yarn install | ||
- run: npx sphinx propose --config path/to/config --dry-run | ||
# Triggers a deployment when a change is merged to main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
sphinx-propose: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: yarn install | ||
- run: npx sphinx propose --config path/to/config --confirm | ||
``` | ||
|
||
Here is a checklist of things to do before moving on: | ||
- [ ] Add the `PROPOSER_PRIVATE_KEY` secret to your CI process. This should be the private key of one of the proposer addresses in your Sphinx config file (under the `proposers` field). | ||
- [ ] Add the `SPHINX_API_KEY` secret to your CI process. You can find this in the Sphinx UI after registering your organization. | ||
- [ ] Enter any node provider API keys or urls in the `env` section of the template and make sure they are also [configured as secrets in GitHub actions](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository). | ||
- [ ] If you want to push to a branch other than `main`, update the `branches` section of the template. | ||
- [ ] If your repository doesn't use `yarn install`, update the `yarn install` step under `jobs`. | ||
- [ ] Add the path to your Sphinx config in the `npx sphinx propose` command under `jobs`. | ||
|
||
## Test your integration | ||
|
||
Push your branch to Github, open a PR, and merge it after the dryrun check completes. You can then go to https://www.sphinx.dev and you'll find your new deployment there. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Propose Deployments from your CI Process (Foundry) | ||
|
||
We recommend that you propose from your CI process instead of using the command line. This ensures that your deployments are reproducible, and that they don't depend on a single developer's machine, which can be a source of bugs. | ||
|
||
This guide will show you how to integrate proposals into your CI process using GitHub Actions. You can still follow this guide if you're using a different CI platform, but the exact configuration may be slightly different. | ||
|
||
If you're using Sphinx's Foundry plugin instead of Foundry, check out the [Foundry version of this guide](https://github.com/sphinx-labs/sphinx/blob/develop/docs/ci-foundry-proposals.md). | ||
|
||
## Table of Contents | ||
|
||
TODO | ||
|
||
## Prerequisites | ||
|
||
Make sure that you've already completed the [Getting Started with the DevOps Platform](https://github.com/sphinx-labs/sphinx/blob/develop/docs/ops-hardhat-getting-started.md) guide for the project you're going to use in this guide. | ||
|
||
Also, make sure that your `hardhat.config.ts` file has a `networks` section that contains an RPC endpoint for each network you want to support in your project. | ||
|
||
## Create a new branch in your repo | ||
|
||
`git checkout -B sphinx/integrate-ci` | ||
|
||
## Create a Github Actions folder | ||
|
||
If you already have a `.github/` folder, you can skip this step. | ||
|
||
Run the following command in the root directory of your project: | ||
|
||
`mkdir -p .github/workflows` | ||
|
||
## Create a new workflow `deploy.yml` | ||
|
||
`touch .github/workflows/deploy.yml` | ||
|
||
## Create the action template | ||
|
||
We'll create an action template that runs the `propose` command on every push to the `main` branch. We'll also use the `--dry-run` flag to check that a proposal will complete successfully whenever a PR is opened and updated. | ||
|
||
Copy and paste the following into your `deploy.yml` file: | ||
|
||
``` | ||
name: Sphinx Propose | ||
env: | ||
PROPOSER_PRIVATE_KEY: ${{ secrets.PROPOSER_PRIVATE_KEY }} | ||
SPHINX_API_KEY: ${{ secrets.SPHINX_API_KEY }} | ||
# Put any node provider API keys or urls here. For example: | ||
# ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} | ||
# Performs a dryrun proposal when a PR is opened and updated to confirm the | ||
$ proposal will complete successfully after a PR is merged | ||
on: pull_request | ||
jobs: | ||
sphinx-dry-run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: yarn install | ||
- run: npx hardhat sphinx-propose --config-path path/to/config --dry-run | ||
# Triggers a deployment when a change is merged to main | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
sphinx-propose: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: yarn install | ||
- run: npx hardhat sphinx-propose --config-path path/to/config --confirm | ||
``` | ||
|
||
Here is a checklist of things to do before moving on: | ||
- [ ] Add the `PROPOSER_PRIVATE_KEY` secret to your CI process. This should be the private key of one of the proposer addresses in your Sphinx config file (under the `proposers` field). | ||
- [ ] Add the `SPHINX_API_KEY` secret to your CI process. You can find this in the Sphinx UI after registering your organization. | ||
- [ ] Enter any node provider API keys or urls in the `env` section of the template and make sure they are also [configured as secrets in GitHub actions](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository). | ||
- [ ] If you want to push to a branch other than `main`, update the `branches` section of the template. | ||
- [ ] If your repository doesn't use `yarn install`, update the `yarn install` step under `jobs`. | ||
- [ ] Add the path to your Sphinx config in the `npx sphinx propose` command under `jobs`. | ||
|
||
## Test your integration | ||
|
||
Push your branch to Github, open a PR, and merge it after the dryrun check completes. You can then go to https://www.sphinx.dev and you'll find your new deployment ready to be funded and approved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.