Skip to content

Adding test workflow #34

Adding test workflow

Adding test workflow #34

Workflow file for this run

name: Test Recipes
on:
workflow_dispatch:
inputs:
version:
description: 'Radius version number to use (e.g. 0.1.0, 0.1.0-rc1, edge). Defaults to edge.'
required: false
default: 'edge'
type: string
push:
branches:
- v*.*
- edge
paths:
- "local-dev/**"
- ".github/workflows/**"
pull_request:
types: [opened, synchronize, reopened]
env:
RUN_IDENTIFIER: recipestest-${{ github.run_id }}-${{ github.run_attempt }}
jobs:
test:
name: "Recipe tests"
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
include:
# - name: mongodatabases
# app: dsrp-resources-mongodb-recipe
# namespace: dsrp-resources-mongodb-recipe-app
# path: ./tests/mongodatabases.bicep
# args: --parameters magpieimage="radiusdev.azurecr.io/magpiego:latest"
# - name: rediscaches
# app: dsrp-resources-redis-recipe
# namespace: dsrp-resources-redis-recipe-app
# path: ./tests/rediscaches.bicep
# args: --parameters magpieimage="radiusdev.azurecr.io/magpiego:latest"
- name: rabbitmqqueues
app: msgrp-resources-rabbitmq-recipe
namespace: msgrp-resources-rabbitmq-default-recipe-app
path: ./tests/rabbitmqqueues.bicep
args: --parameters magpieimage="radiusdev.azurecr.io/magpiego:latest"
- name: secretstores
app: daprrp-rs-secretstore-recipe
namespace: daprrp-rs-secretstore-recipe
path: ./tests/secretstores.bicep
args: --parameters magpieimage="radiusdev.azurecr.io/magpiego:latest"
steps:
- name: Generate output variables
id: gen-id
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
RUN_TEST=true
else
RUN_TEST=true
fi
# Set output variables to be used in the other jobs
echo "RUN_IDENTIFIER=${RUN_IDENTIFIER}" >> $GITHUB_OUTPUT
echo "RUN_TEST=${RUN_TEST}" >> $GITHUB_OUTPUT
- name: Checkout code
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/checkout@v3
- name: Setup Node
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
- name: Download k3d
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
- name: Create k3d cluster
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: k3d cluster create --agents 2 -p "80:80@loadbalancer" --k3s-arg "--disable=traefik@server:0" --registry-create reciperegistry:51351
- name: Install Dapr
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
helm repo add dapr https://dapr.github.io/helm-charts/
helm install dapr dapr/dapr --version=1.6 --namespace dapr-system --create-namespace --wait
- name: Download rad CLI
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
RADIUS_VERSION="${{ inputs.version }}"
if [[ -z "${{ inputs.version }}" ]]; then
RADIUS_VERSION=edge
fi
chmod +x ./.github/scripts/install-radius.sh
./.github/scripts/install-radius.sh $RADIUS_VERSION
- name: Publish Recipes
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
files_list=$(ls "local-dev")
for file in $files_list; do
echo "Publishing recipe: local-dev/$file"
recipeName="${file%.*}"
rad bicep publish --file local-dev/$file --target br:localhost:51351/recipes/local-dev/$recipeName:latest --plain-http
done
- name: Initialize default environment
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
rad install kubernetes --set rp.publicEndpointOverride=localhost
rad group create default
rad workspace create kubernetes default --group default
rad group switch default
rad env create default
rad env switch default
- name: Running local-dev recipe Tests
if: steps.gen-id.outputs.RUN_TEST == 'false'
run: |
files_list=$(ls "tests")
for file in $files_list; do
testFile=tests/$file
echo "Deploying bicep file $testFile"
rad deploy $testFile --parameters magpieimage="radiusdev.azurecr.io/magpiego:latest"
echo "==========================="
done
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: rad deploy ${{ matrix.path }} ${{ matrix.args }}
- name: Wait for all pods to be ready
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: wait-for-pods
run: |
label="radapp.io/application=${{ matrix.app }}"
kubectl wait --for=condition=Ready pod -l $label -n ${{ matrix.namespace }} --timeout=5m