diff --git a/docs/source/configuration-variables.rst b/docs/source/configuration-variables.rst index 88358d85d590b5585ebacb87c427e3f021c53455..0f65f546a3da13454f6cee157eeb6c2f6e7bd7a9 100644 --- a/docs/source/configuration-variables.rst +++ b/docs/source/configuration-variables.rst @@ -70,6 +70,7 @@ RECC Configuration Variables * ``RECC_ACTION_UNCACHEABLE`` - if set to any value, sets `do_not_cache` flag to indicate that the build action can never be cached * ``RECC_SKIP_CACHE`` - if set to any value, sets `skip_cache_lookup` flag to re-run the build action instead of looking it up in the cache * ``RECC_ACTION_SALT`` - optional salt value to place the `Action` into a separate cache namespace +* ``RECC_IGNORE_FAILURE_RESULT`` - if set to any value, sets `ignore_failure_result` flag to indicate that the failed build result with non-zero exit code in cache will be ignored ---- diff --git a/src/bin/recc.m.cpp b/src/bin/recc.m.cpp index a2307bf65d272c983891069d92d77d5f2d3e28c1..231f72d8fd2b3aaab85f9c79dc5b6f67aeb6558a 100644 --- a/src/bin/recc.m.cpp +++ b/src/bin/recc.m.cpp @@ -176,6 +176,9 @@ const std::string HELP( "RECC_DONT_SAVE_OUTPUT - if set to any value, prevent build output from \n" " being saved to local disk\n" "\n" + "RECC_IGNORE_FAILURE_RESULT - if set to any value, ignore results with \n" + " non-zero exit code in cache being retrieved \n" + "\n" "RECC_DEPS_GLOBAL_PATHS - if set to any value, report all entries \n" " returned by the dependency command, even if \n" " they are absolute paths\n" diff --git a/src/env.cpp b/src/env.cpp index e1f27b99768bdd40def94e5134520a9786b9fb3e..e2a0b2e572b24c4a0b8b064a7b6272268ec3f2ca 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -88,6 +88,7 @@ bool RECC_LINK_CACHE_ONLY = DEFAULT_RECC_CACHE_ONLY; bool RECC_ACTION_UNCACHEABLE = DEFAULT_RECC_ACTION_UNCACHEABLE; bool RECC_SKIP_CACHE = DEFAULT_RECC_SKIP_CACHE; bool RECC_DONT_SAVE_OUTPUT = DEFAULT_RECC_DONT_SAVE_OUTPUT; +bool RECC_IGNORE_FAILURE_RESULT = DEFAULT_RECC_IGNORE_FAILURE_RESULT; bool RECC_CACHE_UPLOAD_FAILED_BUILD = DEFAULT_RECC_CACHE_UPLOAD_FAILED_BUILD; bool RECC_SERVER_AUTH_GOOGLEAPI = DEFAULT_RECC_SERVER_AUTH_GOOGLEAPI; bool RECC_SERVER_SSL = @@ -357,6 +358,7 @@ void Env::parse_config_variables(const char *const *env) BOOLVAR(RECC_ACTION_UNCACHEABLE) BOOLVAR(RECC_SKIP_CACHE) BOOLVAR(RECC_DONT_SAVE_OUTPUT) + BOOLVAR(RECC_IGNORE_FAILURE_RESULT) BOOLVAR(RECC_CACHE_UPLOAD_FAILED_BUILD) BOOLVAR(RECC_SERVER_AUTH_GOOGLEAPI) BOOLVAR(RECC_SERVER_SSL) diff --git a/src/env.h b/src/env.h index 3dbb14e0901f86b7a6099f68fa31dbc9c932ab48..15f9f1dd9f56c6891a940f67214a18ce1810c3a8 100644 --- a/src/env.h +++ b/src/env.h @@ -202,6 +202,12 @@ extern bool RECC_SKIP_CACHE; */ extern bool RECC_DONT_SAVE_OUTPUT; +/** + * Sets the `ignore_failure_result` flag in the Action to indicate that it will + ignore results with non-zero exit code in cache + */ +extern bool RECC_IGNORE_FAILURE_RESULT; + /** * If true, cache action results even with non-zero subprocess exit codes */ diff --git a/src/executioncontext.cpp b/src/executioncontext.cpp index f4c52baa216ba4b87867fc9b300be526e7081b9a..cca0ff8cb44af8ca74a672aea3f1119a8f65f104 100644 --- a/src/executioncontext.cpp +++ b/src/executioncontext.cpp @@ -517,10 +517,12 @@ int ExecutionContext::executeConfigured(int argc, char *argv[]) recordCounterMetric(COUNTER_NAME_ACTION_CACHE_SKIP, 1); } - // If the results for the action are not cached, we upload the - // necessary resources to CAS: + // If the results for the action are not cached or set to ignore failure + // results with non-zero exit code in cache, we upload the necessary + // resources to CAS: if (!action_in_cache || - (RECC_LINK_METRICS_ONLY && command.is_linker_command())) { + (RECC_LINK_METRICS_ONLY && command.is_linker_command()) || + (RECC_IGNORE_FAILURE_RESULT && result.exit_code() != 0)) { blobs[actionDigest] = action.SerializeAsString(); if (RECC_CACHE_ONLY && !local_runner) { diff --git a/src/reccdefaults.h b/src/reccdefaults.h index 20176813d84986c048f4e068b890f3d0484033ef..b82ec52c8ca835ae6ade99abaa97a72b081a35eb 100644 --- a/src/reccdefaults.h +++ b/src/reccdefaults.h @@ -59,6 +59,7 @@ #define DEFAULT_RECC_ACTION_UNCACHEABLE 0 #define DEFAULT_RECC_SKIP_CACHE 0 #define DEFAULT_RECC_DONT_SAVE_OUTPUT 0 +#define DEFAULT_RECC_IGNORE_FAILURE_RESULT 0 #define DEFAULT_RECC_CACHE_UPLOAD_FAILED_BUILD 0 #define DEFAULT_RECC_WORKING_DIR_PREFIX "" #define DEFAULT_RECC_ACTION_SALT "" diff --git a/test/env/env_set.t.cpp b/test/env/env_set.t.cpp index 282448aa086b3d50773f5b9cb897906b5754c4f7..b97617f8ffab40cf0e59730f4f9b7dd28c32cc4e 100644 --- a/test/env/env_set.t.cpp +++ b/test/env/env_set.t.cpp @@ -42,6 +42,7 @@ TEST_F(EnvTest, EnvSetTest) "RECC_DEPS_OVERRIDE=oneitem", "RECC_OUTPUT_FILES_OVERRIDE=one,two,three", "RECC_REMOTE_ENV_key=val", + "RECC_IGNORE_FAILURE_RESULT=1", "RECC_REMOTE_ENV_anotherkey=anotherval", "RECC_DEPS_EXCLUDE_PATHS=/usr/include,/opt/" "rh/devtoolset-7,/some/dir\\,withcomma", @@ -193,6 +194,9 @@ TEST_F(EnvTest, EnvTestCacheOnly) EXPECT_EQ(expectedACServer, RECC_ACTION_CACHE_SERVER); EXPECT_EQ(true, RECC_CACHE_ONLY); + + // Check that failure results with non-zero exit code are ignored + EXPECT_EQ(1, RECC_IGNORE_FAILURE_RESULT); } TEST_F(EnvTest, EnvTestCacheOnlyCAS)