-
Notifications
You must be signed in to change notification settings - Fork 10
134 lines (115 loc) · 4.34 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
on:
workflow_call: {}
workflow_dispatch:
inputs:
debug_unit:
description: "start tmate before unit tests"
type: boolean
required: false
default: false
debug_e2e:
description: "start tmate before e2e tests"
type: boolean
required: false
default: false
jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: load env vars for workflow run
run: |
source .github/vars.env
echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV"
echo "DEVSPACE_VERSION=$DEVSPACE_VERSION" >> "$GITHUB_ENV"
echo "GCI_VERSION=$GCI_VERSION" >> "$GITHUB_ENV"
echo "GOFUMPT_VERSION=$GOFUMPT_VERSION" >> "$GITHUB_ENV"
echo "GOLANGCI_LINT_VERSION=$GOLANGCI_LINT_VERSION" >> "$GITHUB_ENV"
echo "GOLINES_VERSION=$GOLINES_VERSION" >> "$GITHUB_ENV"
echo "GOTESTSUM_VERSION=$GOTESTSUM_VERSION" >> "$GITHUB_ENV"
echo "HELM_VERSION=$HELM_VERSION" >> "$GITHUB_ENV"
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_unit }}
- name: run the unit tests
run: make test-race
e2e:
runs-on: ubuntu-latest
needs:
- unit
# run e2e on main or prs pointing to main
if: (github.ref_name == 'main' || github.base_ref == 'main') || (github.event_name == 'workflow_dispatch' && inputs.debug_e2e)
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: load env vars for workflow run
run: |
source .github/vars.env
echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV"
echo "DEVSPACE_VERSION=$DEVSPACE_VERSION" >> "$GITHUB_ENV"
echo "GCI_VERSION=$GCI_VERSION" >> "$GITHUB_ENV"
echo "GOFUMPT_VERSION=$GOFUMPT_VERSION" >> "$GITHUB_ENV"
echo "GOLANGCI_LINT_VERSION=$GOLANGCI_LINT_VERSION" >> "$GITHUB_ENV"
echo "GOLINES_VERSION=$GOLINES_VERSION" >> "$GITHUB_ENV"
echo "GOTESTSUM_VERSION=$GOTESTSUM_VERSION" >> "$GITHUB_ENV"
echo "HELM_VERSION=$HELM_VERSION" >> "$GITHUB_ENV"
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: install devspace
run: |
curl -L -o devspace \
"https://github.com/loft-sh/devspace/releases/download/${{ env.DEVSPACE_VERSION}}/devspace-linux-amd64" &&
install -c -m 0755 devspace /usr/local/bin
working-directory: /tmp
- name: spin up kind cluster
uses: helm/[email protected]
- name: verify kind cluster
run: |
set -x
kubectl cluster-info
kubectl get pods -A
- name: deploy clabernetes
run: devspace run deploy --profile debug
- name: setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_e2e }}
- name: wait for clabernetes
run: |
kubectl rollout status deployment clabernetes-manager -n clabernetes
- name: run the e2e tests
id: run-the-e2e-tests
run: make test-e2e
continue-on-error: true
- name: dump logs from controller if tests fail
if: steps.run-the-e2e-tests.outcome != 'success'
run: |
set -x
kubectl get pods -n clabernetes -o yaml
echo "********************************"
echo "**** events ****"
echo "********************************"
kubectl get events -n clabernetes --sort-by='.lastTimestamp'
echo "********************************"
echo "**** logs ****"
echo "********************************"
kubectl logs -l clabernetes/name=clabernetes-manager -n clabernetes --tail=-1
exit 1