Skip to content

Commit

Permalink
give logs their own subdirectory in the job report path
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Jun 7, 2016
1 parent a5b1362 commit 987230b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 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 Down Expand Up @@ -47,8 +47,8 @@ function build_julia!(config::Config, build::BuildRef, prnumber::Nullable{Int} =

# 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
8 changes: 2 additions & 6 deletions src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ reportrepo(config::Config) = config.reportrepo
# the local directory of the report repository
reportdir(config::Config) = joinpath(workdir(config), split(reportrepo(config), "/")[2])

# the directory where build logs are stored
logdir(config::Config) = joinpath(workdir(config), "logs")

persistdir!(path) = (!(isdir(path)) && mkdir(path); return path)

function persistdir!(config::Config)
persistdir!(workdir(config))
persistdir!(logdir(config))
if isdir(reportdir(config))
gitreset!(reportdir(config))
else
Expand All @@ -46,8 +42,8 @@ function persistdir!(config::Config)
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
23 changes: 14 additions & 9 deletions src/jobs/BenchmarkJob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ end

function Base.summary(job::BenchmarkJob)
result = "BenchmarkJob $(summary(submission(job).build))"
if !(isnull(job.against))
if job.isdaily
result = "$(result) [daily]"
elseif !(isnull(job.against))
result = "$(result) vs. $(summary(get(job.against)))"
end
return result
Expand Down Expand Up @@ -125,6 +127,7 @@ function jobdirname(job::BenchmarkJob)
end

reportdir(job::BenchmarkJob) = joinpath(reportdir(submission(job).config), jobdirname(job))
logdir(job::BenchmarkJob) = joinpath(reportdir(job), "logs")
datadir(job::BenchmarkJob) = joinpath(reportdir(job), "data")

##########################
Expand All @@ -151,6 +154,8 @@ function Base.run(job::BenchmarkJob)
nodelog(cfg, node, "creating job directories in report repository")
nodelog(cfg, node, "...creating $(reportdir(job))...")
mkdir(reportdir(job))
nodelog(cfg, node, "...creating $(logdir(job))...")
mkdir(logdir(job))
nodelog(cfg, node, "...creating $(datadir(job))...")
mkdir(datadir(job))

Expand All @@ -167,15 +172,15 @@ function Base.run(job::BenchmarkJob)
i = 1
while !(found_previous_date) && i < 31
check_date = job.date - Dates.Day(i)
if isdir(joinpath(repordir(cfg), datedirname(check_date)))
if isdir(joinpath(reportdir(cfg), datedirname(check_date)))
results["previous_date"] = check_date
found_previous_date = true
end
i += 1
end
if found_previous_date # untar and retrieve old data
try
previous_path = joinpath(repordir(cfg), datedirname(results["previous_date"]))
previous_path = joinpath(reportdir(cfg), datedirname(results["previous_date"]))
cd(previous_path) do
run(`tar -xvzf data.tar.gz`)
datapath = joinpath(previous_path, "data")
Expand Down Expand Up @@ -224,9 +229,9 @@ function execute_benchmarks!(job::BenchmarkJob, whichbuild::Symbol)
# If we're doing the primary build from a PR, feed `build_julia!` the PR number
# so that it knows to attempt a build from the merge commit
if whichbuild == :primary && submission(job).fromkind == :pr
builddir = build_julia!(cfg, build, submission(job).prnumber)
builddir = build_julia!(cfg, build, logdir(job), submission(job).prnumber)
else
builddir = build_julia!(cfg, build)
builddir = build_julia!(cfg, build, logdir(job))
end
juliapath = joinpath(builddir, "julia")
end
Expand Down Expand Up @@ -265,8 +270,8 @@ function execute_benchmarks!(job::BenchmarkJob, whichbuild::Symbol)
end

benchname = string(build.sha, "_", whichbuild)
benchout = joinpath(reportdir(job), string(benchname, ".out"))
bencherr = joinpath(reportdir(job), string(benchname, ".err"))
benchout = joinpath(logdir(job), string(benchname, ".out"))
bencherr = joinpath(logdir(job), string(benchname, ".err"))
benchresults = joinpath(datadir(job), string(benchname, ".jld"))

open(jlscriptpath, "w") do file
Expand Down Expand Up @@ -377,11 +382,11 @@ function report(job::BenchmarkJob, results)
# write the markdown report
nodelog(cfg, node, "...generating report...")
reportname = "report.md"
open(joinpath(reportdir(job), reportname)) do file
open(joinpath(reportdir(job), reportname), "w") do file
printreport(file, job, results)
end
# push changes to report repo
target_url = upload_report_repo!(job, joinpath(jobdirname(job), reportname), "upload markdown report for $(summary(job))")
target_url = upload_report_repo!(job, joinpath(jobdirname(job), reportname), "upload report for $(summary(job))")
catch err
nodelog(cfg, node, "error when pushing to report repo: $(err)")
end
Expand Down

0 comments on commit 987230b

Please sign in to comment.