Skip to content

Commit

Permalink
translate bash script to jl code
Browse files Browse the repository at this point in the history
  • Loading branch information
KDr2 committed Jun 24, 2019
1 parent 3ea402d commit 758356c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
45 changes: 45 additions & 0 deletions scripts/run-benchmarks-on-travis.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")
end
end

SANTI_BR_NAME = 0
COMMIT_SHA = strip(read(`git rev-parse HEAD`))
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`)
15 changes: 8 additions & 7 deletions scripts/run-benchmarks-on-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 758356c

Please sign in to comment.