Skip to content

Add deploy changes#90

Draft
mikeeq wants to merge 3 commits intomainfrom
feature/hote-710/mock-fargate
Draft

Add deploy changes#90
mikeeq wants to merge 3 commits intomainfrom
feature/hote-710/mock-fargate

Conversation

@mikeeq
Copy link
Copy Markdown
Collaborator

@mikeeq mikeeq commented Apr 1, 2026

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copilot AI review requested due to automatic review settings April 1, 2026 08:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the hometest-app Terragrunt deployment flow to optionally bake WireMock-related authentication configuration into the SPA build, and disables WireMock for the UAT environment.

Changes:

  • Extend scripts/build-spa.sh to accept WireMock-related build-time environment variables and reflect them in cache hashing / build output.
  • Update poc/hometest-app/app.hcl Terragrunt before_hook to pass WireMock settings into the SPA build step.
  • Set enable_wiremock = false for the poc/hometest-app/uat environment.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
scripts/build-spa.sh Adds WireMock env var handling to the SPA build and updates the build cache inputs.
infrastructure/environments/poc/hometest-app/app.hcl Passes WireMock config into the SPA build hook and derives enablement from the child config.
infrastructure/environments/poc/hometest-app/uat/terragrunt.hcl Disables WireMock in UAT via enable_wiremock = false.

Comment thread scripts/build-spa.sh
all_hashes+="BACKEND_URL:${BACKEND_URL}|"

# Include wiremock config in hash — toggling wiremock changes build-time env vars
all_hashes+="ENABLE_WIREMOCK:${ENABLE_WIREMOCK}|"
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The SPA build cache hash includes ENABLE_WIREMOCK but not WIREMOCK_BASE_URL, even though the built output changes when NHS_LOGIN_AUTHORIZE_URL (derived from the base URL) changes. This can cause Terragrunt to skip rebuilds when the WireMock URL changes. Include WIREMOCK_BASE_URL (or the full computed NHS_LOGIN_AUTHORIZE_URL) in calculate_source_hash().

Suggested change
all_hashes+="ENABLE_WIREMOCK:${ENABLE_WIREMOCK}|"
all_hashes+="ENABLE_WIREMOCK:${ENABLE_WIREMOCK}|"
all_hashes+="WIREMOCK_BASE_URL:${WIREMOCK_BASE_URL}|"

Copilot uses AI. Check for mistakes.
Comment thread scripts/build-spa.sh
Comment on lines +287 to +293
# When wiremock is enabled, bake auth-related env vars into the SPA build
if [[ "$ENABLE_WIREMOCK" == "true" ]]; then
export USE_WIREMOCK_AUTH="true"
export NHS_LOGIN_AUTHORIZE_URL="${WIREMOCK_BASE_URL}/authorize"
echo " USE_WIREMOCK_AUTH=$USE_WIREMOCK_AUTH"
echo " NHS_LOGIN_AUTHORIZE_URL=$NHS_LOGIN_AUTHORIZE_URL"
fi
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

When ENABLE_WIREMOCK is true, the script constructs NHS_LOGIN_AUTHORIZE_URL from WIREMOCK_BASE_URL but doesn't validate that WIREMOCK_BASE_URL is set/non-empty. This can silently bake an invalid '/authorize' URL into the build. Add a guard that errors out (or defaults safely) when wiremock is enabled but WIREMOCK_BASE_URL is missing.

Copilot uses AI. Check for mistakes.
Comment thread scripts/build-spa.sh
Comment on lines +32 to +35
# WireMock configuration (set via environment variables by Terragrunt hook)
ENABLE_WIREMOCK="${ENABLE_WIREMOCK:-false}"
WIREMOCK_BASE_URL="${WIREMOCK_BASE_URL:-}"

Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

These new environment variables are required to control WireMock build-time behavior, but the script's usage/help text only documents FORCE_SPA_REBUILD. Please update the usage output to include ENABLE_WIREMOCK and WIREMOCK_BASE_URL so running the script outside Terragrunt is self-explanatory.

Copilot uses AI. Check for mistakes.

# WireMock build configuration — controls SPA build-time env vars
# Reads enable_wiremock from the child terragrunt.hcl inputs (e.g. enable_wiremock = true)
_enable_wiremock = trimspace(run_cmd("bash", "-c", "grep -qE '^[[:space:]]*enable_wiremock[[:space:]]*=[[:space:]]*true' '${get_terragrunt_dir()}/terragrunt.hcl' 2>/dev/null && echo true || echo false"))
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

_enable_wiremock is derived by shelling out to grep and parsing terragrunt.hcl as plain text. This is fragile (e.g., it won't work if enable_wiremock is set via a local/expression, moved to a shared include, or formatted differently) and adds an implicit dependency on bash/grep during config evaluation. Prefer a Terragrunt-native approach (e.g., define a local enable_wiremock in child configs and reference that here, or pass it via an env var that the hook consumes) rather than scraping HCL with grep.

Suggested change
_enable_wiremock = trimspace(run_cmd("bash", "-c", "grep -qE '^[[:space:]]*enable_wiremock[[:space:]]*=[[:space:]]*true' '${get_terragrunt_dir()}/terragrunt.hcl' 2>/dev/null && echo true || echo false"))
# Use Terragrunt-native parsing instead of shelling out to grep.
child_config = read_terragrunt_config("${get_terragrunt_dir()}/terragrunt.hcl")
_enable_wiremock = lower(tostring(try(local.child_config.inputs.enable_wiremock, false)))

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +171
# When wiremock is enabled (via domain.hcl), USE_WIREMOCK_AUTH and NHS_LOGIN_AUTHORIZE_URL
# are baked into the SPA build.
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The comment says wiremock is enabled "via domain.hcl", but the hook is actually driven by the enable_wiremock input (and _enable_wiremock is parsed from terragrunt.hcl). This is misleading documentation; update the comment to reflect the real toggle source.

Suggested change
# When wiremock is enabled (via domain.hcl), USE_WIREMOCK_AUTH and NHS_LOGIN_AUTHORIZE_URL
# are baked into the SPA build.
# When wiremock is enabled via the enable_wiremock Terragrunt input (local._enable_wiremock),
# USE_WIREMOCK_AUTH and NHS_LOGIN_AUTHORIZE_URL are baked into the SPA build.

Copilot uses AI. Check for mistakes.
@@ -23,5 +23,5 @@ include "app" {

inputs = {
# WireMock - enabled for dev to stub 3rd-party APIs and support Playwright tests
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This comment implies WireMock is generally "enabled for dev", but this is the uat environment config and enable_wiremock is being set to false. Consider rewording the comment to state that WireMock is disabled in UAT (and why), so readers don't have to reconcile the mismatch.

Suggested change
# WireMock - enabled for dev to stub 3rd-party APIs and support Playwright tests
# WireMock - disabled in UAT; only enabled in dev to stub 3rd-party APIs and support Playwright tests

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 1, 2026 08:35
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +59 to +62
# WireMock build configuration — controls SPA build-time env vars
# Reads enable_wiremock from the child terragrunt.hcl inputs (e.g. enable_wiremock = true)
_enable_wiremock = trimspace(run_cmd("bash", "-c", "grep -qE '^[[:space:]]*enable_wiremock[[:space:]]*=[[:space:]]*true' '${get_terragrunt_dir()}/terragrunt.hcl' 2>/dev/null && echo true || echo false"))
_wiremock_base_url = "https://wiremock-${local.environment}.${local.base_domain}"
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

This derives enable_wiremock by grepping the child terragrunt.hcl. That’s brittle (breaks if the value is set via an expression, different formatting, or moved to a different file) and adds an implicit coupling between config structure and behavior. Prefer passing wiremock build flags explicitly to the hook from the child config (or from a dedicated, machine-readable file like domain.hcl) instead of parsing HCL with grep.

Suggested change
# WireMock build configuration — controls SPA build-time env vars
# Reads enable_wiremock from the child terragrunt.hcl inputs (e.g. enable_wiremock = true)
_enable_wiremock = trimspace(run_cmd("bash", "-c", "grep -qE '^[[:space:]]*enable_wiremock[[:space:]]*=[[:space:]]*true' '${get_terragrunt_dir()}/terragrunt.hcl' 2>/dev/null && echo true || echo false"))
_wiremock_base_url = "https://wiremock-${local.environment}.${local.base_domain}"
# WireMock build configuration — controls SPA build-time env vars.
# WireMock flags are read from domain.hcl locals to avoid parsing HCL via grep.
_enable_wiremock = lookup(local._domain_overrides, "enable_wiremock", false)
_wiremock_base_url = lookup(local._domain_overrides, "wiremock_base_url", "https://wiremock-${local.environment}.${local.base_domain}")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants