From 4d2783c352022c28354b5c0534075d944048ec4f Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Thu, 13 Feb 2025 16:57:11 +0100 Subject: [PATCH] chore(IDX): clean up status (#3942) This removes (more) unused status env vars, and removes the workaround used to clean up the volatile status by instead using stable status for farm metadata. This means farm tests will be retriggered if the jobs are run under a new CI job name, which is actually already the case since ic-os images are not cached (we rely on `diff.sh` for skipping tests). --- bazel/ic_version_or_git_sha.sh | 3 --- bazel/workspace_status.sh | 6 +++--- rs/tests/driver/src/driver/farm.rs | 10 ++++------ rs/tests/system_tests.bzl | 16 ++-------------- 4 files changed, 9 insertions(+), 26 deletions(-) diff --git a/bazel/ic_version_or_git_sha.sh b/bazel/ic_version_or_git_sha.sh index 86bc193ee95..bae19f41502 100755 --- a/bazel/ic_version_or_git_sha.sh +++ b/bazel/ic_version_or_git_sha.sh @@ -17,9 +17,6 @@ while read -r k v; do COMMIT_SHA) VERSION="$v" ;; - GIT_TREE_STATUS) - GIT_TREE_STATUS="$v" - ;; BUILD_TIMESTAMP) BUILD_TIMESTAMP="$v" ;; diff --git a/bazel/workspace_status.sh b/bazel/workspace_status.sh index 1ded59196ac..3e18bf05e1f 100755 --- a/bazel/workspace_status.sh +++ b/bazel/workspace_status.sh @@ -14,11 +14,11 @@ echo "GIT_TREE_STATUS $git_tree_status" echo "HOME ${HOME}" # Used as farm metadata -test -n "${CI_JOB_NAME:-}" && echo "CI_JOB_NAME ${CI_JOB_NAME}" +test -n "${CI_JOB_NAME:-}" && echo "STABLE_FARM_JOB_NAME ${CI_JOB_NAME}" if [[ -n "${USER:-}" ]]; then - echo "USER ${USER}" + echo "STABLE_FARM_USER ${USER}" elif [[ -n "${HOSTUSER:-}" ]]; then - echo "USER ${HOSTUSER}" + echo "STABLE_FARM_USER ${HOSTUSER}" fi # Generate a file that changes every time bazel runs. It can be used as dependency for targets we want to always rebuild. diff --git a/rs/tests/driver/src/driver/farm.rs b/rs/tests/driver/src/driver/farm.rs index 47d97bc0750..78ec6de6aa1 100644 --- a/rs/tests/driver/src/driver/farm.rs +++ b/rs/tests/driver/src/driver/farm.rs @@ -448,14 +448,12 @@ pub struct GroupSpec { impl GroupSpec { pub fn add_meta(mut self, group_base_name: &str) -> Self { - // Acquire bazel's volatile status containing key value pairs like USER and CI_JOB_NAME: + // Acquire bazel's stable status containing key value pairs like user and job name: let farm_metadata_path = std::env::var("FARM_METADATA_PATH") .expect("Expected the environment variable FARM_METADATA_PATH to be defined!"); let farm_metadata = read_dependency_to_string(&farm_metadata_path) .unwrap_or_else(|e| { - panic!( - "Couldn't read content of the volatile status file {farm_metadata_path}: {e:?}" - ) + panic!("Couldn't read content of the status file {farm_metadata_path}: {e:?}") }) .trim_end() .to_string(); @@ -463,11 +461,11 @@ impl GroupSpec { // Read values from the runtime args and use sensible defaults if unset let user = runtime_args_map - .get("USER") + .get("STABLE_FARM_USER") // Always set by bazel .cloned() .unwrap_or("CI".to_string()); let job_schedule = runtime_args_map - .get("CI_JOB_NAME") + .get("STABLE_FARM_JOB_NAME") // Injected by workspace status .cloned() .unwrap_or("manual".to_string()); let metadata = GroupMetadata { diff --git a/rs/tests/system_tests.bzl b/rs/tests/system_tests.bzl index d37e6fe7c0c..395f6f225de 100644 --- a/rs/tests/system_tests.bzl +++ b/rs/tests/system_tests.bzl @@ -12,18 +12,6 @@ load("//rs/tests:common.bzl", "BOUNDARY_NODE_GUESTOS_RUNTIME_DEPS", "GUESTOS_DEV def _run_system_test(ctx): run_test_script_file = ctx.actions.declare_file(ctx.label.name + "/run-test.sh") - # trim the volatile status file to only the values that farm needs and that rarely - # ever change (on CI at least); otherwise, BUILD_TIMESTAMP changes on every new Bazel - # server start and effectively invalidates all system tests on every CI run. - farm_metadata = ctx.actions.declare_file(ctx.label.name + "/farm_metadata") - ctx.actions.run_shell( - # NOTE: grep shouldn't return 1 as long as the workspace status command at least - # prints USER (which ours does). - command = "grep <{version_file} -e CI_JOB_NAME -e USER > {farm_metadata}".format(version_file = ctx.version_file.path, farm_metadata = farm_metadata.path), - inputs = [ctx.version_file], - outputs = [farm_metadata], - ) - # whether to use k8s instead of farm k8s = ctx.attr._k8s[BuildSettingInfo].value @@ -83,7 +71,7 @@ def _run_system_test(ctx): env[key] = ctx.expand_location(value, ctx.attr.runtime_deps) env |= { - "FARM_METADATA_PATH": farm_metadata.short_path, + "FARM_METADATA_PATH": ctx.info_file.short_path, } # The test runner script expects a list of enviromment variable names to files: @@ -118,7 +106,7 @@ def _run_system_test(ctx): runfiles = ctx.runfiles( files = [ run_test_script_file, - farm_metadata, + ctx.info_file, ctx.executable.src, ctx.executable._upload_systest_dep, ],