Skip to content

Commit 59c6506

Browse files
author
KDr2
committed
translate bash script to jl code
1 parent 3ea402d commit 59c6506

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
os: linux
115115
env: STAGE=benchmark
116116
script:
117-
- ./scripts/run-benchmarks-on-travis.sh
117+
- julia ./scripts/run-benchmarks-on-travis.jl
118118
after_success:
119119
- julia -e 'if get(ENV, "STAGE", "") == "test"
120120
using Pkg; cd(Pkg.dir("Turing")); Pkg.add("Coverage");

scripts/run-benchmarks-on-travis.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Dates
2+
3+
BASE_BRANCH = "master"
4+
CURRENT_BRANCH = strip(read(`git rev-parse --abbrev-ref HEAD`, String))
5+
6+
if get(ENV, "TRAVIS", "false") == "true"
7+
if get(ENV, "TRAVIS_PULL_REQUEST", "false") == "true"
8+
CURRENT_BRANCH = get(ENV, "TRAVIS_PULL_REQUEST_BRANCH")
9+
exit(0)
10+
else
11+
CURRENT_BRANCH = get(ENV, "TRAVIS_BRANCH", "master")
12+
end
13+
end
14+
15+
SANTI_BR_NAME = 0
16+
COMMIT_SHA = strip(read(`git rev-parse HEAD`, String))
17+
COMMIT_SHA_7 = COMMIT_SHA[1:7]
18+
TIME = Dates.format(now(), "YYYYmmddHHMM")
19+
BM_JOB_NAME="BMCI-$(SANTI_BR_NAME)-$(COMMIT_SHA_7)-$(TIME)"
20+
21+
run(`git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'`)
22+
run(`git fetch --all --unshallow`)
23+
24+
run(`git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks`)
25+
26+
delete!(ENV, "JULIA_PROJECT")
27+
28+
code_pre = """using Pkg
29+
# Pkg.instantiate()
30+
try pkg"develop ." catch end
31+
try pkg"develop ." catch end
32+
try pkg"build Turing" catch end
33+
using Turing
34+
try pkg"develop ../TuringBenchmarks" catch end
35+
try pkg"develop ../TuringBenchmarks" catch end
36+
pkg"add SpecialFunctions"
37+
using TuringBenchmarks
38+
"""
39+
40+
code_run = """using TuringBenchmarks.Runner
41+
Runner.run_bm_on_travis("$BM_JOB_NAME", ("master", "$CURRENT_BRANCH"), "$COMMIT_SHA")
42+
"""
43+
44+
run(`julia -e $code_pre`)
45+
run(`julia -e $code_run`)

scripts/run-benchmarks-on-travis.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@ if [[ $TRAVIS == true ]]; then
1313
else
1414
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
1515
fi
16-
17-
COMMIT_MSG=$(git show -s --format="%s")
1816

1917
SANTI_BR_NAME=$(echo $CURRENT_BRANCH | sed 's/\W/_/g')
20-
COMMIT_SHA=$(git rev-parse HEAD)
18+
COMMIT_SHA=$(git rev-parse HEAD)
2119
TIME=$(date +%Y%m%d%H%M%S)
2220
BM_JOB_NAME="BMCI-${SANTI_BR_NAME}-${COMMIT_SHA:0:7}-${TIME}"
2321

24-
if [[ $COMMIT_MSG != *"[bm]"* ]]; then
25-
echo "skipping the benchmark jobs."
26-
exit 0
27-
fi
22+
# Run benchmarks by default, so the following lines are commented out
23+
# COMMIT_MSG=$(git show -s --format="%s")
24+
# if [[ $COMMIT_MSG != *"[bm]"* ]]; then
25+
# echo "skipping the benchmark jobs."
26+
# exit 0
27+
# fi
2828

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

3232
git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks
33+
3334
# Notice: uncomment the following line to use travis-ci branch of TuringBenchmarks
3435
# git -C ../TuringBenchmarks checkout -b travis-ci origin/travis-ci
3536

0 commit comments

Comments
 (0)