Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Oct 12, 2021
0 parents commit fa2943c
Show file tree
Hide file tree
Showing 63 changed files with 3,094 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
48 changes: 48 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: pr-test

# 1. Runs tests
# 2. Upload coverage

on:
pull_request:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Bring up DBs
run: docker-compose -f docker-compose.db.yml up -d

- name: Run unit tests
run: cd src && go test -v -covermode=atomic -coverprofile=coverage.out ./...

- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: unit
fail_ci_if_error: true

- name: Bring up stack
run: make up

- name: Run integration tests
run: cd tests && go test -v -covermode=atomic -coverprofile=coverage.out ./...

- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
flags: integration
fail_ci_if_error: true
49 changes: 49 additions & 0 deletions .github/workflows/push-chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: push-chart

# 1. Run unit and integration tests on chart
# 2. Release the chart

on:
push:
branches:
- main
paths:
- 'chart/**'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: 'v1.16.0'
kubernetes version: 'v1.19.2'

- name: Test
run: |
sudo apt-get -y install socat
export KUBE_CONFIG_PATH=$HOME/.kube/config
cd chart/test
go test .
cd ../..
- name: Configure Git
run: |
git config user.name "geometrybot"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
145 changes: 145 additions & 0 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: push-main

# 1. Run unit and integration tests
# 2. Push containers to AWS ECR with tag based on incrementing build number
# 3. Recommit an update to the chart's deployments with the updated build number in the `deployment` branch

on:
push:
branches:
- main
paths-ignore:
- 'chart/**'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install deps
run: |
pip3 install -r requirements_api.txt -r requirements_worker.txt -r requirements_dev.txt
pip3 install --upgrade protobuf
- name: Bring up stack
run: make up-dbs && sleep 30

- name: Check stack
run: make ps

- name: Run tests with coverage
run: make test-coverage

- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./.coverage
fail_ci_if_error: true

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_WORKER }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_WORKER }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr-worker
uses: aws-actions/amazon-ecr-login@v1

- name: Worker - Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr-worker.outputs.registry }}
ECR_REPOSITORY: icon-metrics-worker
IMAGE_TAG: ${{ github.run_number }}
run: |
docker build --target prod --build-arg SERVICE_NAME=worker -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_API }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_API }}
aws-region: us-west-2

- name: Login to Amazon ECR
id: login-ecr-api
uses: aws-actions/amazon-ecr-login@v1

- name: API - Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr-api.outputs.registry }}
ECR_REPOSITORY: icon-metrics-api
IMAGE_TAG: ${{ github.run_number }}
run: |
docker build --target prod --build-arg SERVICE_NAME=api -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Merge main -> deployment-dev
uses: devmasx/[email protected]
with:
type: now
from_branch: main
target_branch: deployment-dev
github_token: ${{ github.token }}

- name: Checkout dev deployment
uses: actions/checkout@v2
with:
ref: deployment-dev
path: deployment-dev

- name: Update dev-mainnet deployment values file (API) and re-commit
uses: fjogeleit/yaml-update-action@master
with:
valueFile: 'chart/deployments/dev-mainnet/values.dev.yaml'
propertyPath: 'api.image.tag'
value: ${{ github.run_number }}
branch: deployment-dev
createPR: 'false'
token: ${{ secrets.GITHUB_TOKEN }}
updateFile: true
commitChange: false
workDir: deployment-dev

- name: Update dev-mainnet deployment values file (WORKER) and re-commit
uses: fjogeleit/yaml-update-action@master
with:
valueFile: 'chart/deployments/dev-mainnet/values.dev.yaml'
propertyPath: 'worker.image.tag'
value: ${{ github.run_number }}
branch: deployment-dev
createPR: 'false'
message: 'Update dev deployment (mainnet) image versions to ${{ github.run_number }}'
token: ${{ secrets.GITHUB_TOKEN }}
updateFile: true
workDir: deployment-dev

# - name: Update dev-mainnet deployment values file (API) and re-commit
# uses: fjogeleit/yaml-update-action@master
# with:
# valueFile: 'chart/deployments/dev-sejong/values.dev.yaml'
# propertyPath: 'api.image.tag'
# value: ${{ github.run_number }}
# branch: deployment-dev
# createPR: 'false'
# token: ${{ secrets.GITHUB_TOKEN }}
# updateFile: true
# commitChange: false
# workDir: deployment-dev
#
# - name: Update dev-mainnet deployment values file (WORKER) and re-commit
# uses: fjogeleit/yaml-update-action@master
# with:
# valueFile: 'chart/deployments/dev-sejong/values.dev.yaml'
# propertyPath: 'worker.image.tag'
# value: ${{ github.run_number }}
# branch: deployment-dev
# createPR: 'false'
# message: 'Update dev deployment (sejong) image versions to ${{ github.run_number }}'
# token: ${{ secrets.GITHUB_TOKEN }}
# updateFile: true
# workDir: deployment-dev
Loading

0 comments on commit fa2943c

Please sign in to comment.