Skip to content

Commit c53c2c4

Browse files
authored
ci: use github actions instead of aws CI (#73)
* ci: tests in github actions * ci: use docker image as cache * ci: cache image needs to be pulled first * ci: use same build for tests * ci: actually execute the tests * ci: separate building and runtime images * ci: fix push to ecr * ci: missing tag on full image * ci: ignore some files for docker context * ci: build normally on tests * ci: try to deploy alice fullnode * ci: deploy to correct service * ci: specify build output * ci: wrong task-definition file * ci: deploy bob, charlie and full nodes * ci: use different step ids * ci: charlie uses different container name * ci: only deploy on develop branch * ci: remove aws specific buildspecs * ci: purge data in services after deploy
1 parent c4298aa commit c53c2c4

File tree

12 files changed

+388
-54
lines changed

12 files changed

+388
-54
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
.github
3+
task-definition*

.github/workflows/aws-dev.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Deploy to Amazon ECS
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v1
16+
17+
- name: Configure AWS credentials
18+
uses: aws-actions/configure-aws-credentials@v1
19+
with:
20+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
21+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
22+
aws-region: eu-central-1
23+
24+
- name: Login to Amazon ECR
25+
id: login-ecr
26+
uses: aws-actions/amazon-ecr-login@v1
27+
28+
- name: Build, tag, and push image to Amazon ECR
29+
id: build-image
30+
env:
31+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
32+
ECR_REPOSITORY: kilt/prototype-chain
33+
CACHE_IMAGE_TAG: latest-develop
34+
CACHE_IMAGE_BUILDER_TAG: latest-develop-builder
35+
run: |
36+
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG || true
37+
docker build \
38+
--target builder \
39+
--cache-from $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG \
40+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG \
41+
.
42+
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG || true
43+
docker build \
44+
--cache-from $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG \
45+
--cache-from $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG \
46+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG \
47+
.
48+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG
49+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG
50+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG"
51+
52+
- name: (Alice) Fill in the new image ID in the Amazon ECS task definition
53+
id: task-def-alice
54+
uses: aws-actions/amazon-ecs-render-task-definition@v1
55+
with:
56+
task-definition: task-definition-alice.json
57+
container-name: devnet-node
58+
image: ${{ steps.build-image.outputs.image }}
59+
60+
- name: (Alice) Deploy Amazon ECS task definition
61+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
62+
with:
63+
task-definition: ${{ steps.task-def-alice.outputs.task-definition }}
64+
service: bootnode-alice
65+
cluster: kilt-devnet
66+
wait-for-service-stability: true
67+
68+
- name: (Bob) Fill in the new image ID in the Amazon ECS task definition
69+
id: task-def-bob
70+
uses: aws-actions/amazon-ecs-render-task-definition@v1
71+
with:
72+
task-definition: task-definition-bob.json
73+
container-name: devnet-node
74+
image: ${{ steps.build-image.outputs.image }}
75+
76+
- name: (Bob) Deploy Amazon ECS task definition
77+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
78+
with:
79+
task-definition: ${{ steps.task-def-bob.outputs.task-definition }}
80+
service: bootnode-bob
81+
cluster: kilt-devnet
82+
wait-for-service-stability: true
83+
84+
- name: (Charlie) Fill in the new image ID in the Amazon ECS task definition
85+
id: task-def-charlie
86+
uses: aws-actions/amazon-ecs-render-task-definition@v1
87+
with:
88+
task-definition: task-definition-charlie.json
89+
container-name: devnet-charlie
90+
image: ${{ steps.build-image.outputs.image }}
91+
92+
- name: (Charlie) Deploy Amazon ECS task definition
93+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
94+
with:
95+
task-definition: ${{ steps.task-def-charlie.outputs.task-definition }}
96+
service: bootnode-charlie
97+
cluster: kilt-devnet
98+
wait-for-service-stability: true
99+
100+
- name: (Full) Fill in the new image ID in the Amazon ECS task definition
101+
id: task-def-full
102+
uses: aws-actions/amazon-ecs-render-task-definition@v1
103+
with:
104+
task-definition: task-definition-full.json
105+
container-name: devnet-node
106+
image: ${{ steps.build-image.outputs.image }}
107+
108+
- name: (Full) Deploy Amazon ECS task definition
109+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
110+
with:
111+
task-definition: ${{ steps.task-def-full.outputs.task-definition }}
112+
service: full-nodes
113+
cluster: kilt-devnet
114+
wait-for-service-stability: true
115+
116+
- name: Purge data in demo services
117+
env:
118+
SERVICES_SECRET: ${{ secrets.SERVICES_SECRET }}
119+
run: |
120+
curl -X DELETE -H "Authorization: ${SERVICES_SECRET}" https://services.devnet.kilt.io/ctype
121+
curl -X DELETE -H "Authorization: ${SERVICES_SECRET}" https://services.devnet.kilt.io/messaging
122+
curl -X DELETE -H "Authorization: ${SERVICES_SECRET}" https://services.devnet.kilt.io/contacts

.github/workflows/tests.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- master
8+
tags:
9+
- '*'
10+
pull_request:
11+
branches:
12+
- develop
13+
- master
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v1
23+
24+
- name: Configure AWS credentials
25+
uses: aws-actions/configure-aws-credentials@v1
26+
with:
27+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
aws-region: eu-central-1
30+
31+
- name: Login to Amazon ECR
32+
id: login-ecr
33+
uses: aws-actions/amazon-ecr-login@v1
34+
35+
- name: Build and Test
36+
env:
37+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
38+
ECR_REPOSITORY: kilt/prototype-chain
39+
CACHE_IMAGE_TAG: latest-develop
40+
CACHE_IMAGE_BUILDER_TAG: latest-develop-builder
41+
run: |
42+
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG || true
43+
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG || true
44+
docker build \
45+
--cache-from $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_BUILDER_TAG \
46+
--cache-from $ECR_REGISTRY/$ECR_REPOSITORY:$CACHE_IMAGE_TAG \
47+
.

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ COPY . /build
4646

4747
RUN /bin/bash scripts/build.sh
4848

49-
RUN cargo build --release && cargo test
49+
RUN cargo build --release
50+
RUN cargo test --release -p mashnet-node-runtime
5051

5152

5253
FROM ubuntu:xenial

buildspec-ci.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

buildspec.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

runtime/wasm/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

task-definition-alice.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"family": "devnet-node-alice",
3+
"taskRoleArn": "arn:aws:iam::348099934012:role/ecsTaskExecutionRole",
4+
"executionRoleArn": "arn:aws:iam::348099934012:role/ecsTaskExecutionRole",
5+
"containerDefinitions": [
6+
{
7+
"name": "devnet-node",
8+
"image": "348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain:0.21.2",
9+
"logConfiguration": {
10+
"logDriver": "awslogs",
11+
"options": {
12+
"awslogs-group": "/ecs/devnet-node-alice",
13+
"awslogs-region": "eu-central-1",
14+
"awslogs-stream-prefix": "ecs"
15+
}
16+
},
17+
"portMappings": [
18+
{
19+
"hostPort": 30333,
20+
"protocol": "tcp",
21+
"containerPort": 30333
22+
}
23+
],
24+
"command": [
25+
"./start-node.sh",
26+
"--validator",
27+
"--node-name",
28+
"alice",
29+
"--telemetry",
30+
"--devnet"
31+
],
32+
"secrets": [
33+
{
34+
"name": "NODE_KEY",
35+
"valueFrom": "arn:aws:ssm:eu-central-1:348099934012:parameter/ECS/devnet/node/alice/key"
36+
},
37+
{
38+
"name": "NODE_SEED",
39+
"valueFrom": "arn:aws:ssm:eu-central-1:348099934012:parameter/ECS/devnet/node/alice/seed"
40+
}
41+
],
42+
"essential": true
43+
}
44+
],
45+
"cpu": "1024",
46+
"memory": "2048",
47+
"requiresCompatibilities": [
48+
"FARGATE"
49+
],
50+
"networkMode": "awsvpc"
51+
}

task-definition-bob.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"family": "devnet-node-bob",
3+
"taskRoleArn": "arn:aws:iam::348099934012:role/ecsTaskExecutionRole",
4+
"executionRoleArn": "arn:aws:iam::348099934012:role/ecsTaskExecutionRole",
5+
"containerDefinitions": [
6+
{
7+
"name": "devnet-node",
8+
"image": "348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain:0.21.2",
9+
"logConfiguration": {
10+
"logDriver": "awslogs",
11+
"options": {
12+
"awslogs-group": "/ecs/devnet-node-bob",
13+
"awslogs-region": "eu-central-1",
14+
"awslogs-stream-prefix": "ecs"
15+
}
16+
},
17+
"portMappings": [
18+
{
19+
"hostPort": 30333,
20+
"protocol": "tcp",
21+
"containerPort": 30333
22+
}
23+
],
24+
"command": [
25+
"./start-node.sh",
26+
"--validator",
27+
"--node-name",
28+
"bob",
29+
"--connect-to",
30+
"alice",
31+
"--telemetry",
32+
"--devnet"
33+
],
34+
"secrets": [
35+
{
36+
"name": "NODE_KEY",
37+
"valueFrom": "arn:aws:ssm:eu-central-1:348099934012:parameter/ECS/devnet/node/bob/key"
38+
},
39+
{
40+
"name": "NODE_SEED",
41+
"valueFrom": "arn:aws:ssm:eu-central-1:348099934012:parameter/ECS/devnet/node/bob/seed"
42+
}
43+
],
44+
"essential": true
45+
}
46+
],
47+
"cpu": "1024",
48+
"memory": "2048",
49+
"requiresCompatibilities": [
50+
"FARGATE"
51+
],
52+
"networkMode": "awsvpc"
53+
}

0 commit comments

Comments
 (0)