diff --git a/.travis.yml b/.travis.yml index 6f84c31..db5e99f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,10 @@ before_script: - git remote set-url --push origin https://${GITHUB_TOKEN}@github.com/ivanilves/lstags.git script: + - make build - make lint - make vet - - make build + - if [[ "${TRAVIS_PULL_REQUEST}" == "true" ]]; then make semantic RANGE=$(scripts/travis_range.sh); fi - make stress-test-async CONCURRENT_REQUESTS=128 - make coverage - make blackbox-integration-test diff --git a/Makefile b/Makefile index 12c6f1b..219f979 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,16 @@ lint: fail-on-errors vet: ERRORS=$(shell find . -name "*.go" ! -path "./vendor/*" | xargs -I {} go tool vet {} | tr '`' '|') vet: fail-on-errors +semantic: REGEX:="^(feat|fix|docs|style|refactor|test|chore)(\([a-zA-Z0-9\_\-\/]+\))?: [A-Z]" +semantic: + @if [[ -n "${RANGE}" ]]; then \ + git log --pretty="format:%s" ${RANGE} \ + | egrep -v ${REGEX} | awk '{print "NON-SEMANTIC: "$$0}' | grep . \ + && echo -e "\e[1m\e[31mFATAL: Non-semantic commit messages found (${RANGE})!\e[0m" && exit 1 || echo "OK"; \ + else \ + echo -e "\e[33mERROR: Please define 'RANGE' variable!\e[0m"; exit 1; \ + fi + fail-on-errors: @echo "${ERRORS}" | grep . || echo "OK" @test `echo "${ERRORS}" | grep . | wc -l` -eq 0 @@ -147,8 +157,8 @@ deploy-github: @if [[ "${DO_RELEASE}" == "true" ]]; then \ ${MAKE} --no-print-directory validate-release \ && test -n "${GITHUB_TOKEN}" && git tag ${TAG} && git push --tags \ - && GITHUB_TOKEN=${GITHUB_TOKEN} ./scripts/github-create-release.sh ./dist/release \ - && GITHUB_TOKEN=${GITHUB_TOKEN} ./scripts/github-upload-assets.sh ${TAG} ./dist/assets; \ + && GITHUB_TOKEN=${GITHUB_TOKEN} scripts/github-create-release.sh ./dist/release \ + && GITHUB_TOKEN=${GITHUB_TOKEN} scripts/github-upload-assets.sh ${TAG} ./dist/assets; \ else \ echo "NB! GitHub release skipped! (DO_RELEASE != true)"; \ fi diff --git a/README.md b/README.md index 7cf972c..bdb39cf 100644 --- a/README.md +++ b/README.md @@ -164,11 +164,13 @@ CHANGED sha256:aa96c8dc3815c44d4aceaf1ee7903ce58 37c7be7a096b 2017-10-25T2 **You are very welcome to open pull requests to this repository!** :wink: +:warning: CI build will fail, if your commit messages are not **[semantic](https://github.com/fteem/git-semantic-commits)**! + To maximize our collaboration efficiency we would humbly ask you to follow these recommendations: * Please add reasonable description (what?/why?/etc) to your pull request :exclamation: * Your code should pass CI (Travis) and a [pretty liberal] code review :mag: * If code adds or changes some logic, it should be covered by a unit test :neckbeard: -* Please, please, please: Put meaningful messages on your commits :pray: +* Please, put meaningful and [semantic](https://github.com/fteem/git-semantic-commits) messages on your commits :pray: **NB!** Not a requirement, but a GIF included in PR description would make our world a happier place! diff --git a/scripts/travis_range.sh b/scripts/travis_range.sh new file mode 100755 index 0000000..3631bb0 --- /dev/null +++ b/scripts/travis_range.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +if [[ "${TRAVIS}" != "true" ]]; then + echo "FATAL: This should NOT be run outside Travis!" + exit 1 +fi + +if [[ "${TRAVIS_PULL_REQUEST}" == "true" ]]; then + echo ${TRAVIS_BRANCH}...HEAD +else + echo ${TRAVIS_COMMIT_RANGE} +fi