Skip to content

Commit

Permalink
Update validate bicep workflow (#7702)
Browse files Browse the repository at this point in the history
Update validate bicep workflow

<!--

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 <shruthikumar@microsoft.com>
  • Loading branch information
sk593 committed Jul 22, 2024
1 parent b87bc73 commit 6aeb77a
Show file tree
Hide file tree
Showing 115 changed files with 169 additions and 155 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ jobs:
node-version: '18'
- name: Generate Bicep extensibility types from OpenAPI specs
run: |
make generate-bicep-types VERSION=${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }}
make generate-bicep-types VERSION=${{ env.REL_CHANNEL == 'edge' && 'latest' || env.REL_CHANNEL }}
- name: Upload Radius Bicep types artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -300,11 +300,12 @@ jobs:
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
if: github.repository == 'radius-project/radius' && ((startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'))
run: |
bicep publish-provider ./hack/bicep-types-radius/generated/index.json --target br:${{ env.BICEP_TYPES_REGISTRY }}/radius:${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} --force
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.BICEP_TYPES_REGISTRY }}/radius:${{ env.REL_CHANNEL == 'edge' && 'latest' || env.REL_CHANNEL }} --force
publish-release:
name: Publish GitHub Release
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/validate-bicep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ jobs:
name: Validate Bicep Code
runs-on: ubuntu-latest
steps:
- 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: Check out repo
uses: actions/checkout@v4
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- uses: oras-project/setup-oras@main
- name: Download rad-bicep
run: |
oras pull ghcr.io/radius-project/radius/bicep/rad-bicep/linux-x64:latest -o ./
chmod +x rad-bicep
./rad-bicep --version
- name: Verify Bicep files
run: ./build/validate-bicep.sh
env:
BICEP_PATH: './rad-bicep'
BICEP_PATH: 'bicep'
11 changes: 11 additions & 0 deletions bicepconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"experimentalFeaturesEnabled": {
"extensibility": true,
"extensionRegistry": true,
"dynamicTypeLoading": true
},
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
}
}
13 changes: 7 additions & 6 deletions build/validate-bicep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ then
exit 1
fi

WARNING_MSG="WARNING: The following experimental Bicep features"
FILES=$(find . -type f -name "*.bicep")
FAILURES=()
for F in $FILES
do
echo "validating $F"
# We need to run the rad-bicep and fail in one of two cases:
# We need to run bicep and fail in one of two cases:
# - non-zero exit code
# - non-empty stderr
#
# We also don't want to dirty any files on disk.
#
# This complicated little block does that:
# - Compiled output (ARM templates) go to rad-bicep's stdout
# - rad-bicep's stdout goes to /dev/null
# - rad-bicep's stderr goes to the variable
if grep -q "import radius as radius" $F
# - 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
then
exec 3>&1
echo "running: $BICEP_PATH build $F"
Expand All @@ -29,7 +30,7 @@ do
exec 3>&-
fi

if [[ ! $EXITCODE -eq 0 || ! -z $STDERR ]]
if [[ ! $EXITCODE -eq 0 || (! -z $STDERR && ! $STDERR == $WARNING_MSG* ) ]]
then
echo $STDERR
FAILURES+=$F
Expand Down
2 changes: 1 addition & 1 deletion hack/bicep-types-radius/generated/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"resourceFunctions": {},
"settings": {
"name": "radius",
"name": "Radius",
"version": "latest",
"isSingleton": false
}
Expand Down
2 changes: 1 addition & 1 deletion hack/bicep-types-radius/src/generator/src/cmd/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async function buildTypeIndex(logger: ILogger, baseDir: string, version: string)
types: readTypesJson(content),
});
}
const indexContent = await buildIndex(typeFiles, log => logOut(logger, log), {name: "radius", version: version, isSingleton: false} as TypeSettings);
const indexContent = await buildIndex(typeFiles, log => logOut(logger, log), {name: "Radius", version: version, isSingleton: false} as TypeSettings);

await writeFile(`${baseDir}/index.json`, writeIndexJson(indexContent));
await writeFile(`${baseDir}/index.md`, writeIndexMarkdown(indexContent));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param application string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param application string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param dbSubnetGroupName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param dbSubnetGroupName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param bucketName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param bucketName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param filterName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param bucketName string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import aws as aws
extension aws

param creationTimestamp string
param bucketName string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param magpieimage string

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'eastus'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as rad
extension radius

param bucketName string
param creationTimestamp string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param location string = resourceGroup().location

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Name of the Redis Cache resource.')
param redisCacheName string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// 3. Create Keyvault volume.
// 4. Create container which associated keyvault volume.

import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import kubernetes as kubernetes {
extension kubernetes with {
namespace: 'corerp-mechanics-k8s-extensibility'
kubeConfig: ''
}
} as kubernetes

resource redisService 'core/Service@v1' existing = {
metadata: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param location string
param environment string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param location string
param environment string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param magpieimage string
param environment string
Expand All @@ -19,7 +19,7 @@ resource webapp 'Applications.Core/containers@2023-10-01-preview' = {
container: {
image: magpieimage
env: {
DBCONNECTION: redis.connectionString()
DBCONNECTION: redis.listSecrets().connectionString
}
readinessProbe: {
kind: 'httpGet'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

param magpieimage string
param environment string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'local'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'local'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import radius as radius
extension radius

@description('Specifies the location for resources.')
param location string = 'global'
Expand Down
Loading

0 comments on commit 6aeb77a

Please sign in to comment.