File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
33TARGETS=" benchmark_driver benchmark_driver_stats ooo_adversary data_benchmark test dynamic_benchmark"
4- FQDN_IMAGE =" swag-builder-cpp"
4+ IMAGE =" swag-builder-cpp"
55CWD=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd ) "
66
7+ # only proceed if this directory is in the latest commit
8+ if [ $( ./can-skip.sh .) ]; then
9+ echo " Skipping build and test for C++ code."
10+ exit 0
11+ fi
12+
713# build the docker image if not present
8- [ ! -z $( docker images -q ${FQDN_IMAGE } ) ] || make -C ${CWD} builder-image
14+ [ ! -z $( docker images -q ${IMAGE } ) ] || make -C ${CWD} builder-image
915
1016docker run -it \
1117 --user $( id -u) :$( id -g) \
1218 -v ${CWD} :/stage \
13- ${FQDN_IMAGE } \
19+ ${IMAGE } \
1420 bash -c " cd /stage; make ${TARGETS} && make zip && ./bin/test"
1521
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Determines if we can skip build and test based on the provided paths we care
4+ # about. If the provided paths DO NOT appear in the latest commits, then we can
5+ # skip build and test. We exit with 0 to indicate we can skip tests and 1 if
6+ # we need to run tests. Based on:
7+ # https://fant.io/p/circleci-early-exit/
8+ set -e
9+
10+ PATHS_TO_SEARCH=" $* "
11+
12+ # an empty path trivially means we can skip build and tests
13+ if [ -z " $PATHS_TO_SEARCH " ]; then
14+ exit 0
15+ fi
16+
17+ LATEST_COMMIT=$( git rev-parse HEAD)
18+ LATEST_COMMIT_IN_PATH=$( git log -1 --format=format:%H --full-diff $PATHS_TO_SEARCH )
19+
20+ # if the given path is not in the latest commit, then we can skip build and tests
21+ if [ $LATEST_COMMIT != $LATEST_COMMIT_IN_PATH ]; then
22+ exit 0
23+ fi
24+
25+ # we need to run the tests
26+ exit 1
You can’t perform that action at this time.
0 commit comments