Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run benchmark on Travis-CI #816

Merged
merged 11 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
- env: STAGE=numerical
- env: STAGE=stan
- env: STAGE=dynamichmc
- env: STAGE=benchmark
include:
- stage: test
os: linux
Expand Down Expand Up @@ -108,6 +109,12 @@ jobs:
- julia -e 'using Pkg, Turing;
cd(joinpath(dirname(pathof(Turing)), ".."));
include(joinpath("docs", "make.jl"))'
- stage: benchmark
julia: 1.1
os: linux
env: STAGE=benchmark
script:
- ./scripts/benchmark-on-ci.sh
after_success:
- julia -e 'if get(ENV, "STAGE", "") == "test"
using Pkg; cd(Pkg.dir("Turing")); Pkg.add("Coverage");
Expand Down
58 changes: 58 additions & 0 deletions scripts/benchmark-on-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
set -v

BASE_BRANCH=master

if [[ $TRAVIS == true ]]; then
if [[ $TRAVIS_PULL_REQUEST == true ]]; then
CURRENT_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
exit 0 # avoid double run on commit and PR
else
CURRENT_BRANCH=$TRAVIS_BRANCH
fi
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)
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

git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all --unshallow

git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks
# TEMP: use travis-ci branch of TuringBenchmarks
git -C ../TuringBenchmarks checkout -b travis-ci origin/travis-ci

unset JULIA_PROJECT
cat > pre.jl <<EOF
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
EOF

julia pre.jl

cat > run.jl <<EOF
using TuringBenchmarks.Runner
Runner.run_bm_on_travis("$BM_JOB_NAME", ("master", "$CURRENT_BRANCH"), "$COMMIT_SHA")
EOF

cat run.jl
julia run.jl