summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkoan <jkoan@users.noreply.github.com>2019-11-05 11:52:05 +0100
committerGitHub <noreply@github.com>2019-11-05 11:52:05 +0100
commit5d1005ecced8b6f56a39c8f9d7c930a4b55006d1 (patch)
tree96164622a1847c3d4c02c450f0fd6c2cbf0ed534
parentc332b256294df0156a218fd187cd001b9c494682 (diff)
parent39f745bc282c45443deef8e13b381f207207da58 (diff)
downloadnavit-compiler_warnings.tar.gz
Merge branch 'trunk' into compiler_warningscompiler_warnings
-rw-r--r--.circleci/config.yml22
-rwxr-xr-xscripts/check_need_build.sh35
2 files changed, 53 insertions, 4 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index bb542a94d..986ffa2c2 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -14,10 +14,17 @@ jobs:
- run:
name: Run CheckStyle Test
command: ./gradlew checkstyleMain
+ - store_artifacts:
+ name: Store checkstyle report
+ path: navit/android/checkstyle
+ destination: reports
build_linux:
<<: *defaults
steps:
- checkout
+ - run: |
+ apt-get update && apt-get install -y git
+ if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Id
command: cat /etc/*release
@@ -39,6 +46,7 @@ jobs:
<<: *defaults
steps:
- checkout
+ - run: if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Install doxygen and other essentials
command: apt-get update && apt-get -y install doxygen ca-certificates git rsync
@@ -54,6 +62,7 @@ jobs:
machine: true
steps:
- checkout
+ - run: if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: install docker
command: circleci-install docker
@@ -75,6 +84,7 @@ jobs:
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
steps:
- checkout
+ - run: if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Id
command: cat /etc/*release
@@ -116,10 +126,6 @@ jobs:
name: Store Lint reports
path: navit/android/build/reports
destination: reports
- - store_artifacts:
- name: Store checkstyle report
- path: /home/circleci/code/navit/android/checkstyle
- destination: reports
- store_test_results:
path: test-results
- run:
@@ -131,6 +137,9 @@ jobs:
- image: ubuntu:14.04
steps:
- checkout
+ - run: |
+ apt-get update && apt-get install -y git
+ if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Prepare the Windows build environment
command: |
@@ -154,6 +163,9 @@ jobs:
- image: navit/dockerfiles:wince
steps:
- checkout
+ - run: |
+ apt-get update && apt-get install -y git-core
+ if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Prepare the WinCE build environment
command: |
@@ -173,6 +185,7 @@ jobs:
- image: navit/tomtom-ng
steps:
- checkout
+ - run: if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Setup common requirements
command: |
@@ -193,6 +206,7 @@ jobs:
- image: navit/tomtom-ng
steps:
- checkout
+ - run: if scripts/check_need_build.sh; then circleci step halt; fi
- run:
name: Setup common requirements
command: |
diff --git a/scripts/check_need_build.sh b/scripts/check_need_build.sh
new file mode 100755
index 000000000..124722e9a
--- /dev/null
+++ b/scripts/check_need_build.sh
@@ -0,0 +1,35 @@
+#!/bin/bash -e
+# ################################################################################################################### #
+# This file exits 1 if there are files of interest that should trigger a build and exits normally otherwise. #
+# The idea is also to build if the exit code is different from 0 as it means we cannot get a filtered list properly. #
+# ################################################################################################################### #
+
+# If we are on a tag, just exit 1 as we want to go on with the build
+git describe --exact-match --tags HEAD 2>&1 2>/dev/null && exit 1 || echo "Not on a tag, checking files diff"
+
+# This block constructs the list of files that differ from the trunk branch.
+# Note that if you are on the trunk or master branch it will return the files modified by the last commit.
+declare -a file_list=$(git diff --name-only refs/remotes/origin/trunk)
+# If there is no diff that might just mean that you are on the trunk or master branch
+# so you just want to check the last commit. This way we still have that check more
+# or less working when pushing directly to trunk or when merging in master.
+if [[ -z "$file_list" ]]; then
+ file_list=$(git diff --name-only HEAD^)
+fi
+
+# This block filters out those don't match the pattern we use to exclude files that should not trigger a build.
+declare -a filters=('^docs/.*' '.*\.md$' '.*\.rst$')
+for f in ${file_list[@]}; do
+ for filter in "${filters[@]}" ; do
+ echo "checking $f with filter $filter"
+ if [[ "$f" =~ $filter ]]; then
+ # This removes the element from the element matching the filter
+ file_list=(${file_list[@]/$f})
+ echo "filtering out $f"
+ break
+ fi
+ done
+done
+
+# exits with a 0 if the list is empty
+[[ -z "${file_list}" ]]