Skip to content

Commit 23d85c4

Browse files
authored
Avoid unnecessary builds (the-benchmarker#2477)
1 parent c9459a0 commit 23d85c4

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

.ci/has_to_run.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
set -vx
6+
7+
# Always runs if master
8+
if [ "${TRAVIS_BRANCH}" == "master" ] ; then
9+
exit 0
10+
fi
11+
12+
# List of updated files
13+
git diff master.. --name-only > /tmp/files.txt
14+
15+
FWK=`echo ${FRAMEWORK} | awk -F '.' '{print $1}'`
16+
LNG=`echo ${FRAMEWORK} | awk -F '.' '{print $2}'`
17+
18+
grep "${FWK}" /tmp/files.txt
19+
20+
if [ $? -eq 0 ]; then
21+
echo "${FWK} has been updated, running CI"
22+
exit 0
23+
fi
24+
25+
grep "${LNG}" /tmp/files.txt
26+
27+
if [ $? -eq 0 ]; then
28+
echo "${LNG} has been updated, running CI"
29+
exit 0
30+
fi
31+
32+
echo "No modification detected, exiting ..."
33+
exit 1

.ci/template.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Exit build if no modification found
2+
before_install: bash .ci/has_to_run.sh || travis_terminate 0
3+
14
# Use latest ubuntu LTS (18.04)
25
dist: bionic
36

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Exit build if no modification found
2+
before_install: bash .ci/has_to_run.sh || travis_terminate 0
3+
14
# Use latest ubuntu LTS (18.04)
25
dist: bionic
36

0 commit comments

Comments
 (0)