From 987230b835b507251e6bd3880ae0de1248e006b7 Mon Sep 17 00:00:00 2001 From: Jarrett Revels Date: Mon, 6 Jun 2016 22:46:58 -0400 Subject: [PATCH] give logs their own subdirectory in the job report path --- src/build.jl | 6 +++--- src/config.jl | 8 ++------ src/jobs/BenchmarkJob.jl | 23 ++++++++++++++--------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/build.jl b/src/build.jl index c29b90d..5c80dd2 100644 --- a/src/build.jl +++ b/src/build.jl @@ -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)) @@ -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)) diff --git a/src/config.jl b/src/config.jl index 2c96cac..e856b2f 100644 --- a/src/config.jl +++ b/src/config.jl @@ -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 @@ -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 diff --git a/src/jobs/BenchmarkJob.jl b/src/jobs/BenchmarkJob.jl index b9184df..0c4d333 100644 --- a/src/jobs/BenchmarkJob.jl +++ b/src/jobs/BenchmarkJob.jl @@ -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 @@ -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") ########################## @@ -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)) @@ -167,7 +172,7 @@ 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 @@ -175,7 +180,7 @@ function Base.run(job::BenchmarkJob) 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") @@ -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 @@ -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 @@ -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