2
0
mirror of https://github.com/offen/website.git synced 2024-11-23 01:20:29 +01:00
website/.circleci/config.yml

403 lines
12 KiB
YAML
Raw Normal View History

2019-04-10 18:17:24 +02:00
version: 2
2019-04-11 15:48:36 +02:00
2019-07-05 19:54:54 +02:00
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$/
2019-04-10 18:17:24 +02:00
jobs:
2019-05-30 12:49:29 +02:00
kms:
docker:
- image: circleci/golang:1.12
environment:
- PORT=8081
2019-05-30 12:49:29 +02:00
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
2019-05-30 12:49:29 +02:00
- run:
name: Run tests
command: make test-ci
2019-04-11 15:48:36 +02:00
server:
2019-04-10 18:17:24 +02:00
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
2019-04-11 15:48:36 +02:00
working_directory: ~/offen/server
2019-04-10 18:17:24 +02:00
steps:
2019-04-11 15:48:36 +02:00
- checkout:
path: ~/offen
2019-04-10 18:17:24 +02:00
- restore_cache:
2019-04-11 20:19:57 +02:00
key: offen-server-{{ checksum "go.mod" }}
2019-04-10 18:17:24 +02:00
- run:
name: Download modules
command: go mod download
- save_cache:
paths:
- /go/pkg/mod
2019-04-11 20:19:57 +02:00
key: offen-server-{{ checksum "go.mod" }}
2019-04-20 01:37:26 +02:00
- 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
2019-04-10 18:17:24 +02:00
- run:
name: Run tests
2019-04-20 01:37:26 +02:00
command: make test-ci
2019-04-11 15:48:36 +02:00
2019-06-06 13:06:31 +02:00
shared:
docker:
- image: circleci/golang:1.12
working_directory: ~/offen/shared
steps:
- checkout:
path: ~/offen
- run:
name: Install dependencies
command: go get ./...
2019-06-06 13:06:31 +02:00
- run:
name: Run tests
command: make test
2019-04-20 04:50:49 +02:00
vault:
docker:
2019-04-20 17:06:06 +02:00
- image: circleci/node:10-browsers
2019-04-20 04:50:49 +02:00
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
2019-04-27 04:35:53 +02:00
command: npm test
2019-04-20 04:50:49 +02:00
2019-05-10 12:54:39 +02:00
script:
docker:
- image: circleci/node:10-browsers
working_directory: ~/offen/script
steps:
- checkout:
path: ~/offen
- restore_cache:
key: offen-script-{{ checksum "package.json" }}
2019-06-07 15:56:57 +02:00
- run:
name: Install lsof
command: sudo apt-get install lsof
2019-05-10 12:54:39 +02:00
- 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
2019-05-21 16:58:40 +02:00
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 lsof
command: sudo apt-get install lsof
2019-05-21 16:58:40 +02:00
- 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
2019-05-23 16:36:21 +02:00
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
2019-05-23 16:36:21 +02:00
- 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
2019-07-05 19:54:54 +02:00
accounts:
docker:
- image: circleci/python:3.6
environment:
HASHED_PASSWORD: JDJhJDEwJGpFRXJMOVVSQndZQlFQNjkxallkZi53aGp1cDMvRW5maGUvakZleG1pWFlnWEVXcU93ODBp
JWT_PRIVATE_KEY: |-
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzgU18PnRrpbVK
LU4EewU476arjLeMAXoxQAvrufvnwAGlrvnuh+TE7z7R3KslOyP0m3bTMaNyn2la
DFz0ERR8KFA3rbUUDLG8QAUomm6X2WNbZJqFG/ORBWyEWy/bvNEbCTtF8K09v6HT
PcNzpSrzN8MK/xsIXnMTa/acftbfD3jnb1KFNWaSUKgEM9OL8NSW8PpqTf+le/+R
0Dwhd4vNnELpobKY3tvhxjvlQmbZA6vRrOoWfWbKXuS/7B7CWXWEhXPTbcJPcKPt
zlkpJGlrcHgvTBorM/lBZw7zrmfUcJROdX6ziU1ymEENkKtLBORedWdBZU8Ivuyy
hDIzS7cdAgMBAAECggEAVReXfq0wjRMJhHdDg5Y5nIrmbG4RWFoe7ZfZzs3kXzDC
1yLCMdPTm5N6KQu9SbHmUn8b7fOa8qwkyd4QdlZeapjFpg8/RpjZ7E5A48WJZYxU
sC9ZnH3qkTWMApYjcrvoODPBGF+GED52XO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coEomAoy102k4A6WsM2bKf4=
-----END PRIVATE KEY-----
JWT_PUBLIC_KEY: |-
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs4FNfD50a6W1Si1OBHsF
OO+mq4y3jAF6MUAL67n758ABpa757ofkxO8+0dyrJTsj9Jt20zGjcp9pWgxc9BEU
fChQN621FAyxvEAFKJpul9ljW2SahRvzkQVshFsv27zRGwk7RfCtPb+h0z3Dc6Uq
8zfDCv8bCF5zE2v2nH7W3w94529ShTVmklCoBDPTi/DUlvD6ak3/pXv/kdA8IXeL
zZxC6aGymN7b4cY75UJm2QOr0azqFn1myl7kv+wewll1hIVz023CT3Cj7c5ZKSRp
a3B4L0waKzP5QWcO865n1HCUTnV+s4lNcphBDZCrSwTkXnVnQWVPCL7ssoQyM0u3
HQIDAQAB
-----END PUBLIC KEY-----
2019-07-05 19:54:54 +02:00
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
2019-07-05 19:54:54 +02:00
<<: *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
2019-07-05 19:54:54 +02:00
- 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
2019-07-01 21:15:07 +02:00
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
2019-04-11 15:48:36 +02:00
workflows:
version: 2
test_build_deploy:
2019-04-11 15:48:36 +02:00
jobs:
- server
2019-05-30 12:49:29 +02:00
- kms
2019-04-20 04:50:49 +02:00
- vault
2019-05-10 12:54:39 +02:00
- script
2019-05-21 16:58:40 +02:00
- auditorium
2019-05-23 16:36:21 +02:00
- packages
2019-06-06 13:06:31 +02:00
- shared
2019-07-05 19:54:54 +02:00
- accounts
- deploy_golang:
<<: *deploy_preconditions
- deploy_node:
<<: *deploy_preconditions
- deploy_python:
<<: *deploy_preconditions