From 1e1830870e96e083e8bc867a66b283d4409f3360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20R=C3=A4mi?= Date: Mon, 13 May 2019 17:48:11 +0200 Subject: [PATCH] feat(semantic-releases): use semantic releases Additionally add commit message linting to travis. --- .gitignore | 4 +++ .releaserc.json | 11 +++++++++ .travis.yml | 58 ++++++++++++++++++++++++++++---------------- README.md | 28 +++++++++++++++++++++ commit-msg | 8 ++++++ commitlint.config.js | 1 + setup.py | 2 +- 7 files changed, 90 insertions(+), 22 deletions(-) create mode 100644 .releaserc.json create mode 100755 commit-msg create mode 100644 commitlint.config.js diff --git a/.gitignore b/.gitignore index 4d788f61..83125e46 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,7 @@ target/ # IDE specific configurations .idea/ + +# npm +node_modules/ +package-lock.json diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..b7988250 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,11 @@ +{ + "branch": "release", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + ["@semantic-release/changelog", { + "changelogFile": "CHANGELOG.md" + }], + "@semantic-release/github" + ] +} diff --git a/.travis.yml b/.travis.yml index bea1cb53..0642a948 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,26 +10,42 @@ env: global: - DOCKER_COMPOSE_VERSION=1.23.1 -before_install: - # install newer compose version - - 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 +jobs: + include: + - stage: tests + name: "Tests" + before_install: + # install newer compose version + - 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 - # Workaround for https://github.com/travis-ci/travis-ci/issues/4842 - # Let's stop postgresql - - sudo service postgresql stop - # wait for postgresql to shutdown - - while sudo lsof -Pi :5432 -sTCP:LISTEN -t; do sleep 1; done + # Workaround for https://github.com/travis-ci/travis-ci/issues/4842 + # Let's stop postgresql + - sudo service postgresql stop + # wait for postgresql to shutdown + - while sudo lsof -Pi :5432 -sTCP:LISTEN -t; do sleep 1; done + install: + - docker-compose up -d --build + - npm install @commitlint/{config-conventional,travis-cli} + script: + - docker-compose up -d db caluma + - docker-compose run --rm interval black --check . + - docker-compose run --rm interval flake8 + - ./node_modules/.bin/commitlint-travis + - docker-compose run --rm interval wait-for-it.sh db:5432 + - docker-compose run --rm interval wait-for-it.sh caluma:8000 + - docker-compose run --rm interval pytest --no-cov-on-fail --cov -install: - - docker-compose up -d --build - -script: - - docker-compose up -d db caluma - - docker-compose run --rm interval black --check . - - docker-compose run --rm interval flake8 - - docker-compose run --rm interval wait-for-it.sh db:5432 - - docker-compose run --rm interval wait-for-it.sh caluma:8000 - - docker-compose run --rm interval pytest --no-cov-on-fail --cov + - stage: release + if: branch = release and type = push + script: skip + deploy: + provider: script + skip_cleanup: true + on: + branch: release + script: + - nvm install lts/* + - npx semantic-release diff --git a/README.md b/README.md index 4d07a3e6..a3326731 100644 --- a/README.md +++ b/README.md @@ -225,3 +225,31 @@ interval: depends_on: - caluma ``` + +## Contribution +We use following tools in order to standardize development and releases: + + * flake8 + * black + * isort + * commitlint + +### pre-commit hooks + +Pre commit hooks is an additional option instead of executing checks in your editor of choice. + +First create a virtualenv with the tool of your choice before running below commands: + +```bash +pip install pre-commit +pip install -r requirements-dev.txt -U +pre-commit install +``` + +### commit-msg hook +If you want to have your commit message automatically linted, execute below commands: + +```bash +npm install @commitlint/{config-conventional,cli} +ln -s "$(pwd)/commit-msg" .git/hooks/commit-msg +``` diff --git a/commit-msg b/commit-msg new file mode 100755 index 00000000..aee48084 --- /dev/null +++ b/commit-msg @@ -0,0 +1,8 @@ +#!/bin/sh +# +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. + +cat "$1" | ./node_modules/.bin/commitlint diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..3347cb96 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/setup.py b/setup.py index 9f7ddc7f..29a925fd 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="caluma_interval", - version="0.0.1", + version="0.0.0", description="Caluma companion app for periodic usage of forms", url="https://projectcaluma.github.io/", license="MIT",