diff --git a/.travis.yml b/.travis.yml index ef50e5249..26f620ff2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,7 +114,7 @@ jobs: os: linux env: STAGE=benchmark script: - - ./scripts/run-benchmarks-on-travis.sh + - julia ./scripts/run-benchmarks-on-travis.jl after_success: - julia -e 'if get(ENV, "STAGE", "") == "test" using Pkg; cd(Pkg.dir("Turing")); Pkg.add("Coverage"); diff --git a/scripts/run-benchmarks-on-travis.jl b/scripts/run-benchmarks-on-travis.jl new file mode 100644 index 000000000..0febe413e --- /dev/null +++ b/scripts/run-benchmarks-on-travis.jl @@ -0,0 +1,45 @@ +using Dates + +BASE_BRANCH = "master" +CURRENT_BRANCH = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) + +if get(ENV, "TRAVIS", "false") == "true" + if get(ENV, "TRAVIS_PULL_REQUEST", "false") == "true" + CURRENT_BRANCH = get(ENV, "TRAVIS_PULL_REQUEST_BRANCH") + exit(0) + else + CURRENT_BRANCH = get(ENV, "TRAVIS_BRANCH", "master") + end +end + +SANTI_BR_NAME = 0 +COMMIT_SHA = strip(read(`git rev-parse HEAD`, String)) +COMMIT_SHA_7 = COMMIT_SHA[1:7] +TIME = Dates.format(now(), "YYYYmmddHHMM") +BM_JOB_NAME="BMCI-$(SANTI_BR_NAME)-$(COMMIT_SHA_7)-$(TIME)" + +run(`git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'`) +run(`git fetch --all --unshallow`) + +run(`git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks`) + +delete!(ENV, "JULIA_PROJECT") + +code_pre = """using Pkg +# Pkg.instantiate() +try pkg"develop ." catch end +try pkg"develop ." catch end +try pkg"build Turing" catch end +using Turing +try pkg"develop ../TuringBenchmarks" catch end +try pkg"develop ../TuringBenchmarks" catch end +pkg"add SpecialFunctions" +using TuringBenchmarks +""" + +code_run = """using TuringBenchmarks.Runner +Runner.run_bm_on_travis("$BM_JOB_NAME", ("master", "$CURRENT_BRANCH"), "$COMMIT_SHA") +""" + +run(`julia -e $code_pre`) +run(`julia -e $code_run`) diff --git a/scripts/run-benchmarks-on-travis.sh b/scripts/run-benchmarks-on-travis.sh index 22ab33b03..69d55a03d 100755 --- a/scripts/run-benchmarks-on-travis.sh +++ b/scripts/run-benchmarks-on-travis.sh @@ -13,23 +13,24 @@ if [[ $TRAVIS == true ]]; then else CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) fi - -COMMIT_MSG=$(git show -s --format="%s") SANTI_BR_NAME=$(echo $CURRENT_BRANCH | sed 's/\W/_/g') -COMMIT_SHA=$(git rev-parse HEAD) +COMMIT_SHA=$(git rev-parse HEAD) TIME=$(date +%Y%m%d%H%M%S) BM_JOB_NAME="BMCI-${SANTI_BR_NAME}-${COMMIT_SHA:0:7}-${TIME}" -if [[ $COMMIT_MSG != *"[bm]"* ]]; then - echo "skipping the benchmark jobs." - exit 0 -fi +# Run benchmarks by default, so the following lines are commented out +# COMMIT_MSG=$(git show -s --format="%s") +# if [[ $COMMIT_MSG != *"[bm]"* ]]; then +# echo "skipping the benchmark jobs." +# exit 0 +# fi git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' git fetch --all --unshallow git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks + # Notice: uncomment the following line to use travis-ci branch of TuringBenchmarks # git -C ../TuringBenchmarks checkout -b travis-ci origin/travis-ci