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

introducing workflow dispatch trigger for Devnet V3 workflow. #927

Merged
merged 4 commits into from
Nov 22, 2022
Merged
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
211 changes: 211 additions & 0 deletions .github/workflows/deploy.devnet.eph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
---
name: Ephemeral DevNet Workflow

on: # yamllint disable-line rule:truthy
workflow_dispatch:

permissions:
id-token: write
contents: read
security-events: write

jobs:
snyk:
name: Snyk and Publish
uses: ./.github/workflows/security.yml
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_ORG: ${{ secrets.SNYK_ORG }}

build:
name: Build
uses: ./.github/workflows/build.yml
secrets:
GH_TOKEN_CLONE_PRIVATE: ${{ secrets.GH_TOKEN_CLONE_PRIVATE }}

test:
name: Test
uses: ./.github/workflows/test.yml
needs: build
secrets:
GH_TOKEN_CLONE_PRIVATE: ${{ secrets.GH_TOKEN_CLONE_PRIVATE }}

deploy_eph_devnet:
name: Deploy Ephemeral DevNet
needs: build
concurrency: deploy_eph_devnet
environment:
name: devnet-ephemeral
url: https://rpc.us-east-1.deph.testing.psdk.io/
runs-on: ubuntu-latest
steps:
- name: Download Polygon Edge Artifact
uses: actions/download-artifact@v3
with:
name: polygon-edge

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Notify Slack
uses: slackapi/slack-github-action@v1.22.0
if: false
continue-on-error: true
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Ephemeral Devnet Deployment - Started"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Ephemeral Devnet Deployment Status: ${{ job.status }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Job Status>"
}
}
]
}

- name: Publish Binary package to S3
run: |
aws s3 cp ./polygon-edge.tar.gz s3://${{ secrets.POLYGON_EDGE_ARTIFACT_BUCKET }} --metadata "{\"commit_sha\":\"${GITHUB_SHA}\"}"

- name: Deploy Ephemeral DevNet
continue-on-error: true
env:
VALIDATOR_ASGS: ${{ secrets.VALIDATOR_ASGS }}
run: |
# Parallel deploy all nodes, relying on ALB Health Checks
echo "Deploying Ephemeral Devnet"
echo "--------------------"

# Should finish relatively fast. Can add a check to guard against pre-mature cycle
echo "Cleaning up the data directories and stopping Polygon-Edge service..."
aws ssm send-command --document-name polygon-edge-validators-maintenance-clean-data --targets Key=tag:aws:autoscaling:groupName,Values=$VALIDATOR_ASGS >> /dev/null

for vasg in ${VALIDATOR_ASGS//,/ }
do
instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $vasg --query 'AutoScalingGroups[0].Instances[0].InstanceId' --output text)
echo "Draining $instance_id in $vasg"
irid=$(aws autoscaling start-instance-refresh --auto-scaling-group-name $vasg --query InstanceRefreshId --output text)
done

echo "Waiting for instance to clear health check..."
pending=true

until [ $pending != true ]
do
pending=false
sleep 10
for vasg in ${VALIDATOR_ASGS//,/ }
do
refresh_status=$(aws autoscaling describe-instance-refreshes --auto-scaling-group-name $vasg --query 'InstanceRefreshes[0].Status' --output text)
echo "ASG: $vasg"
echo "Status: $refresh_status"

if [ "$refresh_status" == "Successful" ]
then
VALIDATOR_ASGS=${VALIDATOR_ASGS//$vasg/}
instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $vasg --query 'AutoScalingGroups[0].Instances[0].InstanceId' --output text)

echo "-------------------------------------------------"
echo "New validator: $instance_id successfully deployed"
echo "-------------------------------------------------"
fi
pending=true
done
echo ""
done
echo "Ephemeral Devnet Deployment Complete"

- name: Notify Slack - Failures
uses: slackapi/slack-github-action@v1.22.0
if: ${{ job.status != 'success' }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Ephemeral Devnet Deployment - Failed"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Job Status>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Commit SHA: <${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}|${{ github.sha }}>\nBranch: <${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name}}>"
}
}
]
}

pandoras_box_eoa:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box
needs: deploy_eph_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet-ephemeral
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: EOA
pandoras_box_erc20:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box
needs: pandoras_box_eoa
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet-ephemeral
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: ERC20
pandoras_box_erc721:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box
needs: pandoras_box_erc20
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet-ephemeral
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: ERC721