Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions test/bin/brew_test_alignment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/bin/bash
#
# Aligns test code (test/suites/, test/resources/) with the brew RPM
# source commit so that release CI jobs do not run HEAD tests against
# older brew-built binaries.
#
# Must be sourced, not executed directly.

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "This script must be sourced, not executed."
exit 1
fi

MAX_BREW_SKEW="${MAX_BREW_SKEW:-100}"

BREW_SOURCE_COMMIT="${BREW_SOURCE_COMMIT:-}"
BREW_SOURCE_SHORTCOMMIT="${BREW_SOURCE_SHORTCOMMIT:-}"
BREW_TEST_ALIGNED="${BREW_TEST_ALIGNED:-false}"
BREW_COMMIT_DELTA="${BREW_COMMIT_DELTA:-0}"
Comment on lines +1 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Maintainability & Code Quality | 🟑 Minor | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

printf 'File present and first few lines:\n'
if [ -f test/bin/brew_test_alignment.sh ]; then
  sed -n '1,35p' test/bin/brew_test_alignment.sh | cat -n
else
  printf 'MISSING\n'
fi

printf '\nShellcheck availability and status for file:\n'
if command -v shellcheck >/dev/null 2>&1; then
  shellcheck --severity=error test/bin/brew_test_alignment.sh || true
else
  printf 'shellcheck not available\n'
fi

Repository: openshift/microshift

Length of output: 1593


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

if command -v shellcheck >/dev/ null 2>&1; then
  shellcheck test/bin/brew_test_alignment.sh || true
else
  printf 'shellcheck not available\n'
fi

Repository: openshift/microshift

Length of output: 219


Use the approved shell scripting template.

test/bin/brew_test_alignment.sh starts with #!/bin/bash and does not enable set -euo pipefail; use #!/usr/bin/bash and the required strict shell options for shell script files.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bin/brew_test_alignment.sh` around lines 1 - 19, Update the header of
the brew test alignment script to use the approved /usr/bin/bash interpreter and
enable the required strict shell options, including errexit, nounset, and
pipefail. Preserve the existing sourced-only guard and variable initialization
in brew_test_alignment.sh.

Source: Coding guidelines


# Extract the source commit SHA from the brew LREL RPM's release field.
# The NVR release field format is:
# YYYYMMDDHHMMSS.p0.g<shortcommit>.assembly.<stream>.el<N>
# Sets BREW_SOURCE_COMMIT (full SHA) and BREW_SOURCE_SHORTCOMMIT.
get_brew_source_commit() {
local -r vrel="${BREW_LREL_RELEASE_VERSION:-}"
if [[ -z "${vrel}" ]]; then
return 0
fi

local -r release_field="${vrel#*-}"

local shortcommit=""
if [[ "${release_field}" =~ \.g([0-9a-f]{7,})\. ]]; then
shortcommit="${BASH_REMATCH[1]}"
fi

if [[ -z "${shortcommit}" ]]; then
echo "ERROR: Cannot parse git shortcommit from brew release field: ${release_field}"
return 1
fi

BREW_SOURCE_SHORTCOMMIT="${shortcommit}"
export BREW_SOURCE_SHORTCOMMIT

local full_sha=""
if full_sha=$(git rev-parse "${shortcommit}^{commit}" 2>/dev/null); then
BREW_SOURCE_COMMIT="${full_sha}"
else
BREW_SOURCE_COMMIT="${shortcommit}"
fi
export BREW_SOURCE_COMMIT
}

# Fetch the brew source commit if it is not available in the local
# git history. CI environments may use shallow clones.
fetch_brew_commit_if_needed() {
local -r commit="$1"

if git cat-file -e "${commit}^{commit}" 2>/dev/null; then
return 0
fi

echo "Brew source commit ${commit} not found locally, fetching..."

if git fetch origin "${commit}" 2>/dev/null; then
if git cat-file -e "${commit}^{commit}" 2>/dev/null; then
return 0
fi
fi

if git rev-parse --is-shallow-repository 2>/dev/null | grep -q true; then
echo "Shallow repository detected, unshallowing..."
if git fetch --unshallow origin 2>/dev/null; then
if git cat-file -e "${commit}^{commit}" 2>/dev/null; then
return 0
fi
fi
fi

echo "ERROR: Cannot fetch brew source commit ${commit}"
return 1
}

# Check out test/suites/ and test/resources/ at the brew source commit.
# Uses git checkout <sha> -- <paths>, which modifies the working tree
# without changing HEAD.
#
# Globals read:
# BREW_SOURCE_COMMIT - full SHA from get_brew_source_commit()
# ROOTDIR - repository root (from common.sh)
# MAX_BREW_SKEW - maximum allowed commit delta
#
# Globals set:
# BREW_TEST_ALIGNED - "true" if checkout was performed
# BREW_COMMIT_DELTA - integer commit count between brew SHA and HEAD
checkout_brew_aligned_tests() {
BREW_TEST_ALIGNED="false"
BREW_COMMIT_DELTA=0

local -r brew_sha="${BREW_SOURCE_COMMIT:-}"
if [[ -z "${brew_sha}" ]]; then
echo "BREW_SOURCE_COMMIT is not set, skipping test alignment"
return 0
fi

local -r head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟑 Minor | ⚑ Quick win

Declare/assign separately to avoid masking git rev-parse failures.

local -r head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)" masks the command substitution's exit status behind local's own (shellcheck SC2155). Without set -e, a failing rev-parse here silently yields an empty head_sha and the function proceeds with bogus comparisons/delta math.

As per coding guidelines, "Shell scripts must pass shellcheck."

🩹 Proposed fix
-    local -r head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)"
+    local head_sha
+    if ! head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)"; then
+        echo "ERROR: Cannot resolve HEAD commit"
+        return 1
+    fi
+    readonly head_sha
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
local -r head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)"
local head_sha
if ! head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD)"; then
echo "ERROR: Cannot resolve HEAD commit"
return 1
fi
readonly head_sha
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bin/brew_test_alignment.sh` at line 107, Update the head_sha declaration
in the relevant shell function to declare the readonly local variable
separately, then assign it from git rev-parse in a distinct command so its
failure status is preserved and handled according to the existing shell error
flow.

Source: Coding guidelines

if [[ "${brew_sha}" == "${head_sha}" ]]; then
echo "Brew source commit matches HEAD, no alignment needed"
BREW_TEST_ALIGNED="true"
BREW_COMMIT_DELTA=0
export BREW_TEST_ALIGNED BREW_COMMIT_DELTA
return 0
fi

if ! fetch_brew_commit_if_needed "${brew_sha}"; then
echo "ERROR: Cannot proceed with test alignment"
return 1
fi

local delta
if delta=$(git -C "${ROOTDIR}" rev-list --count "${brew_sha}..${head_sha}" 2>/dev/null); then
BREW_COMMIT_DELTA="${delta}"
else
echo "WARNING: Cannot compute commit delta (commits not on same lineage)"
BREW_COMMIT_DELTA=-1
fi
export BREW_COMMIT_DELTA

echo "Brew source commit: ${brew_sha}"
echo "HEAD commit: ${head_sha}"
echo "Commit delta: ${BREW_COMMIT_DELTA}"

if [[ "${BREW_COMMIT_DELTA}" -ne -1 ]] && [[ "${BREW_COMMIT_DELTA}" -gt "${MAX_BREW_SKEW}" ]]; then
echo "ERROR: Commit delta ${BREW_COMMIT_DELTA} exceeds MAX_BREW_SKEW=${MAX_BREW_SKEW}"
return 1
fi

echo "Checking out test/suites/ and test/resources/ at brew commit ${brew_sha}"
if ! git -C "${ROOTDIR}" checkout "${brew_sha}" -- test/suites/ test/resources/ 2>&1; then
echo "ERROR: Failed to checkout test directories at ${brew_sha}"
return 1
fi

BREW_TEST_ALIGNED="true"
export BREW_TEST_ALIGNED

echo "Test code aligned to brew source commit ${brew_sha}"
return 0
}

# Restore test directories to HEAD after tests complete.
restore_head_tests() {
if [[ "${BREW_TEST_ALIGNED:-false}" == "true" ]]; then
echo "Restoring test/suites/ and test/resources/ to HEAD"
git -C "${ROOTDIR}" checkout HEAD -- test/suites/ test/resources/ 2>/dev/null || true
fi
}
Comment on lines +97 to +158

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | πŸ”΄ Critical | πŸ—οΈ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg '(^|/)brew_test_alignment\.sh$|(^|/)test/(suites|resources)/' | head -80

echo
echo "Target section:"
if [ -f test/bin/brew_test_alignment.sh ]; then
  nl -ba test/bin/brew_test_alignment.sh | sed -n '1,190p'
fi

echo
echo "Search tests for BREW_TEST_ALIGNED / BREW_COMMIT_DELTA:"
rg -n "BREW_TEST_ALIGNED|BREW_COMMIT_DELTA|MAX_BREW_SKEW|checkout_brew_aligned_tests|restore_head_tests|BREW_SOURCE_COMMIT" .

Repository: openshift/microshift

Length of output: 3369


🌐 Web query:

git checkout documentation overlay mode never removes files from index or working tree

πŸ’‘ Result:

In Git, "overlay mode" is a behavior where the command being executed does not remove files from the index or the working tree if they are absent in the source (e.g., the commit or tree-ish being checked out) [1][2]. Specifically regarding git checkout: - When using git checkout to restore paths, it operates in a default overlay mode [1][3]. - In this overlay mode, git checkout will update existing files in the index and working tree to match the specified source, but it will never remove files that are already present in your index or working tree if those files do not exist in the source [1][4]. - While the git checkout documentation mentions --overlay and --no-overlay flags, these are primarily discussed in the context of their implementation or related commands; historically, git checkout has maintained this non-destructive "overlay" behavior as its default [1][2]. This behavior contrasts with the newer command, git restore, which was introduced to separate and clarify the complex responsibilities of git checkout [5]. By default, git restore operates in "no-overlay" mode, meaning it will remove tracked files from the working tree or index if they do not exist in the source [6][7]. Users can pass the --overlay flag to git restore to mimic the traditional, non-destructive behavior of git checkout [8][6].

Citations:


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

echo "Target section:"
if command -v nl >/dev/null; then
  nl -ba test/bin/brew_test_alignment.sh | sed -n '1,190p'
else
  cat -n test/bin/brew_test_alignment.sh | sed -n '1,190p'
fi

echo
echo "Search tests for BREW_TEST_ALIGNED / BREW_COMMIT_DELTA:"
rg -n "BREW_TEST_ALIGNED|BREW_COMMIT_DELTA|MAX_BREW_SKEW|checkout_brew_aligned_tests|restore_head_tests|BREW_SOURCE_COMMIT" . || true

echo
echo "Behavior probe for checkout-path semantics:"
cd /tmp
rm -rf repo-shape-probe
mkdir repo-shape-probe
cd repo-shape-probe

export GIT_AUTHOR_NAME="Test" GIT_AUTHOR_EMAIL="test@test.test" GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="test@test.test"
git init -q
echo "old" > test/suites/x.robot
git add test/suites/x.robot
git commit -q -m "base"
OLD="$(git rev-parse HEAD)"
mkdir -p newdir
echo "extra" > test/suites/newdir/y.robot
echo "old" > test/suites/x.robot
echo "old" > test/resources/z.res
git add test/suites/newdir/y.robot test/suites/x.robot test/resources/z.res
git rm -q test/suites/x.robot
git commit -q -m "late"
HEAD="$(git rev-parse HEAD)"

echo "Before OLD checkout:"
find test -type f | sort
git -C "$PWD" checkout "$OLD" -- test/suites/ test/resources/ 2>&1 || true
echo "After OLD checkout:"
find test -type f | sort
git -C "$PWD" status --short

echo
git -C "$PWD" checkout "$HEAD" -- test/suites/ test/resources/ 2>&1 || true
echo "After restore HEAD checkout:"
find test -type f | sort
git -C "$PWD" status --short

Repository: openshift/microshift

Length of output: 11234


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

echo "Behavior probe in temp repo:"
cd /tmp
rm -rf repo-shape-probe
mkdir -p repo-shape-probe
pushd repo-shape-probe >/dev/null

export GIT_AUTHOR_NAME="Test" GIT_AUTHOR_EMAIL="test@test.test" \
  GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="test@test.test"
git init -q

mkdir -p test/suites test/resources
printf 'old\n' > test/suites/x.robot
git add test/suites/x.robot
git commit -q -m 'base'
OLD="$(git rev-parse HEAD)"

mkdir -p test/suites/newdir
printf 'extra\n' > test/suites/newdir/y.robot
printf 'old\n' > test/suites/x.robot
printf 'old\n' > test/resources/z.res
git add test/suites/newdir/y.robot test/suites/x.robot test/resources/z.res
git rm -q test/suites/x.robot
git commit -q -m 'late'
HEAD="$(git rev-parse HEAD)"

echo '--- before checkout ---'
find test -type f | sort

printf '--- checkout OLD ---\n'
git checkout "$OLD" -- test/suites/ test/resources/

echo '--- after checkout ---'
find test -type f | sort
git status --short

printf '--- checkout HEAD ---\n'
git checkout "$HEAD" -- test/suites/ test/resources/

echo '--- after restore ---'
find test -type f | sort
git status --short

popd >/dev/null

Repository: openshift/microshift

Length of output: 351


🌐 Web query:

git checkout pathspec diff-filter=A does not filter deleted files documentation

πŸ’‘ Result:

The git checkout command does not support the --diff-filter option [1][2][3]. The --diff-filter option is a feature of git diff and other similar commands used for comparing revisions, but it is not available in git checkout [4][5]. To achieve the desired resultβ€”such as checking out files that have been deleted or modified in another branchβ€”you must first use git diff to identify the files and then pass those file paths to git checkout [6][7]. A common and recommended approach is to use xargs to pipe the output of git diff into git checkout: git diff --diff-filter=A --name-only -z | xargs -0 git checkout -- In this command: 1. git diff --diff-filter=A --name-only -z identifies files that have been added (or otherwise match the filter) in the specified commit or branch and lists them as null-terminated strings (-z) [4][5][7]. 2. xargs -0 processes these null-terminated file names and passes them as arguments to the git checkout command [7]. 3. git checkout -- restores the specified files from the source branch to your current working directory [1][6]. Using the -z and -0 flags is best practice to correctly handle file names that contain spaces or special characters [7].

Citations:


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

echo "Behavior probe in temp repo:"
cd /tmp
rm -rf repo-shape-probe
mkdir -p repo-shape-probe
pushd repo-shape-probe >/dev/null

export GIT_AUTHOR_NAME="Test" GIT_AUTHOR_EMAIL="test@test.test" \
  GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="test@test.test"
git init -q

mkdir -p test/suites test/resources
printf '%s\n' old > test/suites/x.robot
git add test/suites/x.robot
git commit -q -m 'base'
OLD="$(git rev-parse HEAD)"

mkdir -p test/suites/newdir
printf '%s\n' extra > test/suites/newdir/y.robot
printf '%s\n' old > test/suites/x.robot
printf '%s\n' old > test/resources/z.res
git add test/suites/newdir/y.robot test/suites/x.robot test/resources/z.res
git rm -q test/suites/x.robot
git commit -q -m 'late'
HEAD="$(git rev-parse HEAD)"

printf '%s\n' '--- before checkout ---'
find test -type f | sort

printf '%s\n' '--- checkout OLD ---'
git checkout "$OLD" -- test/suites/ test/resources/

printf '%s\n' '--- after checkout ---'
find test -type f | sort
git status --short

printf '%s\n' '--- checkout HEAD ---'
git checkout "$HEAD" -- test/suites/ test/resources/

printf '%s\n' '--- after restore ---'
find test -type f | sort
git status --short

printf '%s\n' '--- diff added/deleted between ---'
git diff --name-status --diff-filter=AD "$OLD"..."$HEAD" -- test/suites/ test/resources/

popd >/dev/null

Repository: openshift/microshift

Length of output: 353


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

echo "Behavior probe in temp repo:"
cd /tmp
rm -rf repo-shape-probe
mkdir -p repo-shape-probe
pushd repo-shape-probe >/dev/null

export GIT_AUTHOR_NAME="Test" GIT_AUTHOR_EMAIL="test@test.test" \
  GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="test@test.test"
git init -q

mkdir -p test/suites test/resources
printf '%s\n' old > test/suites/x.robot
printf '%s\n' base > test/resources/a.res
git add test
git commit -q -m 'base'
OLD="$(git rev-parse HEAD)"

mkdir -p test/suites/newdir
printf '%s\n' extra > test/suites/newdir/y.robot
printf '%s\n' old > test/suites/x.robot
printf '%s\n' removed > test/resources/removed.res
git add test/suites/newdir/y.robot test/suites/x.robot test/resources/removed.res
git rm -q test/suites/x.robot test/resources/removed.res
git commit -q -m 'late'
HEAD="$(git rev-parse HEAD)"

printf '%s\n' '--- before checkout ---'
find test -type f | sort

printf '%s\n' '--- checkout OLD ---'
git checkout "$OLD" -- test/suites test/resources

printf '%s\n' '--- after checkout ---'
find test -type f | sort
git status --short

printf '%s\n' '--- checkout HEAD ---'
git checkout "$HEAD" -- test/suites test/resources

printf '%s\n' '--- after restore ---'
find test -type f | sort
git status --short

printf '%s\n' '--- diff added/deleted between ---'
git diff --name-status --diff-filter=AD "$OLD"..."$HEAD" -- test/suites test/resources

popd >/dev/null

Repository: openshift/microshift

Length of output: 333


Align and restore by reconciling added and deleted paths.

git checkout <sha> -- test/suites test/resources uses overlay mode, so it won’t remove files added after brew_sha and won’t delete files removed after brew_sha; the restore checkout can leave those leftovers in the working tree. Use a diff-based cleanup or scoped tree export/delete logic for both alignment and HEAD restore.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bin/brew_test_alignment.sh` around lines 97 - 158, Update
checkout_brew_aligned_tests and restore_head_tests to reconcile the scoped test
directories rather than using overlay git checkout alone: remove paths absent
from the target commit and restore paths present there, for both brew_sha
alignment and HEAD restoration. Keep all operations limited to test/suites/ and
test/resources/, and preserve the existing success, failure, and alignment-state
behavior.


# Write a JSON sidecar artifact with brew alignment metadata.
# Each scenario invocation writes its own copy for per-scenario audit.
emit_brew_alignment_artifact() {
local -r artifact_dir="${SCENARIO_INFO_DIR}/${SCENARIO}"
mkdir -p "${artifact_dir}"

local -r brew_sha="${BREW_SOURCE_COMMIT:-unset}"
local -r head_sha="$(git -C "${ROOTDIR}" rev-parse HEAD 2>/dev/null || echo 'unknown')"
local -r delta="${BREW_COMMIT_DELTA:-0}"
local -r aligned="${BREW_TEST_ALIGNED:-false}"

local coverage_delta="[]"
if [[ "${brew_sha}" != "unset" ]] && [[ "${brew_sha}" != "${head_sha}" ]]; then
local added_files
added_files=$(git -C "${ROOTDIR}" diff --name-only --diff-filter=A \
"${brew_sha}..HEAD" -- test/suites/ test/resources/ 2>/dev/null || true)
if [[ -n "${added_files}" ]]; then
coverage_delta=$(echo "${added_files}" | jq -R -s 'split("\n") | map(select(length > 0))')
fi
fi

cat > "${artifact_dir}/brew-alignment.json" <<EOF
{
"brew_source_commit": "${brew_sha}",
"head_commit": "${head_sha}",
"commit_delta": ${delta},
"test_aligned": ${aligned},
"max_brew_skew": ${MAX_BREW_SKEW},
"coverage_delta": ${coverage_delta}
}
EOF

echo "Wrote brew alignment artifact to ${artifact_dir}/brew-alignment.json"
}
14 changes: 14 additions & 0 deletions test/bin/ci_phase_boot_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export PS4='+ $(date "+%T.%N") ${BASH_SOURCE#$HOME/}:$LINENO \011'
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck source=test/bin/common.sh
source "${SCRIPTDIR}/common.sh"
# shellcheck source=test/bin/brew_test_alignment.sh
source "${SCRIPTDIR}/brew_test_alignment.sh"
# Directory to crawl for scenarios when creating/running in batch mode.
# The CI system will override this depending on the job its running.
SCENARIO_SOURCES="${SCENARIO_SOURCES:-${TESTDIR}/scenarios}"
Expand Down Expand Up @@ -63,6 +65,18 @@ fi
# where all the relevant scenarios will be copied for execution
prepare_scenario_sources

# For release jobs, align test suites/resources with the brew RPM source
# commit to avoid false failures from HEAD tests against older brew RPMs.
if [[ "${SCENARIO_SOURCES:-}" =~ .*releases.* ]]; then
# shellcheck source=test/bin/common_versions.sh
source "${SCRIPTDIR}/common_versions.sh"
get_brew_source_commit
if [[ -n "${BREW_SOURCE_COMMIT:-}" ]]; then
checkout_brew_aligned_tests || exit 1
trap 'restore_head_tests' EXIT
fi
fi

BOOT_TEST_JOB_LOG="${IMAGEDIR}/boot_test_jobs.txt"

cd "${TESTDIR}"
Expand Down
6 changes: 6 additions & 0 deletions test/bin/scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPTDIR}/common.sh"
# shellcheck source=test/bin/common_versions.sh
source "${SCRIPTDIR}/common_versions.sh"
# shellcheck source=test/bin/brew_test_alignment.sh
source "${SCRIPTDIR}/brew_test_alignment.sh"

LVM_SYSROOT_SIZE="15360"
PULL_SECRET="${PULL_SECRET:-${HOME}/.pull-secret.json}"
Expand Down Expand Up @@ -1849,6 +1851,10 @@ action_run() {
start_junit
trap "close_junit" EXIT

if [[ "${BREW_TEST_ALIGNED:-false}" == "true" ]]; then
emit_brew_alignment_artifact
fi

Comment on lines +1854 to +1857

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "SCENARIO_INFO_DIR=|^SCENARIO=" test/bin/scenario.sh
rg -n "load_global_settings\(\)|load_scenario_script\(\)" -A5 test/bin/scenario.sh

Repository: openshift/microshift

Length of output: 580


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

printf '--- scenario.sh action context ---\n'
sed -n '1820,1870p' test/bin/scenario.sh

printf '\n--- brew_test_alignment usages/definitions ---\n'
fd -a 'brew_test_alignment.sh|scenario.sh' . | sed 's#^\./##' | xargs -r -n1 sh -c '
  echo "== $0 =="
  rg -n "emit_brew_alignment_artifact|SCENARIO_INFO_DIR|SCENARIO_SCRIPT=|SCENARIO=" "$0"
'

printf '\n--- load/load_global/load_scenario sections ---\n'
sed -n '1700,1785p' test/bin/scenario.sh

Repository: openshift/microshift

Length of output: 249


🏁 Script executed:

#!/usr/bin/bash
set -euo pipefail

printf '%s\n' '--- scenario.sh action context ---'
sed -n '1820,1870p' test/bin/scenario.sh

printf '%s\n' ''
printf '%s\n' '--- brew_test_alignment usages/definitions ---'
file_re='^test/bin/(scenario\.sh|brew_test_alignment\.sh)$'
if [ -f test/bin/scenario.sh ]; then
  rg -n "emit_brew_alignment_artifact|SCENARIO_INFO_DIR|SCENARIO_SCRIPT=|SCENARIO=" test/bin/scenario.sh
fi
if [ -f test/bin/scenario.sh.bash ]; then
  rg -n "emit_brew_alignment_artifact|SCENARIO_INFO_DIR|SCENARIO_SCRIPT=|SCENARIO=" test/bin/scenario.sh.bash
fi
if [ -f test/bin/brew_test_alignment.sh ]; then
  rg -n "emit_brew_alignment_artifact|SCENARIO_INFO_DIR|SCENARIO_SCRIPT=|SCENARIO=" test/bin/brew_test_alignment.sh
fi

printf '%s\n' ''
printf '%s\n' '--- load sections ---'
sed -n '1700,1785p' test/bin/scenario.sh

Repository: openshift/microshift

Length of output: 5470


Initialize SCENARIO_INFO_DIR before emitting the Brew artifact.

emit_brew_alignment_artifact writes to ${SCENARIO_INFO_DIR}/${SCENARIO}, but in action_run the artifact is emitted before that path is established via ${SCENARIO_SCRIPT}/load_scenario_script. Set the required scenario directory from $1 before this call, or move the call after load_scenario_script.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bin/scenario.sh` around lines 1854 - 1857, Update action_run around
emit_brew_alignment_artifact so SCENARIO_INFO_DIR is initialized for the current
scenario before the artifact is emitted. Set it from $1 before the call, or move
the call until after SCENARIO_SCRIPT/load_scenario_script establishes the
directory, while preserving the existing BREW_TEST_ALIGNED guard.

if ! load_global_settings; then
record_junit "run" "load_global_settings" "FAILED"
return 1
Expand Down