From 052a331fb79f81a6d4a0f25c4addf925d345ccff Mon Sep 17 00:00:00 2001 From: Elior Erez Date: Thu, 30 Jul 2026 22:05:00 -0400 Subject: [PATCH] OSAC-1733: Scope component build context to its own subdirectory The "Build and load component images" step's podman build (and the OSAC-CLI go build and CRD-directory check next to it) used the whole component checkout as their working root, which is wrong for a monorepo caller: a components[] entry like {"containerfile": "fulfillment-service/Containerfile"} clones the entire osac-project/osac checkout, but the Containerfile, go.mod, cmd/, and config/crd/bases/ it needs all live under fulfillment-service/, not at the checkout root. Confirmed on real infra: osac PR #14's first real e2e run against the new components array failed both vmaas and caas with "building at STEP COPY go.mod go.sum ...: no such file or directory" -- podman was building with the whole monorepo checkout as context instead of the component's own subdirectory. Fixed by deriving a build_dir from the containerfile's directory (same scoping already used in replace-installer-submodule.sh) and using it for the podman build context/file, the go build cwd, and the CRD directory check. Standalone (non-monorepo) callers are unaffected, since build_dir falls back to the checkout root when containerfile has no directory component. --- .github/workflows/e2e-bmaas-full-install.yml | 25 +++++++++++++++----- .github/workflows/e2e-caas-full-install.yml | 20 ++++++++++++---- .github/workflows/e2e-vmaas-full-install.yml | 25 +++++++++++++++----- 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.github/workflows/e2e-bmaas-full-install.yml b/.github/workflows/e2e-bmaas-full-install.yml index babb15eb7..d0716367e 100644 --- a/.github/workflows/e2e-bmaas-full-install.yml +++ b/.github/workflows/e2e-bmaas-full-install.yml @@ -360,19 +360,32 @@ jobs: echo "::group::Build component[$i]: ${repo}@${ref} (${file})" git clone --depth 1 --branch "${ref}" "https://github.com/${repo}.git" "${src}" + # When `file` has a directory component (e.g. + # "fulfillment-service/Containerfile" from a monorepo checkout), + # everything about this component -- build context, go.mod, + # cmd/, CRDs -- lives under that subdirectory, not at the + # checkout root. Mirrors the same scoping in + # replace-installer-submodule.sh. + build_dir="${src}" + containerfile_name="${file}" + if [[ "${file}" == */* ]]; then + build_dir="${src}/$(dirname "${file}")" + containerfile_name="$(basename "${file}")" + fi + if [[ "${build_type}" == "ansible-builder" ]]; then python3 -m pip install --quiet 'ansible-builder~=3.0' - ansible-builder create --file "${src}/${file}" --context "${src}/context" - podman build -t "${tag}" -f "${src}/context/Containerfile" "${src}/context" + ansible-builder create --file "${build_dir}/${containerfile_name}" --context "${build_dir}/context" + podman build -t "${tag}" -f "${build_dir}/context/Containerfile" "${build_dir}/context" else - podman build -t "${tag}" -f "${src}/${file}" "${src}" + podman build -t "${tag}" -f "${build_dir}/${containerfile_name}" "${build_dir}" fi # Build OSAC CLI from source when this component is fulfillment-service. # Keyed off imageKey (not a repo-name substring), so this works whether # repo is fulfillment-service's own repo or a monorepo like osac-project/osac. if [[ "${image_key}" == "service.images.service" ]]; then - (cd "${src}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) + (cd "${build_dir}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) echo "OSAC_CLI_BIN=$RUNNER_TEMP/osac-cli-bin" >> "$GITHUB_ENV" fi @@ -380,10 +393,10 @@ jobs: # OSAC install. Without this, CRDs come from osac-installer's # submodule pin and miss any CRD changes in the PR. crds_dir="" - if [[ -d "${src}/config/crd/bases" ]]; then + if [[ -d "${build_dir}/config/crd/bases" ]]; then crds_dir="$RUNNER_TEMP/component-${i}-crds" mkdir -p "${crds_dir}" - cp "${src}"/config/crd/bases/*.yaml "${crds_dir}/" + cp "${build_dir}"/config/crd/bases/*.yaml "${crds_dir}/" fi echo "Loading image onto node ${NODE_NAME}..." diff --git a/.github/workflows/e2e-caas-full-install.yml b/.github/workflows/e2e-caas-full-install.yml index 50bd37f6d..a00ccde63 100644 --- a/.github/workflows/e2e-caas-full-install.yml +++ b/.github/workflows/e2e-caas-full-install.yml @@ -364,19 +364,31 @@ jobs: echo "::group::Build component[$i]: ${repo}@${ref} (${file})" git clone --depth 1 --branch "${ref}" "https://github.com/${repo}.git" "${src}" + # When `file` has a directory component (e.g. + # "fulfillment-service/Containerfile" from a monorepo checkout), + # everything about this component -- build context, go.mod, + # cmd/ -- lives under that subdirectory, not at the checkout + # root. Mirrors the same scoping in replace-installer-submodule.sh. + build_dir="${src}" + containerfile_name="${file}" + if [[ "${file}" == */* ]]; then + build_dir="${src}/$(dirname "${file}")" + containerfile_name="$(basename "${file}")" + fi + if [[ "${build_type}" == "ansible-builder" ]]; then python3 -m pip install --quiet 'ansible-builder~=3.0' - ansible-builder create --file "${src}/${file}" --context "${src}/context" - podman build -t "${tag}" -f "${src}/context/Containerfile" "${src}/context" + ansible-builder create --file "${build_dir}/${containerfile_name}" --context "${build_dir}/context" + podman build -t "${tag}" -f "${build_dir}/context/Containerfile" "${build_dir}/context" else - podman build -t "${tag}" -f "${src}/${file}" "${src}" + podman build -t "${tag}" -f "${build_dir}/${containerfile_name}" "${build_dir}" fi # Build OSAC CLI from source when this component is fulfillment-service. # Keyed off imageKey (not a repo-name substring), so this works whether # repo is fulfillment-service's own repo or a monorepo like osac-project/osac. if [[ "${image_key}" == "service.images.service" ]]; then - (cd "${src}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) + (cd "${build_dir}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) echo "OSAC_CLI_BIN=$RUNNER_TEMP/osac-cli-bin" >> "$GITHUB_ENV" fi diff --git a/.github/workflows/e2e-vmaas-full-install.yml b/.github/workflows/e2e-vmaas-full-install.yml index d4e501226..0373f2405 100644 --- a/.github/workflows/e2e-vmaas-full-install.yml +++ b/.github/workflows/e2e-vmaas-full-install.yml @@ -378,19 +378,32 @@ jobs: echo "::group::Build component[$i]: ${repo}@${ref} (${file})" git clone --depth 1 --branch "${ref}" "https://github.com/${repo}.git" "${src}" + # When `file` has a directory component (e.g. + # "fulfillment-service/Containerfile" from a monorepo checkout), + # everything about this component -- build context, go.mod, + # cmd/, CRDs -- lives under that subdirectory, not at the + # checkout root. Mirrors the same scoping in + # replace-installer-submodule.sh. + build_dir="${src}" + containerfile_name="${file}" + if [[ "${file}" == */* ]]; then + build_dir="${src}/$(dirname "${file}")" + containerfile_name="$(basename "${file}")" + fi + if [[ "${build_type}" == "ansible-builder" ]]; then python3 -m pip install --quiet 'ansible-builder~=3.0' - ansible-builder create --file "${src}/${file}" --context "${src}/context" - podman build -t "${tag}" -f "${src}/context/Containerfile" "${src}/context" + ansible-builder create --file "${build_dir}/${containerfile_name}" --context "${build_dir}/context" + podman build -t "${tag}" -f "${build_dir}/context/Containerfile" "${build_dir}/context" else - podman build -t "${tag}" -f "${src}/${file}" "${src}" + podman build -t "${tag}" -f "${build_dir}/${containerfile_name}" "${build_dir}" fi # Build OSAC CLI from source when this component is fulfillment-service. # Keyed off imageKey (not a repo-name substring), so this works whether # repo is fulfillment-service's own repo or a monorepo like osac-project/osac. if [[ "${image_key}" == "service.images.service" ]]; then - (cd "${src}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) + (cd "${build_dir}" && CGO_ENABLED=0 go build -o "$RUNNER_TEMP/osac-cli-bin" ./cmd/osac) echo "OSAC_CLI_BIN=$RUNNER_TEMP/osac-cli-bin" >> "$GITHUB_ENV" fi @@ -398,10 +411,10 @@ jobs: # OSAC install. Without this, CRDs come from osac-installer's # submodule pin and miss any CRD changes in the PR. crds_dir="" - if [[ -d "${src}/config/crd/bases" ]]; then + if [[ -d "${build_dir}/config/crd/bases" ]]; then crds_dir="$RUNNER_TEMP/component-${i}-crds" mkdir -p "${crds_dir}" - cp "${src}"/config/crd/bases/*.yaml "${crds_dir}/" + cp "${build_dir}"/config/crd/bases/*.yaml "${crds_dir}/" fi echo "Loading image onto node ${NODE_NAME}..."