-
Notifications
You must be signed in to change notification settings - Fork 5
168 lines (142 loc) · 4.69 KB
/
test.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
name: test
on:
pull_request:
push:
branches:
- main
jobs:
path-filter:
outputs:
go: ${{steps.changes.outputs.go}}
e2e: ${{steps.changes.outputs.e2e}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
go:
- '**.go'
- 'go.*'
- .github/workflows/test.yml
e2e:
- Dockerfile
- .github/workflows/test.yml
- config/crd/**
- tests/e2e/**
- internal/**
- '**.go'
- 'go.*'
- kuttl-test.yaml
- skaffold.yaml
status-check:
runs-on: ubuntu-latest
needs:
- lint
- test
- e2e-kuttl
- e2e-ginkgo
permissions: {}
if: failure()
steps:
- run: exit 1
lint:
needs: path-filter
if: needs.path-filter.outputs.go == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: golangci-lint command line arguments.
args: --timeout=3m # --issues-exit-code=0
test:
needs: path-filter
if: needs.path-filter.outputs.go == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- run: |
make test
cat cover.out >> coverage.txt
- name: codecov
uses: codecov/codecov-action@v5
e2e-kuttl:
needs: path-filter
if: needs.path-filter.outputs.e2e == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
# https://krew.sigs.k8s.io/docs/user-guide/setup/install/
- name: krew - install
run: |
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path
- name: krew - set PATH
run: echo "${KREW_ROOT:-$HOME/.krew}/bin:$PATH" >> "$GITHUB_PATH"
# https://kuttl.dev/docs/cli.html#setup-the-kuttl-kubectl-plugin
- name: kuttl - install
run: |
kubectl krew install kuttl
kubectl kuttl -v
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build with gha
uses: docker/build-push-action@v6
with:
context: .
push: false # a shorthand for --output=type=registry if set to true
load: true # a shorthand for --output=type=docker if set to true
tags: mysql-operator:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: kuttl test
run: make kuttl
e2e-ginkgo:
needs: path-filter
if: needs.path-filter.outputs.e2e == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
cache: true
- name: install skaffold # TODO: #69 Enable to install skaffold in e2e
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: create kind cluster
working-directory: e2e
run: kind create cluster --name mysql-operator-e2e --kubeconfig kubeconfig --config kind-config.yml --wait 30s
- name: skaffold run
working-directory: e2e
run: skaffold run --kubeconfig kubeconfig
- name: e2e-with-ginkgo
run: make e2e-with-ginkgo