-
Notifications
You must be signed in to change notification settings - Fork 235
165 lines (151 loc) · 5.95 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
name: build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
new:
runs-on: ubuntu-latest
name: Testing New Projects
steps:
- name: Set up Golang
uses: actions/[email protected]
with:
go-version: 1.21
- uses: actions/[email protected]
with:
path: go/src/sigs.k8s.io/apiserver-builder-alpha/
- name: Install
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/
env:
GOPATH: ${{ github.workspace }}/go
run: |
make install
- name: Testing on new project
env:
GOBIN: ${{ github.workspace }}/go/bin
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/
run: |
export PATH=${PATH}:${GOBIN}
export TESTDIR=$(mktemp -d)
make test -f Makefile.test
diff -rq --exclude=bin ./test/golden $TESTDIR
basic-example-build:
runs-on: ubuntu-latest
name: Testing Basic Example
steps:
- name: Set up Golang
uses: actions/[email protected]
with:
go-version: 1.17
- name: Install controller-tools
env:
GO111MODULE: on
run: |
go mod init sigs.k8s.io/workspace
go get sigs.k8s.io/controller-tools/cmd/[email protected]
go install sigs.k8s.io/controller-tools/cmd/controller-gen
- uses: actions/[email protected]
with:
path: go/src/sigs.k8s.io/apiserver-builder-alpha/
- name: Testing on examples
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/example/basic
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
run: |
controller-gen +object +paths=./pkg/apis/...
export PATH=${PATH}:${GOBIN}
go test ./pkg/...
basic-example-container:
runs-on: ubuntu-latest
name: Testing Basic Example Container Build
steps:
- name: Set up Golang
uses: actions/[email protected]
with:
go-version: 1.17
- uses: actions/[email protected]
with:
path: go/src/sigs.k8s.io/apiserver-builder-alpha/
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Install apiserver-boot
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/
env:
GOPATH: ${{ github.workspace }}/go
run: |
make install
- name: Install controller-tools
env:
GO111MODULE: on
run: |
go mod init sigs.k8s.io/workspace
go get sigs.k8s.io/controller-tools/cmd/[email protected]
go install sigs.k8s.io/controller-tools/cmd/controller-gen
- name: Building and running container images
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/example/basic
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
run: |
export PATH=${PATH}:${GOBIN}
controller-gen +object +paths=./pkg/apis/...
export IMAGE="example.io/basic"
apiserver-boot build container --image ${IMAGE}
kind load docker-image ${IMAGE} --name chart-testing
kubectl create -f config/
kubectl wait --for=condition=Available --timeout=180s apiservice/v1.kingsport.k8s.io
kubectl create -f sample/festival.yaml
sleep 20 # Hold for a while
kubectl get festival festival-example -o jsonpath="{.spec.invited}" | grep 1 # successfully processed by controller
kubectl create -f sample/university.yaml
kubectl get university university-example -o jsonpath="{.spec.facultySize}" | grep 1
kubectl replace --raw="/apis/miskatonic.k8s.io/v1beta1/namespaces/default/universities/university-example/scale" -f sample/university_scale.json # scale subresource
kubectl get university university-example -o jsonpath="{.spec.facultySize}" | grep 2
apiserver-boot show resource festivals
kine-example-container:
runs-on: ubuntu-latest
name: Testing Kine Example Container Build
steps:
- name: Set up Golang
uses: actions/[email protected]
with:
go-version: 1.17
- uses: actions/[email protected]
with:
path: go/src/sigs.k8s.io/apiserver-builder-alpha/
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Install apiserver-boot
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/
env:
GOPATH: ${{ github.workspace }}/go
run: |
mkdir -p bin
make install
- name: Install controller-tools
env:
GO111MODULE: on
run: |
go mod init sigs.k8s.io/workspace
go get sigs.k8s.io/controller-tools/cmd/[email protected]
go install sigs.k8s.io/controller-tools/cmd/controller-gen
- name: Building and running container images
working-directory: ${{ github.workspace }}/go/src/sigs.k8s.io/apiserver-builder-alpha/example/kine
env:
GOPATH: ${{ github.workspace }}/go
GOBIN: ${{ github.workspace }}/go/bin
run: |
export PATH=${PATH}:${GOBIN}
controller-gen +object +paths=./pkg/apis/...
export IMAGE="example.io/kine"
apiserver-boot build container --image ${IMAGE}
kind load docker-image ${IMAGE} --name chart-testing
kubectl create -f config/
kubectl wait --for=condition=Available --timeout=180s apiservice/v1.mysql.example.com
kubectl create -f sample/tiger.yaml
apiserver-boot show resource tigers
sleep 20 # Hold for a while
kubectl get tiger tiger-example -o jsonpath="{.status.hungry}" | grep "true" # successfully processed by controller