Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Initial Workflow Rework #765

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Build
on: # yamllint disable-line rule:truthy
workflow_dispatch:
workflow_call:

jobs:
go_build:
name: Polygon Edge
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3.3.0
with:
go-version: 1.17.x

- name: Build Polygon Edge
run: go build -ldflags="-s -w -linkmode external -extldflags "-static" -X \"github.com/0xPolygon/polygon-edge/versioning.Version=${GITHUB_REF_NAME}@${GITHUB_SHA}\"" && tar -czvf polygon-edge.tar.gz polygon-edge
env:
CC: gcc
CXX: g++
GOARC: amd64
GOOS: linux

- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: polygon-edge
path: polygon-edge.tar.gz
retention-days: 3
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Pull Request CI
on: # yamllint disable-line rule:truthy
workflow_dispatch: {}
pull_request:
branches:
- 'develop'
paths:
- '**.go'

jobs:
build:
name: Build
uses: 0xpolygon/polygon-edge/.github/workflows/build.yml@develop

test:
name: Test
uses: 0xpolygon/polygon-edge/.github/workflows/test.yml@develop
needs: build

gosec:
name: Gosec
runs-on: ubuntu-latest
env:
GO111MODULE: on # yamllint disable-line rule:truthy
steps:
- name: Checkout Source
uses: actions/checkout@v2
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
13 changes: 9 additions & 4 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
name: "CLA Assistant"
on:
on: # yamllint disable-line rule:truthy
issue_comment:
types: [created]
types:
- created
pull_request_target:
types: [opened,closed,synchronize]
types:
- opened
- closed
- synchronize

jobs:
CLAssistant:
Expand All @@ -16,7 +21,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: 'cla.json'
path-to-document: 'https://github.com/0xPolygon/polygon-edge/blob/develop/CLA.md'
Expand Down
164 changes: 164 additions & 0 deletions .github/workflows/deploy.devnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
---
name: DevNet Workflow

on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches:
- develop

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

jobs:
gosec:
name: Gosec and Publish
uses: 0xpolygon/polygon-edge/.github/workflows/security.yml@develop

build:
name: Build
uses: 0xpolygon/polygon-edge/.github/workflows/build.yml@develop

test:
name: Test
uses: 0xpolygon/polygon-edge/.github/workflows/test.yml@develop
needs: build

deploy_devnet:
name: Deploy DevNet
needs: build
concurrency: deploy_devnet
environment:
name: devnet
url: https://rpc.us-east-1.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": "Devnet Deployment - Started"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "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}\"}"
vcastellm marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy DevNet
continue-on-error: true
env:
VALIDATOR_ASGS: ${{ secrets.VALIDATOR_ASGS }}
run: |
# Parallel deploy all nodes, relying on ALB Health Checks
vcastellm marked this conversation as resolved.
Show resolved Hide resolved
echo "Deploying new 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 Devnet 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 "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": "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}}>"
}
}
]
}
Loading