Skip to content

Commit

Permalink
chore(IDX): clean up status (#3942)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nmattia authored and marko-k0 committed Feb 14, 2025
1 parent e063a2a commit 58c0837
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
3 changes: 0 additions & 3 deletions bazel/ic_version_or_git_sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
;;
Expand Down
6 changes: 3 additions & 3 deletions bazel/workspace_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 4 additions & 6 deletions rs/tests/driver/src/driver/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,26 +448,24 @@ 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();
let runtime_args_map = parse_farm_metadata_file(farm_metadata);

// 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 {
Expand Down
16 changes: 2 additions & 14 deletions rs/tests/system_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
],
Expand Down

0 comments on commit 58c0837

Please sign in to comment.