Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 committed Aug 8, 2024
1 parent 22f9bb2 commit 2a53f46
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,6 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 'Login via Azure CLI'
uses: azure/login@v2
with:
client-id: ${{ secrets.BICEPTYPES_CLIENT_ID }}
tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }}
subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }}

- uses: marocchino/sticky-pull-request-comment@v2
if: env.PR_NUMBER != ''
Expand Down Expand Up @@ -660,6 +653,9 @@ jobs:
"extensions": {
"radius": "br:${{ env.BICEP_TYPES_REGISTRY }}/test/radius:$RADIUS_VERSION",
"aws": "br:${{ env.BICEP_TYPES_REGISTRY }}/aws:latest"
},
"cloud": {
"credentialPrecedence": ["Environment"]
}
}
EOF
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/functional-test-noncloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,16 @@ jobs:
run: |
make publish-test-terraform-recipes
- name: Setup and verify bicep CLI
run: |
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version
- name: Publish bicep types
run: |
./.rad/bin/rad-bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} --force
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} --force
- name: Generate test bicepconfig.json
run: |
Expand All @@ -341,6 +348,9 @@ jobs:
"extensions": {
"radius": "br:${{ env.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:$RADIUS_VERSION",
"aws": "br:${{ env.BICEP_TYPES_REGISTRY }}/aws:latest"
},
"cloud": {
"credentialPrecedence": ["Environment"]
}
}
EOF
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/validate-bicep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ jobs:
name: Validate Bicep Code
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup and verify bicep CLI
run: |
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
chmod +x ./bicep
sudo mv ./bicep /usr/local/bin/bicep
bicep --version
- name: 'Login via Azure CLI'
uses: azure/login@v2
with:
client-id: ${{ secrets.BICEPTYPES_CLIENT_ID }}
tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }}
subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }}
- name: Check out repo
uses: actions/checkout@v4
- name: Verify Bicep files
run: ./build/validate-bicep.sh
env:
Expand Down
3 changes: 3 additions & 0 deletions bicepconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"cloud": {
"credentialPrecedence": ["Environment"]
}
}
36 changes: 32 additions & 4 deletions build/validate-bicep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ fi

WARNING_MSG="WARNING: The following experimental Bicep features"
FILES=$(find . -type f -name "*.bicep")

# Get the first bicep file from the list to restore extensions
FIRST_FILE_RAD=""
FIRST_FILE_AWS=""
for F in $FILES
do
# Check if the file contains the word "extension radius"
if [ -z "$FIRST_FILE_RAD" ] && grep -q "extension radius" "$F"; then
FIRST_FILE_RAD="$F"
fi
# Check if the file contains the word "extension aws"
if [ -z "$FIRST_FILE_AWS" ] && grep -q "extension aws" "$F"; then
FIRST_FILE_AWS="$F"
fi
# Break the loop if both files are found
if [ -n "$FIRST_FILE_RAD" ] && [ -n "$FIRST_FILE_AWS" ]; then
break
fi
done

echo "running Radius: $BICEP_PATH build $FIRST_FILE_RAD"
STDERR=$($BICEP_PATH build $FIRST_FILE_RAD --stdout 2>&1 1>/dev/null)
echo "Restoring Radius extension with response: $STDERR..."

echo "running AWS: $BICEP_PATH build $FIRST_FILE_AWS"
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
do
Expand All @@ -21,16 +49,16 @@ do
# - Compiled output (ARM templates) go to bicep's stdout
# - bicep's stdout goes to /dev/null
# - bicep's stderr goes to the variable
if grep -q "extension radius" $F
if grep -q "extension" $F
then
exec 3>&1
echo "running: $BICEP_PATH build $F"
STDERR=$($BICEP_PATH build $F --stdout 2>&1 1>/dev/null)
echo "running: $BICEP_PATH build --no-restore $F"
STDERR=$($BICEP_PATH build --no-restore $F --stdout 2>&1 1>/dev/null)
EXITCODE=$?
exec 3>&-
fi

if [[ ! $EXITCODE -eq 0 || (! -z $STDERR && ! $STDERR == $WARNING_MSG* && ! $STDERR == *"Error"* ) ]]
if [[ ! $EXITCODE -eq 0 || ($STDERR != $WARNING_MSG* && $STDERR == *"Error"*) || ($STDERR == *"Warning"*) ]]
then
echo $STDERR
FAILURES+=$F
Expand Down
2 changes: 2 additions & 0 deletions test/infra/azure/modules/grafana.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ resource adminRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01
name: guid(grafana.id, roleDefinitionId.GrafanaAdmin.id)
scope: grafana
properties: {
#disable-next-line use-resource-id-functions
roleDefinitionId: roleDefinitionId.GrafanaAdmin.id
principalId: adminObjectId
}
Expand All @@ -102,6 +103,7 @@ resource readerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-0
name: guid(grafana.id, roleDefinitionId.MonitoringReader.id)
scope: grafana
properties: {
#disable-next-line use-resource-id-functions
roleDefinitionId: roleDefinitionId.MonitoringReader.id
principalId: grafana.identity.principalId
}
Expand Down

0 comments on commit 2a53f46

Please sign in to comment.