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 all 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:
- julia ./benchmarks/runbenchmarks.jl
after_success:
- julia -e 'if get(ENV, "STAGE", "") == "test"
using Pkg; cd(Pkg.dir("Turing")); Pkg.add("Coverage");
Expand Down
45 changes: 45 additions & 0 deletions benchmarks/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -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`)