-
Notifications
You must be signed in to change notification settings - Fork 13
201 lines (179 loc) · 6.79 KB
/
playwright.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Playwright Tests
on:
workflow_dispatch:
inputs:
rancher:
description: Rancher version
type: choice
default: 'released'
options:
- 'released'
- '= 2.7.8'
- '= 2.7.9'
- '> 2.8.0-0 < 2.8.1-0'
kubewarden:
description: Kubewarden version
type: choice
default: 'rc'
required: true
options:
- source
- rc
- released
testsuite:
description: Testsuite
type: choice
default: 'install'
required: true
options:
- install (15 min)
- install + policies (15+30 min)
policyfilter:
description: Policy Filter
type: string
k3s:
description: Kubernetes
type: choice
default: 'v1.26.9-k3s1'
required: true
options:
- v1.25.14-k3s1
- v1.26.9-k3s1
- v1.27.6-k3s1
- v1.28.2-k3s1
pull_request:
branches: main
paths: pkg/kubewarden/**
push:
tags:
- '*'
schedule:
- cron: "0 2 * * *"
env:
RANCHER: ${{ vars.RANCHER || 'released' }}
K3S_VERSION: ${{ inputs.k3s || 'v1.26.9-k3s1' }}
K3D_CLUSTER_NAME: ${{ github.repository_owner }}-${{ github.event.repository.name }}-runner
jobs:
e2e:
# run schedule workflows only on original repo, not forks
if: github.repository_owner == 'rancher' || github.event_name != 'schedule'
runs-on: self-hosted
steps:
# ==================================================================================================
# Check out code and install requirements
- uses: actions/checkout@v3
- uses: azure/setup-kubectl@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install playwright
working-directory: tests
run: |
yarn
yarn playwright install chromium # --with-deps
# ==================================================================================================
# Set up parameters and ENV
- name: Setup global ENV
run: |
case ${{github.event_name}} in
pull_request)
KUBEWARDEN=source
TESTSUITE=install
;;
schedule)
KUBEWARDEN=released
TESTSUITE=policies
;;
workflow_dispatch)
RANCHER="${{ inputs.rancher }}"
KUBEWARDEN="${{ inputs.kubewarden }}"
TESTSUITE="${{ inputs.testsuite }}"
;;
push)
KUBEWARDEN=rc
TESTSUITE=policies
esac
echo "Event: ${{github.event_name}}"
echo RANCHER="$RANCHER" | tee -a $GITHUB_ENV
echo KUBEWARDEN="$KUBEWARDEN" | tee -a $GITHUB_ENV
echo TESTSUITE="$TESTSUITE" | tee -a $GITHUB_ENV
# ==================================================================================================
# Create k3d cluster and install rancher
- name: "Create kubernetes cluster"
uses: AbsaOSS/[email protected]
with:
cluster-name: ${{ env.K3D_CLUSTER_NAME }}
args: "--agents 1 --image rancher/k3s:${{ env.K3S_VERSION }}"
- name: Install Rancher
run: |
RANCHER_FQDN=$(k3d cluster list ${{ env.K3D_CLUSTER_NAME }} -o json | jq -r '[.[].nodes[] | select(.role == "server").IP.IP] | first').nip.io
# Wait for kube-system
for i in {1..20}; do
output=$(kubectl get pods --no-headers -o wide -n kube-system | grep -vw Completed || echo 'Fail')
grep -vE '([0-9]+)/\1 +Running' <<< $output || break
[ $i -ne 20 ] && sleep 10 || { echo "Godot: pods not running"; exit 1; }
done
# Wait for cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml
kubectl wait --for=condition=Available deployment --timeout=2m -n cert-manager --all
# Translate to sematic version
[ "$RANCHER" == "released" ] && RANCHER='*'
# Rancher PSP is based on kubernetes version
RANCHER_PSP=$(kubectl version -o json | jq -r '.serverVersion.minor <= "24"')
helm repo add --force-update rancher-latest https://releases.rancher.com/server-charts/latest
helm search repo rancher-latest/rancher ${RANCHER:+--version "$RANCHER"}
helm upgrade --install rancher rancher-latest/rancher --wait \
--namespace cattle-system --create-namespace \
--set hostname=$RANCHER_FQDN \
--set bootstrapPassword=sa \
--set global.cattle.psp.enabled=$RANCHER_PSP \
${RANCHER:+--version "$RANCHER"}
# Wait for rancher
for i in {1..20}; do
output=$(kubectl get pods --no-headers -o wide -n cattle-system -l app=rancher-webhook | grep -vw Completed || echo 'Wait: cattle-system')$'\n'
output+=$(kubectl get pods --no-headers -o wide -n cattle-system | grep -vw Completed || echo 'Wait: cattle-system')$'\n'
output+=$(kubectl get pods --no-headers -o wide -n cattle-fleet-system | grep -vw Completed || echo 'Wait: cattle-fleet-system')$'\n'
grep -vE '([0-9]+)/\1 +Running|^$' <<< $output || break
[ $i -ne 20 ] && sleep 30 || { echo "Godot: pods not running"; exit 1; }
done
echo "RANCHER_FQDN=$RANCHER_FQDN" | tee -a $GITHUB_ENV
# ==================================================================================================
# Setup playwright ENV and run tests
# https://rancher.github.io/dashboard/testing/e2e-test#setup-for-local-tests
- name: Build Kubewarden extension
if: env.KUBEWARDEN == 'source'
run: |
yarn install --ignore-engines
VERSION=0.0.1 yarn build-pkg kubewarden
- name: Install Kubewarden
working-directory: tests
run: |
yarn playwright test "/[0-9]0-" -x
env:
RANCHER_URL: https://${{env.RANCHER_FQDN}}
ORIGIN: ${{ env.KUBEWARDEN }}
PLAYWRIGHT_HTML_REPORT: installation-report
- name: Install policies
if: ${{ contains(env.TESTSUITE, 'policies') || inputs.policyfilter }}
timeout-minutes: 90
working-directory: tests
run: |
yarn playwright test /policies -g "${{ inputs.policyfilter || '' }}" -x
env:
RANCHER_URL: https://${{env.RANCHER_FQDN}}
ORIGIN: ${{ env.KUBEWARDEN }}
PLAYWRIGHT_HTML_REPORT: policies-report
# ==================================================================================================
# Artifacts & Summary
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: |
tests/installation-report/
tests/policies-report/
retention-days: 30
- name: Clean Up
if: always()
run: |
k3d cluster delete ${{ env.K3D_CLUSTER_NAME }}