Skip to content

Commit f71785e

Browse files
authored
feat: support schemas and refactoring to db-controller (#50)
* feat: support schemas * fix: alignements * fix: merge * fix: merge * fix: setupenvtest version kubernetes-sigs/controller-runtime#2744 * fix: lint
1 parent ffdd11f commit f71785e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1134
-1107
lines changed

.github/workflows/main.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Harden Runner
13+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
14+
with:
15+
egress-policy: audit
1216
- name: Checkout
13-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
17+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3
1418
- name: Setup Go
1519
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
1620
with:

.github/workflows/pr-build.yaml

Lines changed: 165 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,55 @@ on:
88
- reopened
99

1010
jobs:
11-
build:
11+
lint-chart:
1212
runs-on: ubuntu-latest
13-
outputs:
14-
profiles: ${{ steps.profiles.outputs.matrix }}
1513
steps:
14+
- name: Harden Runner
15+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
16+
with:
17+
egress-policy: audit
1618
- name: Checkout
17-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
19+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Helm
24+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
25+
with:
26+
version: v3.4.0
27+
28+
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
29+
with:
30+
python-version: 3.7
31+
32+
- name: Set up chart-testing
33+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
34+
35+
- name: Run chart-testing (list-changed)
36+
id: list-changed
37+
run: |
38+
changed=$(ct list-changed --target-branch=master --chart-dirs chart)
39+
if [[ -n "$changed" ]]; then
40+
echo "::set-output name=changed::true"
41+
fi
42+
- name: Run chart-testing (lint)
43+
run: ct lint --target-branch=master --chart-dirs chart --check-version-increment=false
44+
45+
fmt:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Harden Runner
49+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
50+
with:
51+
egress-policy: audit
52+
- name: Checkout
53+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
1854
- name: Setup Go
19-
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
55+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
2056
with:
2157
go-version: 1.20.x
2258
- name: Restore Go cache
23-
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
59+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
2460
with:
2561
path: ~/go/pkg/mod
2662
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@@ -32,14 +68,68 @@ jobs:
3268
run: make vet
3369
- name: lint
3470
run: make lint
35-
- name: test
36-
run: make test
71+
- name: Check if working tree is dirty
72+
run: |
73+
if [[ $(git diff --stat) != '' ]]; then
74+
git --no-pager diff
75+
echo 'run <make test> and commit changes'
76+
exit 1
77+
fi
78+
79+
test:
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
kubernetes-version:
84+
- "1.25"
85+
- "1.26"
86+
- "1.27"
87+
- "1.28"
88+
steps:
89+
- name: Harden Runner
90+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
91+
with:
92+
egress-policy: audit
93+
- name: Checkout
94+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
95+
- name: Setup Go
96+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
97+
with:
98+
go-version: 1.20.x
99+
- name: Restore Go cache
100+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
101+
with:
102+
path: ~/go/pkg/mod
103+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
104+
restore-keys: |
105+
${{ runner.os }}-go-
106+
- name: run test
107+
run: make test ENVTEST_K8S_VERSION=${{ matrix.kubernetes-version }}
108+
109+
build:
110+
runs-on: ubuntu-latest
111+
outputs:
112+
profiles: ${{ steps.profiles.outputs.matrix }}
113+
steps:
114+
- name: Harden Runner
115+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
116+
with:
117+
egress-policy: audit
118+
- name: Checkout
119+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
120+
- name: Setup Go
121+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
122+
with:
123+
go-version: 1.20.x
124+
- name: Restore Go cache
125+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
126+
with:
127+
path: ~/go/pkg/mod
128+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
129+
restore-keys: |
130+
${{ runner.os }}-go-
37131
- name: build
38132
run: make build
39-
- name: Send go coverage report
40-
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
41-
with:
42-
path-to-profile: coverage.out
43133
- name: Check if working tree is dirty
44134
run: |
45135
if [[ $(git diff --stat) != '' ]]; then
@@ -52,12 +142,12 @@ jobs:
52142
make docker-build
53143
- name: Create image tarball
54144
run: |
55-
docker save --output k8sdb-controller-container.tar k8sdb-controller:latest
145+
docker save --output db-controller-container.tar db-controller:latest
56146
- name: Upload image
57-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
147+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
58148
with:
59-
name: k8sdb-controller-container
60-
path: k8sdb-controller-container.tar
149+
name: db-controller-container
150+
path: db-controller-container.tar
61151
- id: profiles
62152
name: Determine test profiles
63153
run: |
@@ -73,35 +163,82 @@ jobs:
73163
matrix:
74164
profile: ${{ fromJson(needs.build.outputs.profiles) }}
75165
steps:
166+
- name: Harden Runner
167+
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
168+
with:
169+
egress-policy: audit
76170
- name: Checkout
77-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
171+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
172+
- name: Setup Go
173+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
174+
with:
175+
go-version: 1.20.x
78176
- name: Setup Kubernetes
79177
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
80178
with:
81179
version: v0.17.0
82-
- name: Download k8sdb-controller container
180+
- name: Download db-controller container
83181
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3.0.2
84182
with:
85-
name: k8sdb-controller-container
183+
name: db-controller-container
86184
path: /tmp
87185
- name: Load images
88186
run: |
89-
docker load --input /tmp/k8sdb-controller-container.tar
187+
docker load --input /tmp/db-controller-container.tar
90188
docker image ls -a
91189
- name: Setup Kustomize
92190
uses: imranismail/setup-kustomize@6691bdeb1b0a3286fb7f70fd1423c10e81e5375f # v2.0.0
93-
94191
- name: Run test
95192
run: |
96193
make kind-test TEST_PROFILE=${{ matrix.profile }}
97194
- name: Debug failure
98195
if: failure()
99196
run: |
100197
kubectl -n kube-system describe pods
101-
kubectl -n k8sdb-system describe pods
102-
kubectl -n k8sdb-system get all
103-
kubectl -n k8sdb-system logs deploy/k8sdb-controller
104-
kubectl -n k8sdb-system get postgresqlusers -o yaml
105-
kubectl -n k8sdb-system get postgresqldatabases -o yaml
106-
kubectl -n k8sdb-system get mongodbusers -o yaml
107-
kubectl -n k8sdb-system get mongodbdatabases -o yaml
198+
kubectl -n db-system describe pods
199+
kubectl -n db-system get all
200+
kubectl -n db-system logs deploy/db-controller
201+
202+
test-chart:
203+
runs-on: ubuntu-latest
204+
needs:
205+
- build
206+
- lint-chart
207+
steps:
208+
- name: Harden Runner
209+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
210+
with:
211+
egress-policy: audit
212+
- name: Checkout
213+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
214+
with:
215+
fetch-depth: 0
216+
217+
- name: Set up Helm
218+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
219+
220+
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
221+
with:
222+
python-version: 3.7
223+
224+
- name: Set up chart-testing
225+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
226+
227+
- name: Create kind cluster
228+
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
229+
230+
- name: Download db-controller container
231+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
232+
with:
233+
name: db-controller-container
234+
path: /tmp
235+
236+
- name: Load image
237+
run: |
238+
docker load --input /tmp/db-controller-container.tar
239+
docker tag db-controller:latest ghcr.io/doodlescheduling/db-controller:v0.0.0
240+
kind load docker-image ghcr.io/doodlescheduling/db-controller:v0.0.0 --name chart-testing
241+
docker image ls -a
242+
243+
- name: Run chart-testing (install)
244+
run: ct install --target-branch=master --chart-dirs chart

.github/workflows/pr-chart.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/pr-label.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ jobs:
88
runs-on: ubuntu-latest
99
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
1010
steps:
11+
- name: Harden Runner
12+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
13+
with:
14+
egress-policy: audit
1115
- name: size-label
12-
uses: "pascalgn/size-label-action@b1f4946f381d38d3b5960f76b514afdfef39b609"
16+
uses: "pascalgn/size-label-action@1619680c5ac1ef360b944bb56a57587ba4aa2af8"
1317
env:
1418
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/rebase.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ jobs:
1111
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && (github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
1212
runs-on: ubuntu-latest
1313
steps:
14+
- name: Harden Runner
15+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
16+
with:
17+
egress-policy: audit
1418
- name: Checkout the latest code
15-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
19+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1620
with:
1721
fetch-depth: 0
1822
- name: Automatic Rebase

.github/workflows/release-chart.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)