Browse Source

Travis CI - skip unit tests for documentation changes (#5267)

* Add script to skip tests on non master branches with only docs changes

* Review comments - Use 'grep -c' instead of 'wc -l'
pjones-keymap
zvecr 2 months ago
parent
commit
50fce7f255
2 changed files with 23 additions and 1 deletions
  1. 1
    1
      .travis.yml
  2. 22
    0
      util/travis_test.sh

+ 1
- 1
.travis.yml View File

@@ -21,7 +21,7 @@ before_script:
21 21
   - avr-gcc --version
22 22
 script:
23 23
 - git rev-parse --short HEAD
24
-- make test:all
24
+- bash util/travis_test.sh
25 25
 - bash util/travis_build.sh
26 26
 - bash util/travis_docs.sh
27 27
 addons:

+ 22
- 0
util/travis_test.sh View File

@@ -0,0 +1,22 @@
1
+#!/bin/bash
2
+
3
+TRAVIS_COMMIT_MESSAGE="${TRAVIS_COMMIT_MESSAGE:-none}"
4
+TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE:-HEAD~1..HEAD}"
5
+
6
+# test force push
7
+#TRAVIS_COMMIT_RANGE="c287f1bfc5c8...81f62atc4c1d"
8
+
9
+NUM_IMPACTING_CHANGES=$(git diff --name-only -n 1 ${TRAVIS_COMMIT_RANGE} | grep -Ecv '^(docs/)')
10
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
11
+
12
+if [[ "$TRAVIS_COMMIT_MESSAGE" == *"[skip test]"* ]]; then
13
+    echo "Skipping due to commit message"
14
+    exit 0
15
+fi
16
+
17
+if [ "$BRANCH" != "master" ] && [ "$NUM_IMPACTING_CHANGES" == "0" ]; then
18
+    echo "Skipping due to changes not impacting tests"
19
+    exit 0
20
+fi
21
+
22
+make test:all

Loading…
Cancel
Save