diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bfa586d --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.rst b/README.rst index 12f0d97..0e51ff6 100644 --- a/README.rst +++ b/README.rst @@ -42,9 +42,9 @@ References * `Code `_ -.. |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 diff --git a/bin/cicd.sh b/bin/cicd.sh new file mode 100644 index 0000000..24852fb --- /dev/null +++ b/bin/cicd.sh @@ -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 diff --git a/src/brc/api/serializers.py b/src/brc/api/serializers.py index a3bd236..7ea4f56 100644 --- a/src/brc/api/serializers.py +++ b/src/brc/api/serializers.py @@ -71,7 +71,7 @@ class Meta: IsImmutableValidator(), PublishValidator( "BesluitType", settings.ZTC_API_SPEC, get_auth=get_ztc_auth - ) + ), ] }, } diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..3af738f --- /dev/null +++ b/tox.ini @@ -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