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 59c6506
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", "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`)
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

1 comment on commit 59c6506

@BayesBot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benchmark job for this commit is finished.

The report is committed in this commit: TuringLang/TuringBenchmarks#b1bfb4e87fe0e6a7fdf4c00508376f897dd7e772.

You can see the report at https://github.com/TuringLang/TuringBenchmarks/blob/report/jobs/BMCI-0-59c6506-201906240958.report.md.

Please sign in to comment.