Skip to content

Commit

Permalink
feat: DK-3724: update controller (#23)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
paride5745 and raffis committed May 9, 2023
1 parent c61a889 commit edd06f6
Show file tree
Hide file tree
Showing 60 changed files with 1,379 additions and 1,337 deletions.
133 changes: 0 additions & 133 deletions .github/workflows/e2e.yaml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: main

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tests
run: make test
- name: Send go coverage report
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
with:
path-to-profile: coverage.out
107 changes: 107 additions & 0 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: pr-build

on:
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
build:
runs-on: ubuntu-latest
outputs:
profiles: ${{ steps.profiles.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
with:
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: fmt
run: make fmt
- name: vet
run: make vet
- name: lint
run: make lint
- name: test
run: make test
- name: build
run: make build
- name: Send go coverage report
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
with:
path-to-profile: coverage.out
- name: Check if working tree is dirty
run: |
if [[ $(git diff --stat) != '' ]]; then
git --no-pager diff
echo 'run <make test> and commit changes'
exit 1
fi
- name: Build container image
run: |
make docker-build
- name: Create image tarball
run: |
docker save --output k8sdb-controller-container.tar k8sdb-controller:latest
- name: Upload image
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
with:
name: k8sdb-controller-container
path: k8sdb-controller-container.tar
- id: profiles
name: Determine test profiles
run: |
profiles=$(ls config/tests/cases | jq -R -s -c 'split("\n")[:-1]')
echo $profiles
echo "::set-output name=matrix::$profiles"
e2e-tests:
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
profile: ${{ fromJson(needs.build.outputs.profiles) }}
steps:
- name: Checkout
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
version: v0.17.0
- name: Download k8sdb-controller container
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3.0.2
with:
name: k8sdb-controller-container
path: /tmp
- name: Load images
run: |
docker load --input /tmp/k8sdb-controller-container.tar
docker image ls -a
- name: Setup Kustomize
uses: imranismail/setup-kustomize@6691bdeb1b0a3286fb7f70fd1423c10e81e5375f # v2.0.0

- name: Run test
run: |
make kind-test TEST_PROFILE=${{ matrix.profile }}
- name: Debug failure
if: failure()
run: |
kubectl -n kube-system describe pods
kubectl -n k8sdb-system describe pods
kubectl -n k8sdb-system get all
kubectl -n k8sdb-system logs deploy/k8sdb-controller
kubectl -n k8sdb-system get postgresqlusers -o yaml
kubectl -n k8sdb-system get postgresqldatabases -o yaml
kubectl -n k8sdb-system get mongodbusers -o yaml
kubectl -n k8sdb-system get mongodbdatabases -o yaml
18 changes: 9 additions & 9 deletions .github/workflows/chart.yaml → .github/workflows/pr-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and Test Charts
name: pr-chart

on: pull_request

Expand All @@ -7,36 +7,36 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5
with:
version: v3.4.0

- uses: actions/setup-python@v2
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 #v4.4.0
with:
python-version: 3.7

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

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs chart)
changed=$(ct list-changed --target-branch=master --chart-dirs chart)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --chart-dirs chart
run: ct lint --target-branch=master --chart-dirs chart

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

- name: Run chart-testing (install)
run: ct install --chart-dirs chart
run: ct install --target-branch=master --chart-dirs chart
14 changes: 14 additions & 0 deletions .github/workflows/pr-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pr-label

on:
pull_request:

jobs:
size-label:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
steps:
- name: size-label
uses: "pascalgn/size-label-action@1619680c5ac1ef360b944bb56a57587ba4aa2af8"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 2 additions & 2 deletions .github/workflows/rebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3.1
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 #1.8
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
26 changes: 15 additions & 11 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Chart
name: release-chart

on:
push:
Expand All @@ -10,17 +10,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
with:
fetch-depth: 0

- name: Configure Git
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5

- name: Login to Github Container Registry using helm
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin

- name: Package helm charts
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.3.0
with:
charts_dir: ./chart
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
helm package chart/k8sdb-controller -d chart
- name: Publish helm charts to Github Container Registry
run: |
repository=$(echo "${{ github.repository_owner }}" | tr [:upper:] [:lower:])
helm push ${{ github.workspace }}/chart/k8sdb-controller-*.tgz oci://ghcr.io/$repository/charts
Loading

0 comments on commit edd06f6

Please sign in to comment.