-
Notifications
You must be signed in to change notification settings - Fork 85
171 lines (158 loc) · 5.89 KB
/
build.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
---
name: build
on:
push:
branches:
- master
- renovate/**
paths-ignore:
- "**.md"
- "img/**"
- "test/**"
- ".gitignore"
- "docker/**"
- "helm/**"
- "renovate.json"
- ".krew.yaml"
pull_request:
branches:
- master
paths-ignore:
- "**.md"
- "img/**"
- "test/**"
- ".gitignore"
- "docker/**"
- "helm/**"
- "renovate.json"
- ".krew.yaml"
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
- name: Install go
uses: actions/setup-go@v4.1.0
with:
go-version-file: go.mod
- name: Ensure go.mod is already tidied
run: go mod tidy && git diff --no-patch --exit-code
- name: Run linters
uses: golangci/golangci-lint-action@v3.7.0
with:
# renovate: depName=golangci/golangci-lint datasource=github-releases
version: v1.54.1
args: --timeout=10m0s
- name: Build with Goreleaser
if: ${{ always() }}
uses: goreleaser/goreleaser-action@v4.4.0
with:
# renovate: depName=goreleaser/goreleaser datasource=github-releases
version: v1.20.0
args: build --snapshot --clean --single-target
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
- name: Install go
uses: actions/setup-go@v4.1.0
with:
go-version-file: go.mod
- name: Install richgo
# renovate: depName=kyoh86/richgo
run: go install github.com/kyoh86/richgo@v0.3.12
- name: Install helm
run: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Install cilium-cli
env:
# renovate: depName=cilium/cilium-cli datasource=github-releases
CILIUM_CLI_VERSION: v0.15.5
run: |
wget https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-amd64.tar.gz
sudo tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin
rm cilium-linux-amd64.tar.gz
- name: kind-1 - Create cluster
uses: helm/kind-action@v1.8.0
with:
cluster_name: kind-1
# renovate: depName=kubernetes-sigs/kind datasource=github-releases
version: v0.20.0
config: test/kind-config.yaml
- name: kind-1 - Create metallb-system namespace
run: kubectl create namespace metallb-system --dry-run=client -oyaml | kubectl apply -f -
- name: kind-1 - Install allow-all network policies on system namespaces
run: |
kubectl -n kube-system apply -f test/netpol-allow-all.yaml
kubectl -n local-path-storage apply -f test/netpol-allow-all.yaml
kubectl -n metallb-system apply -f test/netpol-allow-all.yaml
- name: kind-1 - Install Cilium with default-deny policy
run: cilium install --set policyEnforcementMode=always
- name: kind-1 - Install MetalLB
env:
# renovate: depName=metallb datasource=helm registryUrl=https://charts.bitnami.com/bitnami
METALLB_CHART_VERSION: 4.6.4
run: |
MANIFESTS_PATH=/tmp/metallb-manifests.yaml
ADDRESS_RANGE_PREFIX=$(docker network inspect -f '{{(index .IPAM.Config 0).Subnet}}' kind | cut -d. -f1-3)
export ADDRESS_RANGE=${ADDRESS_RANGE_PREFIX}.240-${ADDRESS_RANGE_PREFIX}.255
envsubst < test/metallb-manifests.yaml > $MANIFESTS_PATH
helm repo add bitnami https://charts.bitnami.com/bitnami
helm upgrade metallb \
--install bitnami/metallb \
--namespace metallb-system \
--version ${METALLB_CHART_VERSION} \
--atomic \
--set networkPolicy.enabled=true
helm -n metallb-system get values metallb
echo "MetalLB rendered manifests:"
cat $MANIFESTS_PATH
kubectl apply -f $MANIFESTS_PATH
- name: kind-1 - Wait for all pods in the cluster to be ready
run: |
for i in $(seq 1 10); do
echo "Attempt: $i"
kubectl wait pod --for=condition=Ready --all --all-namespaces && break;
sleep 5;
done
- name: kind-2 - Create cluster
uses: helm/kind-action@v1.8.0
env:
KUBECONFIG: /home/runner/.kube/kind-2.yaml
with:
cluster_name: kind-2
# renovate: depName=kubernetes-sigs/kind datasource=github-releases
version: v0.20.0
config: test/kind-config.yaml
- name: kind-2 - Install allow-all network policies on system namespaces
env:
KUBECONFIG: /home/runner/.kube/kind-2.yaml
run: |
kubectl -n kube-system apply -f test/netpol-allow-all.yaml
kubectl -n local-path-storage apply -f test/netpol-allow-all.yaml
- name: kind-2 - Install Cilium with default-deny policy
env:
KUBECONFIG: /home/runner/.kube/kind-2.yaml
run: cilium install --set policyEnforcementMode=always
- name: kind-2 - Wait for all pods in the cluster to be ready
env:
KUBECONFIG: /home/runner/.kube/kind-2.yaml
run: |
for i in $(seq 1 10); do
echo "Attempt: $i"
kubectl wait pod --for=condition=Ready --all --all-namespaces && break;
sleep 5;
done
- name: Run tests
env:
RICHGO_FORCE_COLOR: "1"
PVMIG_TEST_EXTRA_KUBECONFIG: /home/runner/.kube/kind-2.yaml
run: richgo test -tags integration -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic -timeout 20m -v ./...
- name: Send coverage
uses: codecov/codecov-action@v3.1.4
with:
files: coverage.txt