Skip to content

Commit

Permalink
Added travis related content to enable checks
Browse files Browse the repository at this point in the history
tendrl-bug-id: documentation/#64

Signed-off-by: Shubhendu <[email protected]>
  • Loading branch information
Shubhendu committed Nov 30, 2016
1 parent bca2cbe commit db9c338
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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"
- 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
46 changes: 46 additions & 0 deletions check_commit_message.py
Original file line number Diff line number Diff line change
@@ -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:<tendrl_repo>/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)
42 changes: 42 additions & 0 deletions tendrl-redpen-conf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<redpen-conf lang="en">
<validators>
<!--Rules on sentence length-->
<validator name="SentenceLength">
<property name="max_len" value="120"/>
</validator>
<validator name="CommaNumber" />

<!--Rules on expressions-->
<validator name="SymbolWithSpace"/>
<validator name="SectionLength">
<property name="max_char_num" value="2000"/>
</validator>
<validator name="Contraction" />
<validator name="SuccessiveWord" />
<validator name="EndOfSentence" />
<validator name="FrequentSentenceStart"/>
<validator name="UnexpandedAcronym"/>
<validator name="WeakExpression"/>

<!--Rules on sections and paragraphs-->
<validator name="ParagraphNumber"/>
<validator name="SpaceBeginningOfSentence" />
<validator name="ParenthesizedSentence"/>
<validator name="VoidSection" />
<validator name="GappedSection" />
<validator name="SectionLevel" />

<!--Rules on symbols and terminologies-->
<validator name="InvalidSymbol"/>
<validator name="Spelling">
<property name="list" value="Tendrl,Github,Jira,workflow,tendrl,tendrl-devel,tendrl-gluster-integration,tendrl-ceph-integration,tendrl-common,tendrl-api,tendrl-ui" />
</validator>
<validator name="WordFrequency"/>
<validator name="Hyphenation"/>
<validator name="NumberFormat"/>

<!--Load JavaScript validators-->
<validator name="JavaScript" />
</validators>
</redpen-conf>

0 comments on commit db9c338

Please sign in to comment.