Skip to content

Commit

Permalink
Merge pull request #57 from stevenbal/feature/travis-setup
Browse files Browse the repository at this point in the history
Fixes #1579 -- travis setup
  • Loading branch information
joeribekker authored Mar 23, 2020
2 parents 725b69f + 7d70644 commit 5b29cf0
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 3 deletions.
55 changes: 55 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
language: python
cache: pip

python:
- "3.6"

services:
- postgresql

addons:
postgresql: "10"

env:
global:
- DJANGO_SETTINGS_MODULE=brc.conf.jenkins
- SECRET_KEY=dummy
- DB_USER=postgres
- DB_PASSWORD=
- DEPLOYMENT=brc
matrix:
- TOXENV=django_tests
- TOXENV=isort
- TOXENV=black

install:
- pip install tox tox-travis

script: tox

jobs:
include:
# First stage is 'Tests' by default and populated from env matrix
# expansion
- stage: Docker images
name: Test docker image build
services:
- docker
install: skip
script:
- bash bin/release-docker-image.sh
after_success: echo "deploying..."
deploy:
- provider: script
script: bash bin/cicd.sh latest yes
on:
branch: master

- provider: script
script: bash bin/cicd.sh $TRAVIS_TAG yes
on:
tags: true

after_success:
- pip install codecov
- codecov
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ References
* `Code <https://github.com/VNG-Realisatie/gemma-besluitregistratiecomponent/>`_


.. |build-status| image:: http://jenkins.nlx.io/buildStatus/icon?job=gemma-besluitregistratiecomponent-stable
.. |build-status| image:: https://travis-ci.org/VNG-Realisatie/gemma-besluitregistratiecomponent.svg?branch=develop
:alt: Build status
:target: http://jenkins.nlx.io/job/gemma-besluitregistratiecomponent-stable
:target: https://travis-ci.org/VNG-Realisatie/gemma-besluitregistratiecomponent

.. |requirements| image:: https://requires.io/github/VNG-Realisatie/gemma-besluitregistratiecomponent/requirements.svg?branch=master
:target: https://requires.io/github/VNG-Realisatie/gemma-besluitregistratiecomponent/requirements/?branch=master
Expand Down
38 changes: 38 additions & 0 deletions bin/cicd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -u

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

release_tag=$1
do_deploy=$2
shift

JOB_NAME=push ./bin/release-docker-image.sh $release_tag


deploy() {
set +x

# Trigger deploy
curl https://deploy-bot-zgw.vng.cloud/api/v1/deployments \
-H "Authorization: Token ${DEPLOY_BOT_TOKEN}" \
-H "Content-Type: application/json" \
--request POST \
--data @- << EOF
{
"name":"${DEPLOYMENT}",
"namespace":"zgw",
"containerName":"${DEPLOYMENT}",
"image": "vngr/besluiten-api:${release_tag}"
}
EOF
set -x

echo "Deploy triggered"
}


if [[ $do_deploy == "yes" ]]; then
deploy
fi
2 changes: 1 addition & 1 deletion src/brc/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Meta:
IsImmutableValidator(),
PublishValidator(
"BesluitType", settings.ZTC_API_SPEC, get_auth=get_ztc_auth
)
),
]
},
}
Expand Down
36 changes: 36 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[tox]
envlist =
django_tests
isort
black
skipsdist = true

[travis]
python =
3.6: django_tests, black, isort

[testenv]
passenv =
DJANGO_SETTINGS_MODULE
SECRET_KEY
DB_USER
DB_PASSWORD
whitelist_externals = npm
deps =
-rrequirements/jenkins.txt
codecov
commands =
npm ci
npm run build
python src/manage.py collectstatic --noinput --link
coverage run src/manage.py test src

[testenv:isort]
deps = isort
commands =
isort --recursive --check-only --diff src

[testenv:black]
deps = black
commands =
black --check src

0 comments on commit 5b29cf0

Please sign in to comment.