From c1d03f2c4ee57d1c3c0390c9f907f28d1331d15f Mon Sep 17 00:00:00 2001 From: Shubhendu Date: Wed, 30 Nov 2016 17:16:23 +0530 Subject: [PATCH] Added travis related content to enable checks tendrl-bug-id: documentation/#64 Signed-off-by: Shubhendu --- .travis.yml | 23 +++++++++++++++++++++ check_commit_message.py | 46 +++++++++++++++++++++++++++++++++++++++++ tendrl-redpen-conf.xml | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .travis.yml create mode 100644 check_commit_message.py create mode 100644 tendrl-redpen-conf.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a1575f8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +before_install: + - "export TRAVIS_COMMIT_MSG=\\\"$(git log --format=%B --no-merges -n 1)\\" + - "pip install requests" +git: + depth: 4 +env: +- URL=https://github.com/redpen-cc/redpen/releases/download/redpen-1.7.6 + +install: +- "pip install tox-travis" +- yum install java +- wget $URL/redpen-1.7.6.tar.gz +- tar xvf redpen-1.7.6.tar.gz +- export PATH=$PATH:$PWD/redpen-distribution-1.7.6/bin + +language: python +python: + - "2.7" +script: + - "python check_commit_msg.py" + - "redpen -c tendrl-redpen-conf.xml -f asciidoc *.adoc" + - "redpen -c tendrl-redpen-conf.xml -f asciidoc api/*.adoc" +sudo: true diff --git a/check_commit_message.py b/check_commit_message.py new file mode 100644 index 0000000..57bb2ac --- /dev/null +++ b/check_commit_message.py @@ -0,0 +1,46 @@ +#!/bin/python + +import os + +import requests + +commit_msg = str(os.environ['TRAVIS_COMMIT_MSG']) +tendrl_bug_id = None +tendrl_spec = None +github_base_url = "http://github.com/Tendrl" + + +# Extract "tendrl-bug-id" and "tendrl-spec" name from the commit message +for line in commit_msg.split("\n"): + if "tendrl-bug-id" in line: + try: + tendrl_bug_id = line.split("tendrl-bug-id:")[-1].strip() + except Exception as ex: + print(ex) + + if "tendrl-spec" in line: + try: + tendrl_spec = line.split("tendrl-spec:")[-1].strip() + except Exception as ex: + print(ex) + +if tendrl_bug_id is None: + raise Exception("Please add 'tendrl-bug-id:/issue_id' to " + "your commit msg") + +if tendrl_bug_id: + issue = "%s/%s/issues/%s" % (github_base_url, tendrl_bug_id.split( + "/")[0], tendrl_bug_id.split("/")[-1]) + if requests.get(issue).status_code != 200: + raise Exception("Tendrl Bug specified in git commit msg not " + "found!!\n" + "%s" % issue) + print("Tendrl Bug specified in git commit msg found!!\n%s" % issue) + +if tendrl_spec: + spec = "%s/%s.adoc" % ("https://github.com/Tendrl/specifications/tree" + "/master/specs", tendrl_spec) + if requests.get(spec).status_code != 200: + raise Exception("Tendrl Spec specified in git commit msg not found\n" + "%s" % spec) +print("Tendrl Spec specified in git commit msg found!!\n%s" % spec) diff --git a/tendrl-redpen-conf.xml b/tendrl-redpen-conf.xml new file mode 100644 index 0000000..fda6a0d --- /dev/null +++ b/tendrl-redpen-conf.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +