-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
13,242 additions
and
8,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
version: 2.1 | ||
|
||
steps: | ||
- &setup_dependencies | ||
run: | ||
name: Install dependencies (required for fabric) | ||
command: | | ||
pyenv global 3.5.2 | ||
sudo apt-get update | ||
sudo apt-get upgrade | ||
sudo apt-get install libpq-dev | ||
virtualenv --python=python3 .venv | ||
source .venv/bin/activate | ||
pip3 install -r requirements.txt | ||
pip3 install -r dev-requirements.txt | ||
- &add_ssh_keys | ||
add_ssh_keys: | ||
fingerprints: | ||
- "44:81:8d:36:86:55:fa:82:eb:97:65:f4:d7:9a:0b:fa" | ||
|
||
- &encrypt_and_save_backup | ||
run: | ||
name: Encrypt backup to shared GPG key, save to S3 | ||
command: | | ||
export BACKUP_FILENAME=$(ls ~/project/backup/backup-*.tar.gz) | ||
# Not using keyservers because they are hot garbage, pubkey is in env var | ||
echo -e $GPG_KEY > OPENOVERSIGHT_GPG_PUB_KEY.asc | ||
gpg --import OPENOVERSIGHT_GPG_PUB_KEY.asc | ||
gpg --output backup.tar.gz.gpg --encrypt --trust-model always --batch --no-tty --recipient 0x3C4C259402A0E3B2 $BACKUP_FILENAME | ||
# Upload this encrypted backup to S3 | ||
source .venv/bin/activate | ||
pip3 install awscli | ||
export TIMESTAMP=$(date +%s) | ||
cp backup.tar.gz.gpg backup-$TIMESTAMP.tar.gz.gpg | ||
aws s3 cp backup-$TIMESTAMP.tar.gz.gpg s3://openoversight-backups/ | ||
- &backup_production | ||
run: | ||
name: Backup production server | ||
command: | | ||
source .venv/bin/activate | ||
fab production backup | ||
jobs: | ||
staging_backup_and_deploy: | ||
machine: | ||
enabled: true | ||
image: ubuntu-1604:201903-01 | ||
steps: | ||
- checkout | ||
- *setup_dependencies | ||
- *add_ssh_keys | ||
|
||
- run: | ||
name: Backup staging server | ||
command: | | ||
source .venv/bin/activate | ||
fab staging backup | ||
- *encrypt_and_save_backup | ||
|
||
- run: | ||
name: Run migrations and deploy | ||
command: | | ||
source .venv/bin/activate | ||
fab staging migrate | ||
production_backup_and_deploy: | ||
machine: | ||
enabled: true | ||
image: ubuntu-1604:201903-01 | ||
steps: | ||
- checkout | ||
- *setup_dependencies | ||
- *add_ssh_keys | ||
- *backup_production | ||
- *encrypt_and_save_backup | ||
|
||
- run: | ||
name: Run migrations and deploy | ||
command: | | ||
source .venv/bin/activate | ||
fab production migrate | ||
production_backup_only: | ||
docker: | ||
- image: circleci/python:3.6 | ||
steps: | ||
- checkout | ||
- *setup_dependencies | ||
- *add_ssh_keys | ||
- *backup_production | ||
- *encrypt_and_save_backup | ||
|
||
workflows: | ||
staging_cd: | ||
jobs: | ||
- staging_backup_and_deploy: | ||
filters: | ||
branches: | ||
only: develop | ||
production_cd: | ||
jobs: | ||
- production_backup_and_deploy: | ||
filters: | ||
branches: | ||
only: main | ||
weekly: | ||
triggers: | ||
- schedule: | ||
cron: "0 0 * * 0" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
jobs: | ||
- production_backup_only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
backup/** | ||
container_data | ||
container_data | ||
.cache | ||
node_modules | ||
OpenOversight/app/static/dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
language: python | ||
dist: trusty | ||
sudo: false | ||
addons: | ||
firefox: "45.4.0esr" | ||
dist: xenial | ||
sudo: required | ||
python: | ||
- "2.7" | ||
- "3.5" | ||
- "3.6" | ||
- "3.7" | ||
services: | ||
- docker | ||
env: | ||
- DOCKER_COMPOSE_VERSION=1.24.0 | ||
before_install: | ||
- wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz | ||
- mkdir geckodriver | ||
- tar -xzf geckodriver-v0.11.1-linux64.tar.gz -C geckodriver | ||
- export PATH=$PATH:$PWD/geckodriver | ||
- sudo rm /usr/local/bin/docker-compose | ||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose | ||
- chmod +x docker-compose | ||
- sudo mv docker-compose /usr/local/bin | ||
install: | ||
- true | ||
before_script: | ||
- pip install -r dev-requirements.txt | ||
- pip install coveralls | ||
- cd OpenOversight | ||
- pip install coveralls flake8==3.5.0 | ||
- sudo service postgresql stop | ||
script: | ||
- py.test -v -n 4 --dist=loadfile --cov=app | ||
- cd .. && flake8 --ignore=E501,E722 | ||
- sudo make test | ||
- flake8 --ignore=E501,E722 | ||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.