-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devnet): continuous integration
gssmr
devnet on AWS ECS (#2096)
* squashed changes * update Dockerfile * update local devnet * update README * fix lint * update flag * update authorities to include bob and charlie * add scale down step * update working directory * use serviceScaler type * fix imports * unit tests for serviceScaler * use go 1.17 on gha * fix scale-down workflow * update mocks * add licenses * Update devnet/README.md Co-authored-by: Quentin McGaw <[email protected]> * cr feedback * use submodule * cr feedback * cr feedback * fix test? * fix update step in dockerfiles * Update devnet/README.md Co-authored-by: Quentin McGaw <[email protected]> * cr feedback * update workflow Co-authored-by: Quentin McGaw <[email protected]>
- Loading branch information
Showing
29 changed files
with
5,544 additions
and
117 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,85 @@ | ||
name: devnet | ||
on: | ||
push: | ||
branches: | ||
- devnet | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.17.0' | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push alice image to Amazon ECR | ||
id: build-alice | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: gssmr-devnet-alice | ||
IMAGE_TAG: ${{ github.sha }} | ||
DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
run: | | ||
docker build --progress=plain \ | ||
-t=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t=$ECR_REGISTRY/$ECR_REPOSITORY:latest \ | ||
--build-arg DD_API_KEY=$DD_API_KEY --build-arg METRICS_NAMESPACE=gossamer.ecs.devnet \ | ||
-f=devnet/alice.Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
- name: Build, tag, and push bob image to Amazon ECR | ||
id: build-bob | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: gssmr-devnet-bob | ||
IMAGE_TAG: ${{ github.sha }} | ||
DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
run: | | ||
docker build --progress=plain \ | ||
-t=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t=$ECR_REGISTRY/$ECR_REPOSITORY:latest \ | ||
--build-arg key=bob --build-arg DD_API_KEY=$DD_API_KEY --build-arg METRICS_NAMESPACE=gossamer.ecs.devnet \ | ||
-f=devnet/bob.Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
- name: Build, tag, and push charlie image to Amazon ECR | ||
id: build-charlie | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: gssmr-devnet-charlie | ||
IMAGE_TAG: ${{ github.sha }} | ||
DD_API_KEY: ${{ secrets.DD_API_KEY }} | ||
run: | | ||
docker build --progress=plain \ | ||
-t=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t=$ECR_REGISTRY/$ECR_REPOSITORY:latest \ | ||
--build-arg key=charlie --build-arg DD_API_KEY=$DD_API_KEY --build-arg METRICS_NAMESPACE=gossamer.ecs.devnet \ | ||
-f=devnet/bob.Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest | ||
- name: Scale down existing Bob and Charlie | ||
id: scale-down | ||
working-directory: ./devnet/cmd/scale-down-ecs-service | ||
run: | | ||
go run . -c gssmr-ecs -s="gssmr-ecs-(Charlie|Bob)Service-.+$" | ||
- name: docker compose up | ||
id: docker-compose-up | ||
working-directory: ./devnet/gssmr-ecs | ||
run: | | ||
curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh | ||
docker context create ecs gssmr-ecs --from-env | ||
docker context use gssmr-ecs | ||
docker compose up |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*.key | ||
!test-key.key | ||
!test-key-password.key | ||
!devnet/alice.node.key | ||
*.wasm | ||
|
||
test_data | ||
|
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
93ce444331ced4d2f7bfb8296267544e20c2591dbf310c7ea3af672f2879cf8fa999ca3052b725123c2939085e3158dba26624fcfd05c361b1adcc8b27785e35 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 ChainSafe Systems (ON) | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/ecs" | ||
"github.com/jessevdk/go-flags" | ||
) | ||
|
||
type options struct { | ||
ServicesRegex string `short:"s" long:"services" description:"regex query used to match against AWS service names" required:"true"` //nolint:lll | ||
Cluster string `short:"c" long:"cluster" description:"ECS cluster name, must be exact match" required:"true"` //nolint:lll | ||
RequestInterval time.Duration `short:"i" long:"interval" description:"Interval between AWS requests when waiting for service to scale" default:"5s"` //nolint:lll | ||
} | ||
|
||
func main() { | ||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
var opts options | ||
_, err := flags.Parse(&opts) | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
|
||
sess := session.Must(session.NewSessionWithOptions(session.Options{ | ||
SharedConfigState: session.SharedConfigEnable, | ||
})) | ||
|
||
ctx, cancel := context.WithCancel(context.Background()) | ||
done := make(chan error) | ||
go func() { | ||
ss := newServiceScaler(opts.RequestInterval, opts.Cluster, ecs.New(sess)) | ||
done <- ss.scaleServices(ctx, opts.ServicesRegex) | ||
}() | ||
|
||
for { | ||
select { | ||
case err := <-done: | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
// happy path | ||
return | ||
case <-sigs: | ||
cancel() | ||
} | ||
} | ||
} |
Oops, something went wrong.