mirror of
https://github.com/offen/website.git
synced 2024-11-22 09:00:28 +01:00
355 lines
9.6 KiB
YAML
355 lines
9.6 KiB
YAML
version: 2
|
|
|
|
production_env: &production_env
|
|
environment:
|
|
- SERVER_HOST=https://server-alpha.offen.dev
|
|
- KMS_HOST=https://kms-alpha.offen.dev
|
|
- SCRIPT_HOST=https://script-alpha.offen.dev
|
|
- AUDITORIUM_HOST=https://auditorium-alpha.offen.dev
|
|
- VAULT_HOST=https://vault-alpha.offen.dev
|
|
- ACCOUNTS_HOST=https://accounts-alpha.offen.dev
|
|
- NODE_ENV=production
|
|
|
|
deploy_preconditions: &deploy_preconditions
|
|
requires:
|
|
- server
|
|
- kms
|
|
- vault
|
|
- script
|
|
- auditorium
|
|
- packages
|
|
- shared
|
|
- accounts
|
|
filters:
|
|
branches:
|
|
only: /^master$/
|
|
|
|
jobs:
|
|
kms:
|
|
docker:
|
|
- image: circleci/golang:1.12
|
|
environment:
|
|
- PORT=8081
|
|
working_directory: ~/offen/kms
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-kms-{{ checksum "go.mod" }}
|
|
- run:
|
|
name: Download modules
|
|
command: go mod download
|
|
- save_cache:
|
|
paths:
|
|
- /go/pkg/mod
|
|
key: offen-kms-{{ checksum "go.mod" }}
|
|
- run:
|
|
name: Generate one-off key file
|
|
command: make bootstrap
|
|
- run:
|
|
name: Run tests
|
|
command: make test-ci
|
|
|
|
server:
|
|
docker:
|
|
- image: circleci/golang:1.12
|
|
environment:
|
|
- POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
|
- PORT=8080
|
|
- image: circleci/postgres:11.2-alpine
|
|
environment:
|
|
- POSTGRES_USER=circle
|
|
- POSTGRES_PASSWORD=test
|
|
working_directory: ~/offen/server
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-server-{{ checksum "go.mod" }}
|
|
- run:
|
|
name: Download modules
|
|
command: go mod download
|
|
- save_cache:
|
|
paths:
|
|
- /go/pkg/mod
|
|
key: offen-server-{{ checksum "go.mod" }}
|
|
- run:
|
|
name: Waiting for Postgres to be ready
|
|
command: |
|
|
for i in `seq 1 10`;
|
|
do
|
|
nc -z localhost 5432 && echo Success && exit 0
|
|
echo -n .
|
|
sleep 1
|
|
done
|
|
echo Failed waiting for Postgres && exit 1
|
|
- run:
|
|
name: Run tests
|
|
command: make test-ci
|
|
|
|
shared:
|
|
docker:
|
|
- image: circleci/golang:1.12
|
|
working_directory: ~/offen/shared
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- run:
|
|
name: Run tests
|
|
command: make test
|
|
|
|
vault:
|
|
docker:
|
|
- image: circleci/node:10-browsers
|
|
working_directory: ~/offen/vault
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-vault-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/vault/node_modules
|
|
key: offen-vault-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Run tests
|
|
command: npm test
|
|
|
|
script:
|
|
docker:
|
|
- image: circleci/node:10-browsers
|
|
working_directory: ~/offen/script
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-script-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install lsof
|
|
command: sudo apt-get install lsof
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/script/node_modules
|
|
key: offen-script-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Run tests
|
|
command: npm test
|
|
|
|
auditorium:
|
|
docker:
|
|
- image: circleci/node:10-browsers
|
|
working_directory: ~/offen/auditorium
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-auditorium-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/auditorium/node_modules
|
|
key: offen-auditorium-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Run tests
|
|
command: npm test
|
|
|
|
packages:
|
|
docker:
|
|
- image: circleci/node:10-browsers
|
|
working_directory: ~/offen/packages
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-packages-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install lsof
|
|
command: sudo apt-get install lsof
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/packages/node_modules
|
|
key: offen-packages-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Run tests
|
|
command: npm test
|
|
|
|
accounts:
|
|
docker:
|
|
- image: circleci/python:3.6
|
|
working_directory: ~/offen/accounts
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-accounts-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: |
|
|
python3 -m venv venv
|
|
. venv/bin/activate
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-dev.txt
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/accounts/venv
|
|
key: offen-accounts-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
|
|
- run:
|
|
name: Run tests
|
|
command: |
|
|
. venv/bin/activate
|
|
make
|
|
|
|
deploy_python:
|
|
docker:
|
|
- image: circleci/python:3.6-node
|
|
<<: *production_env
|
|
working_directory: ~/offen
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-deploy-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/packages/node_modules
|
|
key: offen-packages-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Deploy
|
|
working_directory: ~/offen
|
|
command: |
|
|
echo "Deploying accounts ..."
|
|
$(npm bin)/sls deploy --config accounts/serverless.yml
|
|
|
|
deploy_golang:
|
|
docker:
|
|
- image: circleci/golang:1.12-node
|
|
<<: *production_env
|
|
working_directory: ~/offen
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-deploy-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/packages/node_modules
|
|
key: offen-packages-{{ checksum "package.json" }}
|
|
|
|
- restore_cache:
|
|
key: offen-server-{{ checksum "server/go.mod" }}
|
|
- run:
|
|
name: Build server service
|
|
working_directory: ~/offen/server
|
|
command: make build
|
|
- run:
|
|
name: Manually clear go cache
|
|
command: sudo rm -rf /go/pkg/mod
|
|
|
|
- restore_cache:
|
|
key: offen-kms-{{ checksum "kms/go.mod" }}
|
|
- run:
|
|
name: Build kms service
|
|
working_directory: ~/offen/kms
|
|
command: make build
|
|
- run:
|
|
name: Manually clear go cache
|
|
command: sudo rm -rf /go/pkg/mod
|
|
|
|
- run:
|
|
name: Deploy
|
|
working_directory: ~/offen
|
|
command: |
|
|
echo "Deploying server ..."
|
|
$(npm bin)/sls deploy --config server/serverless.yml
|
|
echo "Deploying kms ..."
|
|
$(npm bin)/sls deploy --config kms/serverless.yml
|
|
|
|
deploy_node:
|
|
docker:
|
|
- image: circleci/node:10
|
|
<<: *production_env
|
|
working_directory: ~/offen
|
|
steps:
|
|
- checkout:
|
|
path: ~/offen
|
|
- restore_cache:
|
|
key: offen-deploy-{{ checksum "package.json" }}
|
|
- run:
|
|
name: Install dependencies
|
|
command: npm install
|
|
- save_cache:
|
|
paths:
|
|
- ~/offen/packages/node_modules
|
|
key: offen-packages-{{ checksum "package.json" }}
|
|
|
|
- restore_cache:
|
|
key: offen-auditorium-{{ checksum "auditorium/package.json" }}
|
|
- run:
|
|
name: Build auditorium service
|
|
working_directory: ~/offen/auditorium
|
|
command: npm run build
|
|
|
|
- restore_cache:
|
|
key: offen-script-{{ checksum "script/package.json" }}
|
|
- run:
|
|
name: Build script service
|
|
working_directory: ~/offen/script
|
|
command: npm run build
|
|
|
|
- restore_cache:
|
|
key: offen-vault-{{ checksum "vault/package.json" }}
|
|
- run:
|
|
name: Build vault service
|
|
working_directory: ~/offen/vault
|
|
command: npm run build
|
|
|
|
- run:
|
|
name: Deploy
|
|
working_directory: ~/offen
|
|
command: |
|
|
echo "Deploying auditorium ..."
|
|
$(npm bin)/sls deploy --config auditorium/serverless.yml
|
|
$(npm bin)/sls client deploy --config auditorium/serverless.yml --no-confirm
|
|
echo "Deploying script ..."
|
|
$(npm bin)/sls deploy --config script/serverless.yml
|
|
$(npm bin)/sls client deploy --config script/serverless.yml --no-confirm
|
|
echo "Deploying vault ..."
|
|
$(npm bin)/sls deploy --config vault/serverless.yml
|
|
$(npm bin)/sls client deploy --config vault/serverless.yml --no-confirm
|
|
|
|
workflows:
|
|
version: 2
|
|
test_build_deploy:
|
|
jobs:
|
|
- server
|
|
- kms
|
|
- vault
|
|
- script
|
|
- auditorium
|
|
- packages
|
|
- shared
|
|
- accounts
|
|
- deploy_golang:
|
|
<<: *deploy_preconditions
|
|
- deploy_node:
|
|
<<: *deploy_preconditions
|
|
- deploy_python:
|
|
<<: *deploy_preconditions
|