Skip to content

Commit 4de2739

Browse files
authored
test(travis): add Review comments integration (#117)
1 parent d9850fc commit 4de2739

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ language: node_js
33
node_js: "stable"
44
after_success:
55
- npm run travis:coverage
6+
after_failure:
7+
- sh .travis/review-textlint.sh
68
cache:
79
directories:
810
- node_modules

.travis/review-textlint.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
if [ "$CI_PULL_REQUEST" == false ] || [ -z "$CI_PULL_REQUEST" ]; then
3+
echo 'not pull request.'
4+
exit 0
5+
fi
6+
7+
gem install --no-document checkstyle_filter-git saddler saddler-reporter-github
8+
9+
# Diff Target Branch
10+
# diff HEAD...target
11+
# http://stackoverflow.com/questions/3161204/find-the-parent-branch-of-a-git-branch
12+
# http://qiita.com/upinetree/items/0b74b08b64442f0a89b9
13+
diffBranchName=$(git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -1 | awk -F'[]~^[]' '{print $2}')
14+
# 変更行のみを対象にする
15+
git diff --name-only --diff-filter=ACMR ${diffBranchName} \
16+
| grep -a '*.md$' \
17+
| xargs $(npm bin)/textlint -f checkstyle \
18+
| checkstyle_filter-git diff ${diffBranchName} \
19+
| saddler report \
20+
--require saddler/reporter/github \
21+
--reporter Saddler::Reporter::Github::PullRequestReviewComment

0 commit comments

Comments
 (0)