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
|
2019-08-01 11:01:19 +02:00
|
|
|
- HOMEPAGE_HOST=https://www.offen.dev
|
2019-07-05 19:54:54 +02:00
|
|
|
- NODE_ENV=production
|
2019-08-02 10:31:03 +02:00
|
|
|
- SECRET_ID_SERVER_CONNECTION_STRING=alpha/server/postgresConnectionString
|
2019-07-05 19:54:54 +02:00
|
|
|
|
|
|
|
deploy_preconditions: &deploy_preconditions
|
|
|
|
requires:
|
|
|
|
- server
|
|
|
|
- kms
|
|
|
|
- vault
|
|
|
|
- script
|
|
|
|
- auditorium
|
|
|
|
- packages
|
|
|
|
- shared
|
|
|
|
- accounts
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only: /^master$/
|
|
|
|
|
2019-07-26 13:26:14 +02:00
|
|
|
build_preconditions: &build_preconditions
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore: gh-pages
|
|
|
|
|
2019-04-10 18:17:24 +02:00
|
|
|
jobs:
|
2019-05-30 12:49:29 +02:00
|
|
|
kms:
|
|
|
|
docker:
|
|
|
|
- image: circleci/golang:1.12
|
2019-06-20 12:57:36 +02:00
|
|
|
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" }}
|
2019-05-31 15:46:36 +02:00
|
|
|
- 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
|
2019-04-12 09:04:31 +02:00
|
|
|
environment:
|
|
|
|
- POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
2019-06-20 12:57:36 +02:00
|
|
|
- PORT=8080
|
2019-08-15 11:55:35 +02:00
|
|
|
- EVENT_RETENTION_PERIOD=4464h
|
2019-04-12 09:04:31 +02:00
|
|
|
- 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-07-13 22:04:12 +02:00
|
|
|
command: |
|
|
|
|
cp ~/offen/bootstrap.yml .
|
|
|
|
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
|
2019-07-07 13:21:20 +02:00
|
|
|
- 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" }}
|
2019-07-07 13:21:20 +02:00
|
|
|
- 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" }}
|
2019-06-07 15:01:39 +02:00
|
|
|
- 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
|
2019-07-07 13:21:20 +02:00
|
|
|
environment:
|
2019-07-20 16:27:56 +02:00
|
|
|
CONFIG_CLASS: accounts.config.LocalConfig
|
2019-07-14 22:32:07 +02:00
|
|
|
MYSQL_CONNECTION_STRING: mysql://root:circle@127.0.0.1:3306/circle
|
|
|
|
- image: circleci/mysql:5.7
|
2019-07-10 17:17:50 +02:00
|
|
|
environment:
|
2019-07-14 22:32:07 +02:00
|
|
|
- MYSQL_ROOT_PASSWORD=circle
|
|
|
|
- MYSQL_DATABASE=circle
|
|
|
|
- MYSQL_HOST=127.0.0.1
|
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" }}
|
2019-07-10 17:17:50 +02:00
|
|
|
- run:
|
2019-07-14 22:32:07 +02:00
|
|
|
name: Waiting for MySQL to be ready
|
2019-07-10 17:17:50 +02:00
|
|
|
command: |
|
|
|
|
for i in `seq 1 10`;
|
|
|
|
do
|
2019-07-14 22:32:07 +02:00
|
|
|
nc -z localhost 3306 && echo Success && exit 0
|
2019-07-10 17:17:50 +02:00
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
2019-07-14 22:32:07 +02:00
|
|
|
echo Failed waiting for MySQL && exit 1
|
2019-07-05 19:54:54 +02:00
|
|
|
- run:
|
|
|
|
name: Run tests
|
|
|
|
command: |
|
|
|
|
. venv/bin/activate
|
2019-07-13 22:04:12 +02:00
|
|
|
cp ~/offen/bootstrap.yml .
|
|
|
|
make test-ci
|
2019-07-05 19:54:54 +02:00
|
|
|
|
|
|
|
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
|
2019-07-09 18:59:24 +02:00
|
|
|
working_directory: ~/offen/accounts
|
2019-07-05 19:54:54 +02:00
|
|
|
command: |
|
|
|
|
echo "Deploying accounts ..."
|
2019-07-09 18:59:24 +02:00
|
|
|
$(npm bin)/sls deploy
|
2019-07-05 19:54:54 +02:00
|
|
|
|
|
|
|
deploy_golang:
|
2019-06-28 15:02:48 +02:00
|
|
|
docker:
|
|
|
|
- image: circleci/golang:1.12-node
|
2019-07-05 19:54:54 +02:00
|
|
|
<<: *production_env
|
2019-06-28 15:02:48 +02:00
|
|
|
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-08-02 10:31:03 +02:00
|
|
|
- run:
|
|
|
|
name: Migrate `server` database
|
2019-08-02 10:41:39 +02:00
|
|
|
working_directory: ~/offen/server
|
2019-08-02 10:31:03 +02:00
|
|
|
command: |
|
|
|
|
sudo apt-get update && sudo apt-get install -qq -y python-pip libpython-dev
|
|
|
|
curl -O https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py
|
|
|
|
sudo pip install -q awscli --upgrade
|
2019-08-02 10:55:00 +02:00
|
|
|
go run cmd/migrate/main.go -conn $(aws secretsmanager get-secret-value --secret-id $SECRET_ID_SERVER_CONNECTION_STRING | jq -r '.SecretString')
|
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" }}
|
2019-06-28 15:02:48 +02:00
|
|
|
- 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
|
2019-06-28 15:02:48 +02:00
|
|
|
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-07-25 16:14:37 +02:00
|
|
|
deploy_homepage:
|
|
|
|
docker:
|
2019-08-30 12:33:00 +02:00
|
|
|
- image: circleci/python:3.6-node
|
2019-07-25 16:14:37 +02:00
|
|
|
working_directory: ~/offen/homepage
|
|
|
|
environment:
|
|
|
|
- SOURCE_BRANCH: master
|
|
|
|
- TARGET_BRANCH: gh-pages
|
|
|
|
steps:
|
|
|
|
- checkout:
|
|
|
|
path: ~/offen
|
|
|
|
- restore_cache:
|
|
|
|
key: offen-homepage-{{ checksum "requirements.txt" }}
|
|
|
|
- run:
|
|
|
|
name: Install dependencies
|
|
|
|
command: |
|
|
|
|
python -m venv venv
|
|
|
|
source venv/bin/activate
|
|
|
|
pip install -r requirements.txt
|
|
|
|
- save_cache:
|
|
|
|
paths:
|
|
|
|
- ~/offen/homepage/venv
|
|
|
|
key: offen-homepage-{{ checksum "requirements.txt" }}
|
2019-08-30 12:33:00 +02:00
|
|
|
- run:
|
|
|
|
name: Install image optimization deps
|
|
|
|
command: |
|
2019-09-03 22:20:41 +02:00
|
|
|
sudo npm install svgo -g
|
2019-08-30 12:33:00 +02:00
|
|
|
sudo apt-get install libjpeg-progs optipng
|
2019-07-25 16:14:37 +02:00
|
|
|
- run:
|
|
|
|
name: Deploy
|
|
|
|
command: |
|
|
|
|
source venv/bin/activate
|
|
|
|
|
|
|
|
git config --global user.email $GH_EMAIL
|
|
|
|
git config --global user.name $GH_NAME
|
|
|
|
|
|
|
|
git clone $CIRCLE_REPOSITORY_URL out
|
|
|
|
|
|
|
|
cd out
|
|
|
|
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
|
|
|
|
git rm -rf .
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
make publish
|
|
|
|
|
|
|
|
cp -a output/. out/.
|
|
|
|
|
2019-07-26 13:21:18 +02:00
|
|
|
mkdir -p out/.circleci && cp -a ./../.circleci/. out/.circleci/.
|
2019-07-25 16:14:37 +02:00
|
|
|
cp CNAME out/CNAME
|
|
|
|
cd out
|
|
|
|
|
|
|
|
git add -A
|
|
|
|
git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty
|
|
|
|
|
|
|
|
git push origin $TARGET_BRANCH
|
|
|
|
|
2019-04-11 15:48:36 +02:00
|
|
|
workflows:
|
|
|
|
version: 2
|
2019-06-28 15:02:48 +02:00
|
|
|
test_build_deploy:
|
2019-04-11 15:48:36 +02:00
|
|
|
jobs:
|
2019-07-26 13:26:14 +02:00
|
|
|
- server:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- kms:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- vault:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- script:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- auditorium:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- packages:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- shared:
|
|
|
|
<<: *build_preconditions
|
|
|
|
- accounts:
|
|
|
|
<<: *build_preconditions
|
2019-07-05 19:54:54 +02:00
|
|
|
- deploy_golang:
|
|
|
|
<<: *deploy_preconditions
|
|
|
|
- deploy_node:
|
|
|
|
<<: *deploy_preconditions
|
|
|
|
- deploy_python:
|
|
|
|
<<: *deploy_preconditions
|
2019-07-25 16:14:37 +02:00
|
|
|
- deploy_homepage:
|
|
|
|
<<: *deploy_preconditions
|