-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add publishing of recipes for pull requests (#5511)
# Description This change adds a publish step to our builds that will upload the recipes we use in tests. Right now these recipes are published manually, and so changes we make to recipes cannot be tested in PRs. This step adds publishing of recipes to our existing `radiusdev` ACR. The next change will start to consume these recipes from their new paths in our functional tests.
- Loading branch information
Showing
6 changed files
with
154 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#! /bin/bash | ||
|
||
# Fail immedietly if any command fails | ||
set -e | ||
|
||
# Get command line arguments | ||
BICEP_PATH=$1 | ||
DIRECTORY=$2 | ||
REGISTRY_PATH=$3 | ||
RECIPE_VERSION=$4 | ||
|
||
BICEP_EXECUTABLE="$BICEP_PATH/rad-bicep" | ||
|
||
# Print usage information | ||
function print_usage() { | ||
echo "Usage: $0 <BICEP_PATH> <DIRECTORY> <REGISTRY_PATH> <RECIPE_VERSION>" | ||
echo "" | ||
echo " Publishes all recipes in the repository to the Azure Container Registry. Requires you to be logged into Azure via az login." | ||
echo "" | ||
echo " BICEP_PATH: Path to directory containing the bicep executable. For example, ~/.rad/bin" | ||
echo " DIRECTORY: Directory containing the recipes to publish. For example, ./test/functional/testdata/recipes" | ||
echo " REGISTRY_PATH: Registry hostname and path prefix. For example, myregistry.azurecr.io/tests/recipes." | ||
echo " RECIPE_VERSION: Version of the recipe to publish. For example, pr-19293" | ||
echo "" | ||
} | ||
|
||
# Verify that the required arguments are present | ||
if [[ $# -ne 4 ]]; then | ||
echo "Error: Missing required arguments" | ||
echo "" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
# We create output that's intended to be consumed by the GitHub Action summary. If we're | ||
# not running in a GitHub Action, we'll just silence the output. | ||
if [[ -z "$GITHUB_STEP_SUMMARY" ]]; then | ||
GITHUB_STEP_SUMMARY=/dev/null | ||
fi | ||
|
||
echo "## Recipes published to $REGISTRY_PATH" >> $GITHUB_STEP_SUMMARY | ||
for RECIPE in $(find "$DIRECTORY" -type f -name "*.bicep") | ||
do | ||
FILENAME=$(basename $RECIPE) | ||
PUBLISH_REF="$REGISTRY_PATH/${FILENAME%.*}:$RECIPE_VERSION" | ||
|
||
# Skip files that start with _. These are not recipes, they are modules that are | ||
# used by the recipes. | ||
if [[ $RECIPE = _* ]]; then | ||
echo "Skipping $RECIPE" | ||
continue | ||
fi | ||
|
||
echo "Publishing $RECIPE to $PUBLISH_REF" | ||
echo "- $PUBLISH_REF" >> $GITHUB_STEP_SUMMARY | ||
$BICEP_EXECUTABLE publish $RECIPE --target "br:$PUBLISH_REF" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ------------------------------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------------------------------ | ||
|
||
RECIPE_TAG_VERSION?=latest | ||
RAD_BICEP_PATH?=$${HOME}/.rad/bin | ||
|
||
##@ Recipes | ||
|
||
.PHONY: publish-test-recipes | ||
publish-test-recipes: ## Publishes test recipes to <RECIPE_REGISTRY> with version <RECIPE_TAG_VERSION> | ||
@if [ -z "$(RECIPE_REGISTRY)" ]; then echo "Error: RECIPE_REGISTRY must be set to a valid OCI registry"; exit 1; fi | ||
|
||
@echo "$(ARROW) Publishing recipes from ./test/functional/corerp/resources/testdata/recipes/test-recipes..." | ||
./.github/scripts/publish-recipes.sh \ | ||
${RAD_BICEP_PATH} \ | ||
./test/functional/corerp/resources/testdata/recipes/test-recipes \ | ||
${RECIPE_REGISTRY}/test/functional/corerp/recipes \ | ||
${RECIPE_TAG_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/functional/corerp/resources/testdata/recipes/test-recipes/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Test Recipes | ||
|
||
The recipes in this folder are published as part of the PR process to: | ||
|
||
> `radiusdev.azurecr.io/test/functional/corerp/<filename>:pr-<pr-number>` | ||
This is important because it allows us to make changes to the recipes, and test them in the same PR that contains the change. | ||
|
||
## Non-recipes bicep files | ||
|
||
Any Bicep file starting with `_` will be skipped during publishing. Use this as a convention to create shared modules that are not published as recipes. For example `_redis_kubernetes.bicep` would not be published. |