-
Notifications
You must be signed in to change notification settings - Fork 113
209 lines (199 loc) · 6.73 KB
/
ci.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
202
203
204
205
206
207
208
209
name: Unit, Integration, and E2E Tests
on:
pull_request:
branches:
- main
push:
paths-ignore:
- 'README.md'
- 'docs/**'
branches:
- main
jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
cache: true
check-latest: true
- name: Build
run: make build
- name: Test
run: make test-unit-coverage
test-docker-build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 4
matrix:
image:
- base
- git
- image-processing
- waiter
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to container registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.repository_owner }} --password-stdin ghcr.io
- name: Build Image
working-directory: images/${{ matrix.image }}
run: |
NAMESPACE=$(tr '[:upper:]' '[:lower:]' <<<${{ github.repository_owner }})
IMAGE=test-build/base-${{ matrix.image }} NAMESPACE="${NAMESPACE}" docker buildx bake --file ../docker-bake.hcl
integration:
strategy:
fail-fast: false
matrix:
kubernetes:
- v1.24.15
- v1.25.11
max-parallel: 2
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
cache: true
check-latest: true
- name: Install Ko
uses: ko-build/[email protected]
with:
version: v0.13.0
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ matrix.kubernetes }}
- name: Create kind cluster
uses: helm/kind-action@v1
with:
version: v0.20.0
node_image: kindest/node:${{ matrix.kubernetes }}
cluster_name: kind
wait: 120s
- name: Verify kind cluster
run: |
echo "# Using KinD context..."
kubectl config use-context "kind-kind"
echo "# KinD nodes:"
kubectl get nodes
NODE_STATUS=$(kubectl get node kind-control-plane -o json | jq -r .'status.conditions[] | select(.type == "Ready") | .status')
if [ "${NODE_STATUS}" != "True" ]; then
echo "# Node is not ready:"
kubectl describe node kind-control-plane
echo "# Pods:"
kubectl get pod -A
echo "# Events:"
kubectl get events -A
exit 1
fi
- name: Install Tekton
run: |
make kind-tekton
kubectl -n tekton-pipelines rollout status deployment tekton-pipelines-controller --timeout=1m
kubectl -n tekton-pipelines rollout status deployment tekton-pipelines-webhook --timeout=1m
- name: Test
run: |
export GIT_CONTAINER_IMAGE="$(KO_DOCKER_REPO=kind.local ko publish ./cmd/git)"
make test-integration
e2e:
strategy:
fail-fast: false
matrix:
kubernetes:
- v1.24.15
- v1.25.11
max-parallel: 2
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.20.x'
cache: true
check-latest: true
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ matrix.kubernetes }}
- name: Create kind cluster
uses: helm/kind-action@v1
with:
version: v0.20.0
node_image: kindest/node:${{ matrix.kubernetes }}
cluster_name: kind
config: test/kind/config.yaml
wait: 120s
- name: Verify kind cluster
run: |
echo "# Using KinD context..."
kubectl config use-context "kind-kind"
echo "# KinD nodes:"
kubectl get nodes
NODE_STATUS=$(kubectl get node kind-control-plane -o json | jq -r .'status.conditions[] | select(.type == "Ready") | .status')
if [ "${NODE_STATUS}" != "True" ]; then
echo "# Node is not ready:"
kubectl describe node kind-control-plane
echo "# Pods:"
kubectl get pod -A
echo "# Events:"
kubectl get events -A
exit 1
fi
- name: Install Tekton
run: |
make kind-tekton
kubectl -n tekton-pipelines rollout status deployment tekton-pipelines-controller --timeout=1m
kubectl -n tekton-pipelines rollout status deployment tekton-pipelines-webhook --timeout=1m
- name: Install Registry
run: |
kubectl apply -f test/data/registry.yaml
kubectl -n registry rollout status deployment registry --timeout=1m
- name: Install Ko
uses: ko-build/[email protected]
with:
version: v0.13.0
- name: Install Shipwright Build
run: |
make install-controller-kind
kubectl -n shipwright-build rollout status deployment shipwright-build-controller --timeout=1m || true
kubectl -n shipwright-build rollout status deployment shipwright-build-webhook --timeout=1m || true
- name: Test
run: |
kubectl create namespace shp-e2e
export TEST_NAMESPACE=shp-e2e
export TEST_IMAGE_REPO=registry.registry.svc.cluster.local:32222/shipwright-io/build-e2e
export TEST_IMAGE_REPO_INSECURE=true
export TEST_E2E_TIMEOUT_MULTIPLIER=2
make test-e2e
- name: Build controller logs
if: ${{ failure() }}
run: |
echo "# Pods:"
kubectl -n shipwright-build get pod
PODS=$(kubectl -n shipwright-build get pod -o json)
POD_NAME=$(echo "${PODS}" | jq -r '.items[] | select(.metadata.name | startswith("shipwright-build-controller-")) | .metadata.name')
if [ "${POD_NAME}" != "" ]; then
RESTART_COUNT=$(echo "${PODS}" | jq -r ".items[] | select(.metadata.name == \"${POD_NAME}\") | .status.containerStatuses[0].restartCount")
if [ "${RESTART_COUNT}" != "0" ]; then
echo "# Previous logs:"
kubectl -n shipwright-build logs "${POD_NAME}" --previous || true
fi
echo "# Logs:"
kubectl -n shipwright-build logs "${POD_NAME}"
else
echo "# Pod is missing, there are no logs to retrieve, bailing out..."
fi