Skip to content

Commit

Permalink
add temp bicepconfig to validate bicep
Browse files Browse the repository at this point in the history
Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 committed Aug 12, 2024
1 parent 3a8df14 commit aae53b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 7 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,30 @@ jobs:
message: |
:hourglass: Publishing Bicep Recipes for functional tests...
- name: Generate test bicepconfig.json
run: |
if [[ "${{ env.REL_VERSION }}" == "edge" ]]; then
RADIUS_VERSION="latest"
else
RADIUS_VERSION="${{ env.REL_VERSION }}"
fi
cat <<EOF > ./test/bicepconfig.json
{
"experimentalFeaturesEnabled": {
"extensibility": true,
"extensionRegistry": true,
"dynamicTypeLoading": true
},
"extensions": {
"radius": "br:${{ env.BICEP_TYPES_REGISTRY }}/test/radius:$RADIUS_VERSION",
"aws": "br:${{ env.BICEP_TYPES_REGISTRY }}/aws:latest"
},
"cloud": {
"credentialPrecedence": ["Environment"]
}
}
EOF
- name: Publish Bicep Test Recipes
run: |
mkdir ./bin
Expand Down
6 changes: 0 additions & 6 deletions bicepconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"cloud": {
"credentialPrecedence": [
"Environment",
"AzureCLI"
]
}
}
33 changes: 32 additions & 1 deletion build/validate-bicep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ fi
WARNING_MSG="WARNING: The following experimental Bicep features"
FILES=$(find . -type f -name "*.bicep")

# Create a temporary directory
TEMP_DIR=$(mktemp -d)

# Copy .bicep files to the temporary directory
for F in $FILES
do
cp "$F" "$TEMP_DIR"
done

# Add a temporary bicepconfig.json file to the temporary directory
cat <<EOL > "$TEMP_DIR/bicepconfig.json"
{
"experimentalFeaturesEnabled": {
"extensibility": true,
"extensionRegistry": true,
"dynamicTypeLoading": true
},
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"cloud": {
"credentialPrecedence": [
"Environment"
]
}
}
EOL


# Get the first bicep file with Radius and AWS extensions from the list to restore extensions
FIRST_FILE_RAD=""
FIRST_FILE_AWS=""
Expand Down Expand Up @@ -37,7 +67,7 @@ STDERR=$($BICEP_PATH build $FIRST_FILE_AWS --stdout 2>&1 1>/dev/null)
echo "Restoring AWS extension with response: $STDERR..."

FAILURES=()
for F in $FILES
for F in $TEMP_DIR/*.bicep
do
echo "validating $F"
# We need to run bicep and fail in one of two cases:
Expand Down Expand Up @@ -71,4 +101,5 @@ do
echo "Failed: $F"
done

rm -rf "$TEMP_DIR"
exit ${#FAILURES[@]}

0 comments on commit aae53b1

Please sign in to comment.