diff --git a/enos/enos-scenario-e2e-ui-docker.hcl b/enos/enos-scenario-e2e-ui-docker.hcl index 7acc96c9f..67121e677 100644 --- a/enos/enos-scenario-e2e-ui-docker.hcl +++ b/enos/enos-scenario-e2e-ui-docker.hcl @@ -39,9 +39,10 @@ scenario "e2e_ui_docker" { module = matrix.builder == "crt" ? module.build_boundary_docker_crt : module.build_boundary_docker_local variables { - path = matrix.builder == "crt" ? local.boundary_docker_image_file : "" - cli_build_path = local.build_path[matrix.builder] - edition = var.boundary_edition + path = matrix.builder == "crt" ? local.boundary_docker_image_file : "" + cli_build_path = local.build_path[matrix.builder] + edition = var.boundary_edition + ui_build_override = var.ui_build_override } } diff --git a/enos/enos-variables.hcl b/enos/enos-variables.hcl index 9d8b7b1b8..e930af7ca 100644 --- a/enos/enos-variables.hcl +++ b/enos/enos-variables.hcl @@ -272,6 +272,12 @@ variable "windows_instance_type" { default = "m7i-flex.xlarge" } +variable "ui_build_override" { + description = "Override for build for UI automation" + type = string + default = null +} + variable "github_token" { description = "github token needed to run automated tests (requires read access to hashicorp repos)" type = string diff --git a/enos/modules/build_boundary_docker_local/build.sh b/enos/modules/build_boundary_docker_local/build.sh index d54f940e5..da6bf9f26 100644 --- a/enos/modules/build_boundary_docker_local/build.sh +++ b/enos/modules/build_boundary_docker_local/build.sh @@ -15,6 +15,7 @@ export DEV_DOCKER_GOARCH=$(uname -m) if [[ $DEV_DOCKER_GOARCH == "x86_64" ]]; then export DEV_DOCKER_GOARCH="amd64" fi +export UI_SRC_OVERRIDE="${UI_BUILD_OVERRIDE}" export IMAGE_TAG_DEV="${IMAGE_NAME}" make build-ui docker-build-dev diff --git a/enos/modules/build_boundary_docker_local/main.tf b/enos/modules/build_boundary_docker_local/main.tf index 6fffebdc9..126aa8714 100644 --- a/enos/modules/build_boundary_docker_local/main.tf +++ b/enos/modules/build_boundary_docker_local/main.tf @@ -24,6 +24,11 @@ variable "edition" { default = "oss" } +variable "ui_build_override" { + description = "Override for build for UI automation (oss or ent)" + default = null +} + resource "enos_local_exec" "get_git_sha" { inline = ["git rev-parse --short HEAD"] } @@ -34,9 +39,10 @@ locals { resource "enos_local_exec" "build_docker_image" { environment = { - "IMAGE_NAME" = local.image_name - "ARTIFACT_PATH" = var.cli_build_path - "EDITION" = var.edition + "IMAGE_NAME" = local.image_name + "ARTIFACT_PATH" = var.cli_build_path + "EDITION" = var.edition + "UI_BUILD_OVERRIDE" = var.ui_build_override } scripts = ["${path.module}/build.sh"] } diff --git a/enos/modules/build_local/main.tf b/enos/modules/build_local/main.tf index d8a09c80a..3b98c5180 100644 --- a/enos/modules/build_local/main.tf +++ b/enos/modules/build_local/main.tf @@ -33,16 +33,22 @@ variable "goos" { default = "linux" } +variable "ui_build_override" { + description = "Override for build for UI automation (oss or ent)" + default = null +} + resource "enos_local_exec" "build" { environment = { - "GOOS" = var.goos, - "GOARCH" = "amd64", - "CGO_ENABLED" = 0, - "ARTIFACT_PATH" = var.path - "ARTIFACT_NAME" = var.artifact_name - "BINARY_NAME" = var.binary_name - "BUILD_TARGET" = var.build_target - "EDITION" = var.edition + "GOOS" = var.goos, + "GOARCH" = "amd64", + "CGO_ENABLED" = 0, + "ARTIFACT_PATH" = var.path + "ARTIFACT_NAME" = var.artifact_name + "BINARY_NAME" = var.binary_name + "BUILD_TARGET" = var.build_target + "EDITION" = var.edition + "UI_BUILD_OVERRIDE" = var.ui_build_override } scripts = ["${path.module}/templates/build.sh"] } diff --git a/enos/modules/build_local/templates/build.sh b/enos/modules/build_local/templates/build.sh index cbac7032f..3d087afb1 100755 --- a/enos/modules/build_local/templates/build.sh +++ b/enos/modules/build_local/templates/build.sh @@ -13,6 +13,7 @@ npm install --global pnpm || true root_dir="$(git rev-parse --show-toplevel)" pushd "${root_dir}" > /dev/null +export UI_SRC_OVERRIDE="${UI_BUILD_OVERRIDE}" make ${BUILD_TARGET} zip -j ${ARTIFACT_PATH}/${ARTIFACT_NAME}.zip bin/${BINARY_NAME} diff --git a/scripts/build-ui.sh b/scripts/build-ui.sh index 89e6c03cc..be03219ca 100755 --- a/scripts/build-ui.sh +++ b/scripts/build-ui.sh @@ -14,8 +14,17 @@ if [ -z "$UI_VERSION_FILE" ]; then fi UI_EDITION=$(make --no-print-directory edition) +# allow override for the source of ui files +# used by end-to-end tests to build enterprise edition from community files +# UI_SRC_OVERRIDE will override which edition is pulled +# but UI_EDITION_SRC will still determine the build version +if [ -n "$UI_SRC_OVERRIDE" ]; then + UI_SRC=$UI_SRC_OVERRIDE +else + UI_SRC=$UI_EDITION +fi -if [ "$UI_EDITION" == "oss" ]; then +if [ $UI_SRC == "oss" ]; then UI_REPO=https://github.com/hashicorp/boundary-ui REPO_NAME=boundary-ui else @@ -37,12 +46,12 @@ if which gh &> /dev/null; then echo "Found gh cli, attempting to download ui assets" artifact_id=$(gh api "repos/hashicorp/${REPO_NAME}/actions/artifacts" --paginate | \ - jq ".artifacts[] | select(.workflow_run.head_sha == \"${UI_COMMITISH}f\" and .name == \"admin-ui-${UI_EDITION}\")" | \ + jq ".artifacts[] | select(.workflow_run.head_sha == \"${UI_COMMITISH}f\" and .name == \"admin-ui-${UI_SRC}\")" | \ jq --slurp '.[0]' | \ jq -r '.id') if [[ "${artifact_id}" != "null" ]]; then - echo "Downloading artifact: ${artifact_id} for admin-ui-${UI_EDITION} ${UI_COMMITISH}" + echo "Downloading artifact: ${artifact_id} for admin-ui-${UI_SRC} ${UI_COMMITISH}" tmp_dir=$(mktemp -d) gh api "repos/hashicorp/${REPO_NAME}/actions/artifacts/${artifact_id}/zip" > "${tmp_dir}/boundary-ui.zip" trap 'rm -rf ${tmp_dir}' EXIT @@ -54,7 +63,7 @@ if which gh &> /dev/null; then unzip "${tmp_dir}/boundary-ui.zip" -d "${UI_CLONE_DIR}/ui/admin/dist" exit $? else - echo "could not find artifact: admin-ui-${UI_EDITION} ${UI_COMMITISH}, falling back to git clone" + echo "could not find artifact: admin-ui-${UI_SRC} ${UI_COMMITISH}, falling back to git clone" fi fi