Skip to content

Commit

Permalink
Update validate workflow to test against PR specific schema changes (r…
Browse files Browse the repository at this point in the history
…adius-project#7814)

# Description

_Please explain the changes you've made._

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- This pull request fixes a bug in Radius and has an approved issue
(issue link required).
- This pull request adds or changes features of Radius and has an
approved issue (issue link required).
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #issue_number

---------

Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 authored Aug 21, 2024
1 parent 875c5ca commit 33d3d5e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/validate-bicep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ on:
permissions:
id-token: write # Required for requesting the JWT

env:
# Local Docker registry name
LOCAL_REGISTRY_NAME: "radius-registry"
# Local Docker registry server
LOCAL_REGISTRY_SERVER: "localhost"
# Local Docker registry port
LOCAL_REGISTRY_PORT: "5000"

concurrency:
# Cancel the previously triggered build for only PR build.
group: bicep-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -44,11 +52,23 @@ jobs:
bicep --version
- name: Check out repo
uses: actions/checkout@v4
- name: Create a secure local registry
id: create-local-registry
uses: ./.github/actions/create-local-registry
with:
secure: "true"
registry-name: ${{ env.LOCAL_REGISTRY_NAME }}
registry-server: ${{ env.LOCAL_REGISTRY_SERVER }}
registry-port: ${{ env.LOCAL_REGISTRY_PORT }}
- name: Publish bicep types
run: |
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:latest --force
- name: Install jq
run: sudo apt-get install -y jq
- name: Modify bicepconfig.json
run: |
# Add credential preference to the bicepconfig.json file
jq '.extensions.radius = "br:${{ env.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:latest"' bicepconfig.json > tmp.json && mv tmp.json bicepconfig.json
jq '. + {"cloud": {"credentialPrecedence": ["Environment"]}}' bicepconfig.json > tmp.json && mv tmp.json bicepconfig.json
- name: Print updated bicepconfig.json
run: cat bicepconfig.json
Expand Down
15 changes: 13 additions & 2 deletions build/validate-bicep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ then
exit 1
fi

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

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

FAILURES=()
WARNINGS=()
for F in $FILES
do
echo "validating $F"
Expand All @@ -59,7 +59,13 @@ do
exec 3>&-
fi

if [[ ! $EXITCODE -eq 0 || ($STDERR != $WARNING_MSG* && $STDERR == *"Error"*) ]]
if [[ $STDERR == *"Warning"* ]]
then
echo $STDERR
WARNINGS+=$F
fi

if [[ ! $EXITCODE -eq 0 || $STDERR == *"Error"* ]]
then
echo $STDERR
FAILURES+=$F
Expand All @@ -71,4 +77,9 @@ do
echo "Failed: $F"
done

for F in $WARNINGS
do
echo "Warning: $F"
done

exit ${#FAILURES[@]}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module redis '../../../test/testrecipes/modules/redis-selfhost.bicep' = {
}
}

#disable-next-line BCP081
resource dapr 'dapr.io/Component@v1alpha1' = {
metadata: {
name: context.resource.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extension kubernetes with {

param context object

#disable-next-line BCP081
resource dapr 'dapr.io/Component@v1alpha1' = {
metadata: {
name: context.resource.name
Expand Down
1 change: 1 addition & 0 deletions test/testrecipes/test-bicep-recipes/dapr-state-store.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module redis '../../../test/testrecipes/modules/redis-selfhost.bicep' = {
}
}

#disable-next-line BCP081
resource dapr 'dapr.io/Component@v1alpha1' = {
metadata: {
name: context.resource.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ output result object = {
username: account.name
}
secrets: {
#disable-next-line outputs-should-not-contain-secrets
connectionString: account.listConnectionStrings().connectionStrings[0].connectionString
#disable-next-line outputs-should-not-contain-secrets
password: account.listKeys().primaryMasterKey
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ output result object = {
database: context.resource.name
}
secrets: {
#disable-next-line outputs-should-not-contain-secrets
connectionString: 'mongodb://${username}:${password}@${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local:27017'
username: username
#disable-next-line outputs-should-not-contain-secrets
password: password
}
}
1 change: 1 addition & 0 deletions test/testrecipes/test-bicep-recipes/rabbitmq-recipe.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ output result object = {
username: username
}
secrets: {
#disable-next-line outputs-should-not-contain-secrets
password: password
}
}
1 change: 1 addition & 0 deletions test/testrecipes/test-bicep-recipes/sqldb-recipe.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ output result object = {
username: username
}
secrets: {
#disable-next-line outputs-should-not-contain-secrets
password: password
}
}

0 comments on commit 33d3d5e

Please sign in to comment.