-
Notifications
You must be signed in to change notification settings - Fork 14
134 lines (130 loc) · 5.27 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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: sqldatabases
app: dsrp-resources-sqldb-recipe
namespace: dsrp-resources-sqldb-recipe-app
path: ./tests/sqldatabases.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