diff --git a/.github/workflows/cd-protonet-manual.yml b/.github/workflows/cd-protonet-manual.yml deleted file mode 100644 index b723799dbd..0000000000 --- a/.github/workflows/cd-protonet-manual.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Manual Deployment (Protonet) -# allow to be triggered manually -on: workflow_dispatch - -jobs: -# in order: - # enter standby (prevents autoscaling group from killing node during deploy) - # stop kava - # take ebs + zfs snapshots - # download updated binary and genesis - # reset application database state (only done on internal testnet) - reset-chain-to-zero-state: - uses: ./.github/workflows/cd-reset-internal-testnet.yml - with: - aws-region: us-east-1 - chain-id: proto_2221-17000 - ssm-document-name: kava-testnet-internal-node-update - playbook-name: reset-protonet-playbook.yml - playbook-infrastructure-branch: master - secrets: inherit - - # start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live - start-chain-api: - uses: ./.github/workflows/cd-start-chain.yml - with: - aws-region: us-east-1 - chain-id: proto_2221-17000 - ssm-document-name: kava-testnet-internal-node-update - playbook-name: start-chain-api-playbook.yml - playbook-infrastructure-branch: master - secrets: inherit - needs: [reset-chain-to-zero-state] - - # setup test and development accounts and balances, deploy contracts by calling the chain's api - seed-chain-state: - uses: ./.github/workflows/cd-seed-chain.yml - with: - chain-api-url: https://rpc.app.protonet.us-east.production.kava.io:443 - chain-id: proto_2221-17000 - seed-script-filename: seed-protonet.sh - erc20-deployer-network-name: protonet - genesis_validator_addresses: "kavavaloper14w4avgdvqrlpww6l5dhgj4egfn6ln7gmtp7r2m" - kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION - secrets: inherit - needs: [start-chain-api] - post-pipeline-metrics: - uses: ./.github/workflows/metric-pipeline.yml - if: always() # always run so we metric failures and successes - with: - aws-region: us-east-1 - metric-name: kava.deploys.testnet.proto - namespace: Kava/ContinuousDeployment - secrets: inherit - needs: [seed-chain-state] diff --git a/.github/workflows/cd-protonet.yml b/.github/workflows/cd-protonet.yml index aa0b366619..03986d1c3f 100644 --- a/.github/workflows/cd-protonet.yml +++ b/.github/workflows/cd-protonet.yml @@ -1,41 +1,26 @@ name: Continuous Deployment (Protonet) -## run after every successful CI job of new commits to the master branch -#on: -# workflow_run: -# workflows: [Continuous Integration (Kava Master)] -# types: -# - completed -jobs: - # in order: - # enter standby (prevents autoscaling group from killing node during deploy) - # stop kava - # take ebs + zfs snapshots - # download updated binary and genesis - # reset application database state (only done on internal testnet) - reset-chain-to-zero-state: - # only start cd pipeline if last ci run was successful - if: ${{ github.event.workflow_run.conclusion == 'success' }} - uses: ./.github/workflows/cd-reset-internal-testnet.yml - with: - aws-region: us-east-1 - chain-id: proto_2221-17000 - ssm-document-name: kava-testnet-internal-node-update - playbook-name: reset-protonet-playbook.yml - playbook-infrastructure-branch: master - secrets: inherit +## run after every successful CI job of new commits to the master branch, or on manual dispatch +on: + workflow_run: + workflows: [Continuous Integration (Kava Master)] + types: + - completed + workflow_dispatch: - # start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live - start-chain-api: - uses: ./.github/workflows/cd-start-chain.yml +jobs: + reset-and-restart-chain: + # only start cd pipeline if last ci run was successful (or it this is being manually dispatched) + if: | + github.event_name == 'workflow_dispatch' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') + uses: ./.github/workflows/cd-reset-network.yml with: aws-region: us-east-1 chain-id: proto_2221-17000 - ssm-document-name: kava-testnet-internal-node-update - playbook-name: start-chain-api-playbook.yml + ssm-document-name: kava-protonet-api-instance-update playbook-infrastructure-branch: master secrets: inherit - needs: [reset-chain-to-zero-state] # setup test and development accounts and balances, deploy contracts by calling the chain's api seed-chain-state: @@ -46,9 +31,10 @@ jobs: seed-script-filename: seed-protonet.sh erc20-deployer-network-name: protonet genesis_validator_addresses: "kavavaloper14w4avgdvqrlpww6l5dhgj4egfn6ln7gmtp7r2m" - kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION + kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION secrets: inherit - needs: [start-chain-api] + needs: [reset-and-restart-chain] + post-pipeline-metrics: uses: ./.github/workflows/metric-pipeline.yml if: always() # always run so we metric failures and successes diff --git a/.github/workflows/cd-reset-network.yml b/.github/workflows/cd-reset-network.yml new file mode 100644 index 0000000000..6f402f60c6 --- /dev/null +++ b/.github/workflows/cd-reset-network.yml @@ -0,0 +1,87 @@ +# for use with ephemeral testnets like internal testnet + +name: Reset Ephemeral Network +on: + workflow_call: + inputs: + chain-id: + required: true + type: string + aws-region: + required: true + type: string + ssm-document-name: + required: true + type: string + playbook-infrastructure-branch: + required: true + type: string + secrets: + CI_AWS_KEY_ID: + required: true + CI_AWS_KEY_SECRET: + required: true + KAVA_PRIVATE_GITHUB_ACCESS_TOKEN: + required: true +jobs: + reset-ephemeral-network: + runs-on: ubuntu-latest + steps: + - name: checkout infrastructure repo + uses: actions/checkout@v4 + with: + repository: Kava-Labs/infrastructure + token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }} + path: infrastructure + ref: master + + - name: Set up Go with kava-node-updater cache + uses: actions/setup-go@v5 + with: + go-version-file: infrastructure/cli/kava-node-updater/go.mod + cache-dependency-path: infrastructure/cli/kava-node-updater/go.mod + + - name: build kava node updater + run: cd infrastructure/cli/kava-node-updater && make install && cd ../../../ + + - name: stop chain services & reset data on all chain nodes + run: | + kava-node-updater \ + --debug \ + --max-retries=2 \ + --aws-ssm-document-name=$SSM_DOCUMENT_NAME \ + --infrastructure-git-pointer=$PLAYBOOK_INFRASTRUCTURE_BRANCH \ + --chain-id=$CHAIN_ID \ + --max-upgrade-batch-size=0 \ + --wait-for-node-sync-after-upgrade=false \ + --update-playbook-filename=reset-chain-data.yml + env: + SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }} + CHAIN_ID: ${{ inputs.chain-id }} + AWS_SDK_LOAD_CONFIG: 1 + AWS_REGION: ${{ inputs.aws-region }} + AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }} + PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }} + + # NOTE: we wait for the reset to finish before restarting the nodes to prevent nodes from + # re-syncing the previous chain state. + - name: reconfigure & restart chain services on all chain nodes + run: | + kava-node-updater \ + --debug \ + --max-retries=2 \ + --aws-ssm-document-name=$SSM_DOCUMENT_NAME \ + --infrastructure-git-pointer=$PLAYBOOK_INFRASTRUCTURE_BRANCH \ + --chain-id=$CHAIN_ID \ + --max-upgrade-batch-size=0 \ + --wait-for-node-sync-after-upgrade=false \ + --update-playbook-filename=playbook.yml + env: + SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }} + CHAIN_ID: ${{ inputs.chain-id }} + AWS_REGION: ${{ inputs.aws-region }} + AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }} + AWS_SDK_LOAD_CONFIG: 1 + PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}