-
Notifications
You must be signed in to change notification settings - Fork 17
152 lines (133 loc) · 4.95 KB
/
e2e-tests.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
name: End-to-end tests
on:
workflow_dispatch:
inputs:
mode:
type: choice
description: Test mode
options:
- install
- upgrade
version:
description: App version [local|next|prev|v1.17.0]
required: true
default: local
CONTROLLER_ARGS:
description: Controller helm flags
DEFAULTS_ARGS:
description: Defaults helm flags
LATEST:
description: Use latest images
type: boolean
default: false
K3S_VERSION:
description: K3S version
type: choice
default: 'v1.30'
options:
- v1.25
- v1.26
- v1.27
- v1.28
- v1.29
- v1.30
- v1.31
# PR: install + tests from PR
pull_request:
branches:
- "main"
# Nightly:
# - install from main with latest images (to check if we can tag and release)
# - install tagged charts (refrence job to make sure product works, most stable case)
schedule:
- cron: '0 21 * * *'
# Release (stable, rc, beta):
# - install release
# - upgrade from previous stable to this release
# - install on oldest supported k8s
workflow_run:
workflows: ["Release helm chart"]
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
K3D_VERSION: # 'v5.6.3' - optionally pin version
K3D_CLUSTER_NAME: ${{ github.repository_owner }}-${{ github.event.repository.name }}-runner
jobs:
e2e:
strategy:
fail-fast: false
matrix:
mode: ${{
(github.event_name == 'workflow_run') && fromJSON('["install", "upgrade"]') ||
(github.event_name == 'schedule') && fromJSON('["install"]') ||
(github.event_name == 'pull_request') && fromJSON('["install"]') ||
fromJSON(format('["{0}"]', inputs.mode || 'install')) }}
version: ${{
(github.event_name == 'workflow_run') && fromJSON('["next"]') ||
(github.event_name == 'schedule') && fromJSON('["local", "next"]') ||
(github.event_name == 'pull_request') && fromJSON('["local"]') ||
fromJSON(format('["{0}"]', inputs.version || 'local')) }}
k3s: ${{ (github.event_name == 'workflow_run') && fromJSON('["k3d", "1.25"]') || fromJSON(format('["{0}"]', inputs.K3S_VERSION || 'k3d' )) }}
exclude:
- k3s: ${{ (github.event_name == 'workflow_run') && '1.25' }}
mode: upgrade
# Run schedule workflows only on original repo, not forks
if: (github.event_name != 'schedule' || github.repository_owner == 'kubewarden') &&
(github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
if: ${{ matrix.version == 'local' }}
- run: helm repo add kubewarden https://charts.kubewarden.io
if: ${{ matrix.version != 'local' }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: ${{ github.repository_owner }}/kubewarden-end-to-end-tests
path: e2e-tests
submodules: 'true'
- name: "Install kwctl"
uses: kubewarden/github-actions/kwctl-installer@main
with:
KWCTL_VERSION: latest
- run: sudo npm install -g bats
- name: "Create k3d cluster"
run: |
wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${{ env.K3D_VERSION }} sudo --preserve-env=TAG bash
# Use k3d as placehoholder for default (empty) k3s version
[[ "${{ matrix.k3s }}" != "k3d" ]] && export K3S=${{ matrix.k3s }}
make --directory e2e-tests cluster
env:
CLUSTER_NAME: ${{ env.K3D_CLUSTER_NAME }}
- name: Install previous kubewarden
if: ${{ matrix.mode == 'upgrade' }}
working-directory: ./e2e-tests
run: VERSION=prev REPO_NAME=kubewarden CHARTS_LOCATION=kubewarden make install
env:
CLUSTER_NAME: ${{ env.K3D_CLUSTER_NAME }}
- name: Install kubewarden and run tests
working-directory: ./e2e-tests
run: |
# Additional environment setup
[[ "${{ matrix.version }}" == 'local' ]] && CHARTS_LOCATION=../charts || CHARTS_LOCATION=kubewarden
[[ "${{ github.event_name }}" == 'schedule' && "${{ matrix.version }}" == 'local' ]] && LATEST=true
export CHARTS_LOCATION LATEST
make ${{ matrix.mode }} tests audit-scanner-installation.bats
./scripts/helmer.sh debug
make uninstall
env:
CLUSTER_NAME: ${{ env.K3D_CLUSTER_NAME }}
VERSION: ${{ matrix.version }}
LATEST: ${{ inputs.LATEST }}
DEFAULTS_ARGS: ${{ inputs.DEFAULTS_ARGS }}
CONTROLLER_ARGS: ${{ inputs.CONTROLLER_ARGS }}
- name: Clean Up
if: always()
run: make --directory e2e-tests clean
env:
CLUSTER_NAME: ${{ env.K3D_CLUSTER_NAME }}