Upload build logs to the binary cache
This commit is contained in:
parent
7e6486e694
commit
150228d7de
|
@ -3,6 +3,7 @@
|
||||||
#include "state.hh"
|
#include "state.hh"
|
||||||
#include "build-result.hh"
|
#include "build-result.hh"
|
||||||
#include "finally.hh"
|
#include "finally.hh"
|
||||||
|
#include "binary-cache-store.hh"
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
|
@ -148,6 +149,18 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stepNr) {
|
if (stepNr) {
|
||||||
|
/* Upload the log file to the binary cache. FIXME: should
|
||||||
|
be done on a worker thread. */
|
||||||
|
try {
|
||||||
|
auto store = destStore.dynamic_pointer_cast<BinaryCacheStore>();
|
||||||
|
if (uploadLogsToBinaryCache && store && pathExists(result.logFile)) {
|
||||||
|
store->upsertFile("log/" + baseNameOf(buildDrvPath), readFile(result.logFile), "text/plain");
|
||||||
|
unlink(result.logFile.c_str());
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
ignoreException();
|
||||||
|
}
|
||||||
|
|
||||||
/* Asynchronously run plugins. FIXME: if we're killed,
|
/* Asynchronously run plugins. FIXME: if we're killed,
|
||||||
plugin actions might not be run. Need to ensure
|
plugin actions might not be run. Need to ensure
|
||||||
at-least-once semantics. */
|
at-least-once semantics. */
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct Config
|
||||||
bool getBoolOption(const std::string & key, bool def = false)
|
bool getBoolOption(const std::string & key, bool def = false)
|
||||||
{
|
{
|
||||||
auto i = options.find(key);
|
auto i = options.find(key);
|
||||||
return i == options.end() ? def : i->second == "true";
|
return i == options.end() ? def : (i->second == "true" || i->second == "1");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ State::State()
|
||||||
: config(std::make_unique<Config>())
|
: config(std::make_unique<Config>())
|
||||||
, memoryTokens(config->getIntOption("nar_buffer_size", getMemSize() / 2))
|
, memoryTokens(config->getIntOption("nar_buffer_size", getMemSize() / 2))
|
||||||
, maxOutputSize(config->getIntOption("max_output_size", 2ULL << 30))
|
, maxOutputSize(config->getIntOption("max_output_size", 2ULL << 30))
|
||||||
|
, uploadLogsToBinaryCache(config->getBoolOption("upload_logs_to_binary_cache", false))
|
||||||
{
|
{
|
||||||
debug("using %d bytes for the NAR buffer", memoryTokens.capacity());
|
debug("using %d bytes for the NAR buffer", memoryTokens.capacity());
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,8 @@ private:
|
||||||
order to detect non-determinism. */
|
order to detect non-determinism. */
|
||||||
std::map<std::pair<std::string, std::string>, unsigned int> jobsetRepeats;
|
std::map<std::pair<std::string, std::string>, unsigned int> jobsetRepeats;
|
||||||
|
|
||||||
|
bool uploadLogsToBinaryCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State();
|
State();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue