Skip to content

Commit

Permalink
Merge pull request #820 from freedomofpress/42_SpruceUpCI
Browse files Browse the repository at this point in the history
Spruce Up CI
  • Loading branch information
msheiny authored Aug 6, 2019
2 parents ff6d326 + f30305c commit bd6ae8e
Showing 1 changed file with 48 additions and 44 deletions.
92 changes: 48 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
---
reuse-blerbs:
- &python_prereqs
run:
name: Install testing pre-reqs
command: |
# Set python to 3.5.2
pyenv global 3.5.2
pip install -U pip
pip install pipenv
pipenv install
version: 2
jobs:
safety_check:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/tracker
steps:
- checkout

- run:
name: Install dependencies
command: |
# Set to native py3 on circleci image
pyenv global 3.5.2
pip install -U pip
pip install pipenv
pipenv install
- *python_prereqs

- run:
name: Check Python dependencies for CVEs
Expand All @@ -28,19 +34,14 @@ jobs:
command: make flake8

npm_audit:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/tracker
steps:
- checkout

- run:
name: Install dependencies
command: |
# Set to native py3 on circleci image
pyenv global 3.5.2
pip install -U pip
pip install pipenv
pipenv install
- *python_prereqs

- run:
name: Check node dependencies for vulnerabilities
command: |
Expand All @@ -50,58 +51,62 @@ jobs:
path: ~/tracker/test-results/

dev:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/tracker
steps:
- checkout

- run:
name: Install dependencies
command: |
# Set to native py3 on circleci image
pyenv global 3.5.2
pip install -U pip
pip install pipenv
pipenv install
- *python_prereqs

- run:
name: Ensure we can run dev-env
command: |
make dev-init
pipenv run docker-compose up -d
while ! curl --output /dev/null --silent --head --fail http://localhost:8000; do sleep 1 && echo -n .; done;
while ! curl --output /dev/null --silent --head --fail http://localhost:8000; do sleep 1; done;
pipenv run make dev-tests
pipenv run make check-migrations
no_output_timeout: 5m

- run:
name: Yank docker logs
command: |
mkdir -p ~/dockercomposelogs || true
pipenv run docker-compose logs > ~/dockercomposelogs/dev.log
when: always

- store_artifacts:
path: ~/dockercomposelogs

prod:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/pressfreedom
steps:
- checkout

- run:
name: Install dependencies
command: |
# Set to native py3 on circleci image
pyenv global 3.5.2
pip install -U pip
pip install pipenv
pipenv install
- *python_prereqs

- run:
name: Ensure we can run prod-env
command: |
pipenv run docker-compose -f prod-docker-compose.yaml build
pipenv run docker-compose -f prod-docker-compose.yaml up -d
while ! curl --output /dev/null --silent --head --fail http://$(docker-compose -f prod-docker-compose.yaml port nginx 8080); do sleep 1 && echo -n .; done;
while ! curl --output /dev/null --silent --head --fail http://$(docker-compose -f prod-docker-compose.yaml port nginx 8080); do sleep 1; done;
pipenv run docker-compose -f prod-docker-compose.yaml exec django /bin/bash -c "./manage.py createdevdata"
pipenv run pytest devops/tests/test_basic.py
no_output_timeout: 5m

- run:
name: Push prod containers
name: Yank docker logs
command: |
docker login -u "${QUAY_USER}" -p "${QUAY_PASS}" quay.io || true
make prod-push || true
mkdir -p ~/dockercomposelogs || true
pipenv run docker-compose -f prod-docker-compose.yaml logs > ~/dockercomposelogs/prod.log
when: always

- store_artifacts:
path: ~/dockercomposelogs

workflows:
version: 2
Expand All @@ -110,9 +115,8 @@ workflows:
- safety_check
- npm_audit
- dev
- prod:
requires:
- dev
- prod

nightly:
triggers:
- schedule:
Expand Down

0 comments on commit bd6ae8e

Please sign in to comment.