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

add support for daily benchmark jobs #3

Merged
merged 13 commits into from
Jun 9, 2016
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ The `vs` keyword argument takes a reference string which can points to a Julia c
- `"owner/repo:branch"`: the head commit of the branch named `branch` in the repository `owner/repo`
- `"owner/repo@sha"`: the commit specified by `sha` in the repository `owner/repo`

##### Benchmark Results

Once a `BenchmarjJob` is complete, the results are uploaded to the
[BaseBenchmarkReports](https://github.com/JuliaCI/BaseBenchmarkReports) repository. Each job
has its own directory for results. This directory contains the following items:

- `report.md` is a markdown report that summarizes the job results
- `data.tar.gz` contains raw timing data in JLD format. To untar this file, run
`tar -xzvf data.tar.gz`. You can analyze this data using the
[BenchmarkTools](https://github.com/JuliaCI/BaseBenchmarkReports) package.
- `logs` is a directory containing the build logs and benchmark execution logs for the job.

##### Comment Examples

Here are some examples of comments that trigger a `BenchmarkJob` in various contexts:
Expand Down
12 changes: 12 additions & 0 deletions bin/submit_daily_job.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import GitHub

auth = GitHub.authenticate(ENV["GITHUB_AUTH"])
repo = "JuliaLang/julia"
sha = get(get(GitHub.branch(repo, "master").commit).sha)
message = """
Executing the daily benchmark build, I will reply here when finished:

@nanosoldier `runbenchmarks(ALL, isdaily = true)`
"""

GitHub.create_comment(repo, sha, :commit, auth = auth, params = Dict("body" => message))
5 changes: 5 additions & 0 deletions src/Nanosoldier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const BRANCH_SEPARATOR = ':'
snip(str, len) = length(str) > len ? str[1:len] : str
snipsha(sha) = snip(sha, 7)

gitclone!(repo, path) = run(`git clone git@github.com:$(repo).git $(path)`)

gitreset!() = (run(`git fetch --all`); run(`git reset --hard origin/master`))
gitreset!(path) = cd(gitreset!, path)

include("config.jl")
include("build.jl")
include("submission.jl")
Expand Down
10 changes: 5 additions & 5 deletions src/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end
Base.summary(build::BuildRef) = string(build.repo, SHA_SEPARATOR, snipsha(build.sha))

# if a PR number is included, attempt to build from the PR's merge commit
function build_julia!(config::Config, build::BuildRef, prnumber::Nullable{Int} = Nullable{Int}())
function build_julia!(config::Config, build::BuildRef, logpath, prnumber::Nullable{Int} = Nullable{Int}())
# make a temporary workdir for our build
builddir = mktempdir(workdir(config))
cd(workdir(config))
Expand All @@ -28,7 +28,7 @@ function build_julia!(config::Config, build::BuildRef, prnumber::Nullable{Int} =
if !(isnull(prnumber))
pr = get(prnumber)
# clone from `trackrepo`, not `build.repo`, since that's where the merge commit is
run(`git clone --quiet https://github.com/$(config.trackrepo) $(builddir)`)
gitclone!(config.trackrepo, builddir)
cd(builddir)
try
run(`git fetch --quiet origin +refs/pull/$(pr)/merge:`)
Expand All @@ -40,15 +40,15 @@ function build_julia!(config::Config, build::BuildRef, prnumber::Nullable{Int} =
run(`git checkout --quiet --force FETCH_HEAD`)
build.sha = readchomp(`git rev-parse HEAD`)
else
run(`git clone --quiet https://github.com/$(build.repo) $(builddir)`)
gitclone!(build.repo, builddir)
cd(builddir)
run(`git checkout --quiet $(build.sha)`)
end

# set up logs for STDOUT and STDERR
logname = string(build.sha, "_build")
outfile = joinpath(logdir(config), string(logname, ".out"))
errfile = joinpath(logdir(config), string(logname, ".err"))
outfile = joinpath(logpath, string(logname, ".out"))
errfile = joinpath(logpath, string(logname, ".err"))

# run the build
run(pipeline(`make`, stdout = outfile, stderr = errfile))
Expand Down
20 changes: 11 additions & 9 deletions src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@ end
# the shared space in which child nodes can work
workdir(config::Config) = config.workdir

# the directory where results are stored
resultdir(config::Config) = joinpath(workdir(config), "results")
# the report repository
reportrepo(config::Config) = config.reportrepo

# the directory where build logs are stored
logdir(config::Config) = joinpath(workdir(config), "logs")
# the local directory of the report repository
reportdir(config::Config) = joinpath(workdir(config), split(reportrepo(config), "/")[2])

# ensure directories exists
persistdir!(path) = (!(isdir(path)) && mkdir(path); return path)

function persistdir!(config::Config)
persistdir!(workdir(config))
persistdir!(resultdir(config))
persistdir!(logdir(config))
if isdir(reportdir(config))
gitreset!(reportdir(config))
else
gitclone!(reportrepo(config), reportdir(config))
end
end

function nodelog(config::Config, node, message)
persistdir!(logdir(config))
open(joinpath(logdir(config), "node$(node).log"), "a") do file
persistdir!(workdir(config))
open(joinpath(workdir(config), "node$(node).log"), "a") do file
println(file, now(), " | ", node, " | ", message)
end
end
Loading