Skip to content

Commit

Permalink
test(travis): Added validate-commit-msg to Travis CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twolfson committed Mar 13, 2016
1 parent 87c56e3 commit bdbc478
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
51 changes: 27 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
# node_js:
# - "0.10"
# - "0.12"
# - "4"
# - "5"

env:
global:
- SAUCE_USERNAME: karmarunnerbot
- secure: "bRVY+hYZwMf1SqVnMyZRJTLD0gN1hLx9/MwO8MM/qBiu3YNjXy49XElfMdzMKN6cZeKTmhcnjmZonbJuI1PQ2t+utGkyjnlVLJ/OlWptreKLzIlcbt4hrdPoTcjmUTwDWq9Ex9cVoYX8AzCasETttpczp3P+s3+vmOUj8z25JyU="
- CXX=g++-4.8
# global:
# - SAUCE_USERNAME: karmarunnerbot
# - secure: "bRVY+hYZwMf1SqVnMyZRJTLD0gN1hLx9/MwO8MM/qBiu3YNjXy49XElfMdzMKN6cZeKTmhcnjmZonbJuI1PQ2t+utGkyjnlVLJ/OlWptreKLzIlcbt4hrdPoTcjmUTwDWq9Ex9cVoYX8AzCasETttpczp3P+s3+vmOUj8z25JyU="
# - CXX=g++-4.8
include:
- node_js: "5"
env: VALIDATE_COMMIT_MSG=TRUE

# Make sure we have a new npm on Node 0.10. npm >= 2 should work so by not updating them
# here we have proper version coverage, especially that most people use the npm version
# that's included in a Node version they use.
before_install:
- '[ "${TRAVIS_NODE_VERSION}" != "0.10" ] || npm install -g npm'
- npm config set loglevel warn
- g++-4.8 --version
# - g++-4.8 --version

addons:
firefox:
"latest"
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
# addons:
# firefox:
# "latest"
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-4.8

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm run init
- export $(openssl aes-256-cbc -pass env:CREDENTIALS_PASS -d -in credentials)
# before_script:
# - export DISPLAY=:99.0
# - sh -e /etc/init.d/xvfb start
# - npm run init
# - export $(openssl aes-256-cbc -pass env:CREDENTIALS_PASS -d -in credentials)

script:
- npm run travis
- 'if [ "${VALIDATE_COMMIT_MSG}" != "TRUE" ]; then npm run travis; else ./scripts/validate-commit-msg.sh "${TRAVIS_COMMIT}"; fi'
31 changes: 31 additions & 0 deletions scripts/validate-commit-msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#
# Validate commit message matches our expected format
#
# Arguments:
# <commit> Commit revision to validate
#
# Example:
# ./validate-commit-msg.sh abcdef0

# Exit on first error
set -e

# If we didn't receive a commit, then error out
# DEV: If want the HEAD commit, then use `git rev-parse HEAD`
COMMIT_REV="$1"
if [ -z "$COMMIT_REV" ]; then
echo "Expected a commit revision to validate but received nothing" 1>&2
exit 1
fi

# Resolve our file for output
# DEV: We use `.git` to avoid cluttering the working directory
GIT_DIR="$(git rev-parse --git-dir)"
TARGET_FILE="$GIT_DIR/VALIDATE_COMMIT_MSG"

# Output our log message to a file
git log --format=format:"%s" -n 1 "$COMMIT_REV" > "$TARGET_FILE"

# Validate our message
./node_modules/.bin/validate-commit-msg "$TARGET_FILE"

0 comments on commit bdbc478

Please sign in to comment.