Skip to content
Open
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
22 changes: 15 additions & 7 deletions .github/build/environment.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

# Environment Setup:
# make install-radius # Install Radius CLI
# make create-cluster # Create a local k3d Kubernetes cluster for testing
# make delete-cluster # Delete the local k3d Kubernetes cluster
# make create-cluster # Create a local kind Kubernetes cluster for testing
# make delete-cluster # Delete the local kind Kubernetes cluster

RAD_VERSION ?=

Expand All @@ -29,20 +29,28 @@ install-radius-cli: ## Install the Radius CLI. Optionally specify a version numb
wget -q "https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh" -O - | /bin/bash $(if $(RAD_VERSION),-s $(RAD_VERSION))

.PHONY: create-radius-cluster
create-radius-cluster: ## Create a local k3d Kubernetes cluster with a default Radius workspace/group/environment.
@echo -e "$(ARROW) Creating local k3d cluster and installing Radius..."
create-radius-cluster: ## Create a local kind Kubernetes cluster with a default Radius workspace/group/environment.
@echo -e "$(ARROW) Creating local kind cluster and installing Radius..."
@.github/scripts/create-cluster.sh
@.github/scripts/verify-ucp-readiness.sh
@echo -e "$(ARROW) Creating workspace and environment..."
@.github/scripts/create-workspace.sh

.PHONY: clean
clean: ## Delete the local k3d cluster, Radius config, Bicep extensions (*.tgz), and bicepconfig.json files
clean: ## Delete the local kind cluster, Radius config, Bicep extensions (*.tgz), and bicepconfig.json files
@echo -e "$(ARROW) Deleting Radius config file at ~/.rad/config.yaml..."
@rm -f ~/.rad/config.yaml
@echo -e "$(ARROW) Deleting Bicep extension files (*.tgz)..."
@find . -name "*.tgz" -type f -delete
@echo -e "$(ARROW) Deleting bicepconfig.json files..."
@find . -name "bicepconfig.json" -type f -delete
@echo -e "$(ARROW) Deleting k3d cluster..."
@k3d cluster delete
@echo -e "$(ARROW) Deleting kind cluster..."
@kind delete cluster

.PHONY: configure-azure-provider
configure-azure-provider: ## Configure Radius Azure workspace, environment, credential, and deployment target (requires AZURE_* env vars)
@.github/scripts/configure-azure-provider.sh

.PHONY: cleanup-azure-resources
cleanup-azure-resources: ## Delete Azure resource group created for tests (uses AZURE_TEST_STATE_FILE or AZURE_RESOURCE_GROUP)
@.github/scripts/cleanup-azure-resources.sh
16 changes: 16 additions & 0 deletions .github/build/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ RECIPE_TYPE ?= all
build: ## Build all resource types and recipes
@./.github/scripts/build-all.sh "$(RESOURCE_TYPE_ROOT)"

.PHONY: build-kubernetes-recipes
build-kubernetes-recipes: ## Build Kubernetes recipes only
@RECIPE_PLATFORM_FILTER=kubernetes ./.github/scripts/build-all.sh "$(RESOURCE_TYPE_ROOT)"

.PHONY: build-azure-recipes
build-azure-recipes: ## Build Azure recipes only
@RECIPE_PLATFORM_FILTER=azure ./.github/scripts/build-all.sh "$(RESOURCE_TYPE_ROOT)"

.PHONY: build-resource-type
build-resource-type: ## Validate a resource type by running the 'rad resource-type create' and 'bicep publish-extension' commands (requires TYPE_FOLDER parameter)
ifndef TYPE_FOLDER
Expand Down Expand Up @@ -72,6 +80,14 @@ endif
test: ## Run recipe tests (assumes already registered)
@./.github/scripts/test-all-recipes.sh "$(RESOURCE_TYPE_ROOT)" "$(ENVIRONMENT)" "$(RECIPE_TYPE)"

.PHONY: test-kubernetes-recipes
test-kubernetes-recipes: ## Run recipe tests for Kubernetes platform only
@RECIPE_PLATFORM_FILTER=kubernetes ./.github/scripts/test-all-recipes.sh "$(RESOURCE_TYPE_ROOT)"

.PHONY: test-azure-recipes
test-azure-recipes: ## Run recipe tests for Azure platform only (requires Azure configuration)
@RECIPE_PLATFORM_FILTER=azure ./.github/scripts/test-all-recipes.sh "$(RESOURCE_TYPE_ROOT)"

.PHONY: list-resource-types
list-resource-types: ## List resource type folders under the specified root
@./.github/scripts/list-resource-type-folders.sh "$(RESOURCE_TYPE_ROOT)"
Expand Down
49 changes: 47 additions & 2 deletions .github/scripts/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,39 @@
set -euo pipefail

ROOT_DIR="${1:-}"
PLATFORM_FILTER_RAW="${RECIPE_PLATFORM_FILTER:-}"

declare -a PLATFORM_FILTERS=()
if [[ -n "$PLATFORM_FILTER_RAW" ]]; then
IFS=',' read -ra _raw_filters <<< "$PLATFORM_FILTER_RAW"
for _entry in "${_raw_filters[@]}"; do
_trimmed="$(printf '%s' "$_entry" | xargs)"
if [[ -n "$_trimmed" ]]; then
PLATFORM_FILTERS+=("$_trimmed")
fi
done
fi

should_include_platform() {
local recipe_path="$1"
if [[ ${#PLATFORM_FILTERS[@]} -eq 0 ]]; then
return 0
fi

# Extract segment after recipes/ (path is relative: recipes/platform/...)
# Remove "recipes/" prefix if present
local rel="${recipe_path#recipes/}"
# Get the first path segment (the platform)
local platform="${rel%%/*}"

for _filter in "${PLATFORM_FILTERS[@]}"; do
if [[ "$platform" == "$_filter" ]]; then
return 0
fi
done

return 1
}

# Iterate over all resource type folders
while IFS= read -r type_dir; do
Expand All @@ -49,14 +82,26 @@ while IFS= read -r type_dir; do
recipes_root="$type_dir/recipes"
if [[ -d "$recipes_root" ]]; then
while IFS= read -r -d '' recipe_file; do
make -s build-bicep-recipe RECIPE_PATH="$recipe_file"
recipe_rel_path="${recipe_file#$type_dir/}"
if should_include_platform "$recipe_rel_path"; then
echo "Building Bicep recipe: $recipe_file"
make -s build-bicep-recipe RECIPE_PATH="$recipe_file"
else
echo "Skipping Bicep recipe (platform filter): $recipe_file"
fi
done < <(find "$recipes_root" -type f -name '*.bicep' -print0)
fi

# Build/publish all Terraform recipes under this resource type, if any
if [[ -d "$recipes_root" ]]; then
while IFS= read -r -d '' recipe_dir; do
make -s build-terraform-recipe RECIPE_PATH="$recipe_dir"
recipe_rel_path="${recipe_dir#$type_dir/}"
if should_include_platform "$recipe_rel_path"; then
echo "Building Terraform recipe: $recipe_dir"
make -s build-terraform-recipe RECIPE_PATH="$recipe_dir"
else
echo "Skipping Terraform recipe (platform filter): $recipe_dir"
fi
done < <(find "$recipes_root" -type d -name 'terraform' -print0)
fi
done < <(./.github/scripts/list-resource-type-folders.sh ${ROOT_DIR:+"$ROOT_DIR"})
46 changes: 46 additions & 0 deletions .github/scripts/cleanup-azure-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# ------------------------------------------------------------
# Copyright 2025 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

# =============================================================================
# Cleanup script for Azure resources created during recipe validation.
# Deletes the resource group recorded in the Azure test state file (if any).
# =============================================================================

set -euo pipefail

AZURE_RESOURCE_GROUP="${AZURE_RESOURCE_GROUP:-}"

if [[ -z "$AZURE_RESOURCE_GROUP" ]]; then
echo "No Azure resource group provided, skipping cleanup."
exit 0
fi

if ! command -v az >/dev/null 2>&1; then
echo "Azure CLI not available; cannot delete resource group '$AZURE_RESOURCE_GROUP'." >&2
exit 1
fi

echo "Deleting Azure resource group '$AZURE_RESOURCE_GROUP'"
SUB_ARGS=()
if [[ -n "${AZURE_SUBSCRIPTION_ID:-}" ]]; then
SUB_ARGS+=(--subscription "$AZURE_SUBSCRIPTION_ID")
fi

az group delete --name "$AZURE_RESOURCE_GROUP" --yes --no-wait "${SUB_ARGS[@]}"

echo "Azure cleanup initiated for resource group '$AZURE_RESOURCE_GROUP'"
82 changes: 82 additions & 0 deletions .github/scripts/configure-azure-provider.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# ------------------------------------------------------------
# Copyright 2025 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

# =============================================================================
# Configure the Radius control plane with Azure workload identity credentials
# so Azure recipes can be tested. This script assumes the caller has
# already authenticated with Azure via `az login` or the GitHub Actions
# `azure/login` action. It creates (or reuses) a dedicated workspace,
# environment, and credential, then updates the environment with the Azure
# subscription and resource group used for testing.
# =============================================================================

set -euo pipefail

require_env() {
local name="$1"
if [[ -z "${!name:-}" ]]; then
echo "Error: environment variable '$name' must be set" >&2
exit 1
fi
}

ensure_command() {
local cmd="$1"
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: required command '$cmd' not found in PATH" >&2
exit 1
fi
}

ensure_command "az"
ensure_command "rad"

require_env "AZURE_SUBSCRIPTION_ID"
require_env "AZURE_TENANT_ID"
require_env "AZURE_CLIENT_ID"

AZURE_LOCATION="${AZURE_LOCATION:-westus3}"
AZURE_RESOURCE_GROUP="${AZURE_RESOURCE_GROUP:-}"
AZURE_WORKSPACE_NAME="${AZURE_WORKSPACE_NAME:-default}"
AZURE_ENVIRONMENT_NAME="${AZURE_ENVIRONMENT_NAME:-default}"

if [[ -z "$AZURE_RESOURCE_GROUP" ]]; then
echo "Error: AZURE_RESOURCE_GROUP must be provided" >&2
exit 1
fi

printf "\033[34;1m=>\033[0m Configuring Azure provider for Radius tests\n"

# az group exists returns "true" or "false" as text, not an exit code
if [[ "$(az group exists --name "$AZURE_RESOURCE_GROUP" --subscription "$AZURE_SUBSCRIPTION_ID" 2>/dev/null)" != "true" ]]; then
echo "Error: Azure resource group '$AZURE_RESOURCE_GROUP' not found. Create it before running configure-azure-provider." >&2
exit 1
fi

printf "\033[34;1m=>\033[0m Updating environment '%s' with Azure provider settings\n" "$AZURE_ENVIRONMENT_NAME"
rad env update "$AZURE_ENVIRONMENT_NAME" \
--azure-subscription-id "$AZURE_SUBSCRIPTION_ID" \
--azure-resource-group "$AZURE_RESOURCE_GROUP" \
--preview

printf "\033[34;1m=>\033[0m Registering Azure workload identity credential\n"
rad credential register azure wi \
--tenant-id "$AZURE_TENANT_ID" \
--client-id "$AZURE_CLIENT_ID"

printf "\033[34;1m=>\033[0m Azure provider configured successfully\n"
Loading
Loading