Skip to content

Commit

Permalink
Update functional test workflow with test Bicep types (#7730)
Browse files Browse the repository at this point in the history
# 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 <shruthikumar@microsoft.com>
  • Loading branch information
sk593 authored Aug 2, 2024
1 parent dbde31d commit 06d334a
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 129 deletions.
64 changes: 62 additions & 2 deletions .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ env:
TF_RECIPE_PRIVATE_GIT_SOURCE: "git::https://github.com/radius-project/terraform-private-modules//kubernetes-redis"
# The number of failed tests to report.
ISSUE_CREATE_THRESHOLD: 2
# bicep-types ACR url for uploading Radius Bicep types
BICEP_TYPES_REGISTRY: 'biceptypes.azurecr.io'

jobs:
build:
Expand Down Expand Up @@ -348,10 +350,49 @@ jobs:
append: true
message: |
:x: Test recipe publishing failed
publish-test-bicep-types:
name: Publish Radius bicep types to ACR
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py
- name: Set up Go ${{ env.GOVER }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOVER }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
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 }}
- name: Upload Radius Bicep types artifacts
uses: actions/upload-artifact@v4
with:
name: radius-bicep-types
path: ./hack/bicep-types-radius/generated
if-no-files-found: error
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.BICEP_TYPES_AZURE_CREDENTIALS }}
- 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: |
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.BICEP_TYPES_REGISTRY }}/test/radius:${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} --force
tests:
name: Run ${{ matrix.name }} functional tests
needs: build
needs: [build, publish-test-bicep-types]
if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || github.event_name == 'workflow_run'
strategy:
fail-fast: true
Expand Down Expand Up @@ -593,7 +634,26 @@ jobs:
- name: Publish Terraform test recipes
run: |
make publish-test-terraform-recipes
- 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"
}
}
EOF
- name: Run functional tests
run: |
# Ensure rad cli is in path before running tests.
Expand Down
47 changes: 46 additions & 1 deletion .github/workflows/functional-test-noncloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ env:
LOCAL_REGISTRY_SERVER: "localhost"
# Local Docker registry port
LOCAL_REGISTRY_PORT: "5000"
# bicep-types ACR url for uploading Radius Bicep types
BICEP_TYPES_REGISTRY: 'biceptypes.azurecr.io'

jobs:
build:
Expand Down Expand Up @@ -126,7 +128,7 @@ jobs:
echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT
echo "DE_IMAGE=${{ env.DE_IMAGE }}" >> $GITHUB_OUTPUT
echo "DE_TAG=${{ env.DE_TAG }}" >> $GITHUB_OUTPUT
tests:
name: Run ${{ matrix.name }} functional tests
needs: build
Expand Down Expand Up @@ -205,6 +207,25 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Parse release version and set environment variables
run: python ./.github/scripts/get_release_version.py

- name: Generate Bicep extensibility types from OpenAPI specs
run: |
make generate-bicep-types VERSION=${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }}
- name: Upload Radius Bicep types artifacts
uses: actions/upload-artifact@v4
with:
name: radius-bicep-types
path: ./hack/bicep-types-radius/generated
if-no-files-found: error

- name: Create a secure local registry
id: create-local-registry
uses: ./.github/actions/create-local-registry
Expand Down Expand Up @@ -310,7 +331,31 @@ jobs:
BICEP_RECIPE_TAG_VERSION: ${{ env.REL_VERSION }}
TEMP_CERT_DIR: ${{ steps.create-local-registry.outputs.temp-cert-dir }}
SSL_CERT_FILE: ${{ steps.create-local-registry.outputs.temp-cert-dir }}/certs/${{ env.LOCAL_REGISTRY_SERVER }}/client.crt

- 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
- 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.LOCAL_REGISTRY_SERVER }}:${{ env.LOCAL_REGISTRY_PORT }}/radius:$RADIUS_VERSION",
"aws": "br:${{ env.BICEP_TYPES_REGISTRY }}/aws:latest"
}
}
EOF
- name: Run functional tests
run: |
# Ensure rad cli is in path before running tests.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ In addition, we have the below repositories.
| [Samples](https://github.com/radius-project/samples) | This repository contains the source code for quickstarts, reference apps, and tutorials for Radius.
| [Recipes](https://github.com/radius-project/recipes) | This repo contains commonly used Recipe templates for Radius Environments.
| [Website](https://github.com/radius-project/website) | This repository contains the source code for the Radius website.
| [Bicep](https://github.com/radius-project/bicep) | This repository contains source code for Bicep, which is a DSL for deploying cloud resources types.
| [AWS Bicep Types](https://github.com/radius-project/bicep-types-aws) | This repository contains the tooling for Bicep support for AWS resource types.


Expand Down
2 changes: 1 addition & 1 deletion build/validate-bicep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ do
exec 3>&-
fi

if [[ ! $EXITCODE -eq 0 || (! -z $STDERR && ! $STDERR == $WARNING_MSG* ) ]]
if [[ ! $EXITCODE -eq 0 || (! -z $STDERR && ! $STDERR == $WARNING_MSG* && ! $STDERR == *"Error"* ) ]]
then
echo $STDERR
FAILURES+=$F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,60 @@ In order to update or create a new schema follow these steps:
</details>
1. Add any necessary changes to the Radius resource provider to support the newly added types.
1. Add any necessary tests, as needed.
1. Open a pull request in the Radius repo.

Creating a pull request in the Radius repo that contains application model changes triggers an automated pull request in bicep repo with the bicep type changes. You will merge this in step 3.
1. Open a pull request in the Radius repo.

## Step 2: Update docs and samples

Visit the [docs](https://github.com/radius-project/docs/) and [samples](https://github.com/radius-project/samples/) repository and open PRs with the changes to the resource(s). Some checks will fail until you begin merging PRs below.

## Step 3: Merge pull requests in order

⚠️ Make sure you have PRs open and ready to merge within the radius, bicep, docs, and samples repositories. Do not proceed until all the PRs are ready and approved.
⚠️ Make sure you have PRs open and ready to merge within the radius, docs, and samples repositories. Do not proceed until all the PRs are ready and approved.

1. **Samples Repository**: Merging the PR in samples repo may not be straightforward, as we currently have a cyclic dependency between samples and radius repositories (_i.e "Test Quickstarts" task in samples pipeline run would fail as it runs on the main branch of Radius which doesn't have the latest changes as Radius PR is blocked on the samples PR for bicep files update._) You need to have a repo admin force merge the samples PR.
2. **Radius Repository**: After the PR from the samples repositories are merged, re-run the checks to make sure there are no failures to merge the Radius PR.
3. **Docs Repository**: Rerun any failed checks and merge the PR from docs repo with updated Bicep files changes.
# Testing schema changes locally
If you would like to test that your schema changes are compilable in a Bicep template, you can do so by publishing them to an OCI registry using the [Bicep CLI](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/).
## Step 1: Download the Bicep CLI
1. Follow the steps in the Bicep [documentation](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install) to download Bicep
## Step 2: Create an OCI compliant registry
1. Create an OCI compliant registry of your choice. Keep the registry endpoint handy for the next steps.
## Step 3: Upload the new schema types to an OCI registry
1. Run `make generate` to generate the OpenAPI spec and API clients:
1. **Bicep Repository**: Begin by merging the bicep repo PR. This will update the Bicep types which will allow the other PRs to properly build and be merged.
2. **Docs Repository**: Rerun any failed checks and merge the PR from docs repo with updated Bicep files changes.
3. **Samples Repository**: Merging the PR in samples repo may not be straightforward, as we currently have a cyclic dependency between samples and radius repositories (_i.e "Test Quickstarts" task in samples pipeline run would fail as it runs on the main branch of Radius which doesn't have the latest changes as Radius PR is blocked on the samples PR for bicep files update._) You need to have a repo admin force merge the samples PR.
4. **Radius Repository**: After the PRs from the bicep, docs and samples repositories are merged, re-run the checks to make sure there are no failures to merge the Radius PR.
```bash
make generate
```
1. `cd` into the `hack/bicep-types-radius/generated` folder
1. Run `bicep publish-provider <file> --target <ref>` to upload the schema changes to your OCI registry. The file uploaded will be the `index.json` file as it contains all references to the types schema.
```bash
bicep publish-extension index.json --target <OCI-registry-endpoint>
```
## Step 4: Update the `bicepconfig.json` to use your newly published types
1. Update the `bicepconfig.json` file in the root folder to reference your new published types.
```json
{
"experimentalFeaturesEnabled": {
"extensibility": true,
"extensionRegistry": true,
"dynamicTypeLoading": true
},
"extensions": {
"radius": "br:<OCI-registry-endpoint>",
"aws": "br:<OCI-registry-endpoint>"
}
}
```
1. Once Bicep restores the new extensions, you should be able to use the new schema changes in your Bicep templates.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can find the functional tests under `./test/functional`. A functional test (
These tests verify whether:

- That Radius Environment can be created successfully.
- That Bicep templates of sample applications ca be deployed to the Radius Environment.
- That Bicep templates of sample applications can be deployed to the Radius Environment.

## Running via GitHub workflow

Expand Down
1 change: 0 additions & 1 deletion docs/contributing/contributing-releases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

Each release belongs to a *channel* named `<major>.<minor>`. Releases will only interact with assets from their channel. For example, the `0.1` `rad` CLI will:

- Download `rad-bicep` from the `0.1` channel
- Create an environment using the `0.1` version of the RP and environment setup script

> ⚠️ Compatibility ⚠️
Expand Down
Loading

0 comments on commit 06d334a

Please sign in to comment.