Skip to content

Commit edd06f6

Browse files
paride5745raffis
andauthored
feat: DK-3724: update controller (#23)
* update README * make - docker- goreleaser * go versions * config * github actions * api * chart * bump chart version * bump CRD version * making lint happy * missing key * fix path * versions bump * ci: refactor tests and pipelines * fix(chart): remove invalid psb condition * ci: fix build output vars * ci: add codeowners * ci: remove unused stage * ci: dockerfile name goreleaser --------- Co-authored-by: Raffael Sahli <raffael.sahli@doodle.com>
1 parent c61a889 commit edd06f6

Some content is hidden

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

60 files changed

+1379
-1337
lines changed

.github/workflows/e2e.yaml

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

.github/workflows/main.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3
14+
- name: Setup Go
15+
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
16+
with:
17+
go-version: 1.20.x
18+
- name: Restore Go cache
19+
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
20+
with:
21+
path: ~/go/pkg/mod
22+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
${{ runner.os }}-go-
25+
- name: Tests
26+
run: make test
27+
- name: Send go coverage report
28+
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
29+
with:
30+
path-to-profile: coverage.out

.github/workflows/pr-build.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: pr-build
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
profiles: ${{ steps.profiles.outputs.matrix }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
18+
- name: Setup Go
19+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
20+
with:
21+
go-version: 1.20.x
22+
- name: Restore Go cache
23+
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
24+
with:
25+
path: ~/go/pkg/mod
26+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
27+
restore-keys: |
28+
${{ runner.os }}-go-
29+
- name: fmt
30+
run: make fmt
31+
- name: vet
32+
run: make vet
33+
- name: lint
34+
run: make lint
35+
- name: test
36+
run: make test
37+
- name: build
38+
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
43+
- name: Check if working tree is dirty
44+
run: |
45+
if [[ $(git diff --stat) != '' ]]; then
46+
git --no-pager diff
47+
echo 'run <make test> and commit changes'
48+
exit 1
49+
fi
50+
- name: Build container image
51+
run: |
52+
make docker-build
53+
- name: Create image tarball
54+
run: |
55+
docker save --output k8sdb-controller-container.tar k8sdb-controller:latest
56+
- name: Upload image
57+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
58+
with:
59+
name: k8sdb-controller-container
60+
path: k8sdb-controller-container.tar
61+
- id: profiles
62+
name: Determine test profiles
63+
run: |
64+
profiles=$(ls config/tests/cases | jq -R -s -c 'split("\n")[:-1]')
65+
echo $profiles
66+
echo "::set-output name=matrix::$profiles"
67+
68+
e2e-tests:
69+
runs-on: ubuntu-latest
70+
needs:
71+
- build
72+
strategy:
73+
matrix:
74+
profile: ${{ fromJson(needs.build.outputs.profiles) }}
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3
78+
- name: Setup Kubernetes
79+
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
80+
with:
81+
version: v0.17.0
82+
- name: Download k8sdb-controller container
83+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3.0.2
84+
with:
85+
name: k8sdb-controller-container
86+
path: /tmp
87+
- name: Load images
88+
run: |
89+
docker load --input /tmp/k8sdb-controller-container.tar
90+
docker image ls -a
91+
- name: Setup Kustomize
92+
uses: imranismail/setup-kustomize@6691bdeb1b0a3286fb7f70fd1423c10e81e5375f # v2.0.0
93+
94+
- name: Run test
95+
run: |
96+
make kind-test TEST_PROFILE=${{ matrix.profile }}
97+
- name: Debug failure
98+
if: failure()
99+
run: |
100+
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
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint and Test Charts
1+
name: pr-chart
22

33
on: pull_request
44

@@ -7,36 +7,36 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1111
with:
1212
fetch-depth: 0
1313

1414
- name: Set up Helm
15-
uses: azure/setup-helm@v1
15+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
1616
with:
1717
version: v3.4.0
1818

19-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 #v4.4.0
2020
with:
2121
python-version: 3.7
2222

2323
- name: Set up chart-testing
24-
uses: helm/chart-testing-action@v2.1.0
24+
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec #v2.3.1
2525

2626
- name: Run chart-testing (list-changed)
2727
id: list-changed
2828
run: |
29-
changed=$(ct list-changed --chart-dirs chart)
29+
changed=$(ct list-changed --target-branch=master --chart-dirs chart)
3030
if [[ -n "$changed" ]]; then
3131
echo "::set-output name=changed::true"
3232
fi
3333
3434
- name: Run chart-testing (lint)
35-
run: ct lint --chart-dirs chart
35+
run: ct lint --target-branch=master --chart-dirs chart
3636

3737
- name: Create kind cluster
38-
uses: helm/kind-action@v1.2.0
38+
uses: helm/kind-action@d8ccf8fb623ce1bb360ae2f45f323d9d5c5e9f00 #v1.5.0
3939
if: steps.list-changed.outputs.changed == 'true'
4040

4141
- name: Run chart-testing (install)
42-
run: ct install --chart-dirs chart
42+
run: ct install --target-branch=master --chart-dirs chart

.github/workflows/pr-label.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pr-label
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
size-label:
8+
runs-on: ubuntu-latest
9+
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
10+
steps:
11+
- name: size-label
12+
uses: "pascalgn/size-label-action@1619680c5ac1ef360b944bb56a57587ba4aa2af8"
13+
env:
14+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/rebase.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout the latest code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1616
with:
1717
fetch-depth: 0
1818
- name: Automatic Rebase
19-
uses: cirrus-actions/rebase@1.3.1
19+
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 #1.8
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

.github/workflows/release-chart.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Chart
1+
name: release-chart
22

33
on:
44
push:
@@ -10,17 +10,21 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Configure Git
17+
- name: Install Helm
18+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
19+
20+
- name: Login to Github Container Registry using helm
21+
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
22+
23+
- name: Package helm charts
1824
run: |
19-
git config user.name "$GITHUB_ACTOR"
20-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
21-
- name: Run chart-releaser
22-
uses: helm/chart-releaser-action@v1.3.0
23-
with:
24-
charts_dir: ./chart
25-
env:
26-
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
25+
helm package chart/k8sdb-controller -d chart
26+
27+
- name: Publish helm charts to Github Container Registry
28+
run: |
29+
repository=$(echo "${{ github.repository_owner }}" | tr [:upper:] [:lower:])
30+
helm push ${{ github.workspace }}/chart/k8sdb-controller-*.tgz oci://ghcr.io/$repository/charts

0 commit comments

Comments
 (0)