Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support schemas and refactoring to db-controller #50

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
Expand Down
193 changes: 165 additions & 28 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,55 @@ on:
- reopened

jobs:
build:
lint-chart:
runs-on: ubuntu-latest
outputs:
profiles: ${{ steps.profiles.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
fetch-depth: 0

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

- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
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 --target-branch=master --chart-dirs chart --check-version-increment=false

fmt:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Setup Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 #v3.5.0
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@4723a57e26efda3a62cbde1812113b730952852d #v3.2.2
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -32,14 +68,68 @@ jobs:
run: make vet
- name: lint
run: make lint
- name: test
run: make test
- 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

test:
runs-on: ubuntu-latest
strategy:
matrix:
kubernetes-version:
- "1.25"
- "1.26"
- "1.27"
- "1.28"
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.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: run test
run: make test ENVTEST_K8S_VERSION=${{ matrix.kubernetes-version }}

build:
runs-on: ubuntu-latest
outputs:
profiles: ${{ steps.profiles.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.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: 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
Expand All @@ -52,12 +142,12 @@ jobs:
make docker-build
- name: Create image tarball
run: |
docker save --output k8sdb-controller-container.tar k8sdb-controller:latest
docker save --output db-controller-container.tar db-controller:latest
- name: Upload image
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3.1.2
with:
name: k8sdb-controller-container
path: k8sdb-controller-container.tar
name: db-controller-container
path: db-controller-container.tar
- id: profiles
name: Determine test profiles
run: |
Expand All @@ -73,35 +163,82 @@ jobs:
matrix:
profile: ${{ fromJson(needs.build.outputs.profiles) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.20.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
version: v0.17.0
- name: Download k8sdb-controller container
- name: Download db-controller container
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3.0.2
with:
name: k8sdb-controller-container
name: db-controller-container
path: /tmp
- name: Load images
run: |
docker load --input /tmp/k8sdb-controller-container.tar
docker load --input /tmp/db-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
kubectl -n db-system describe pods
kubectl -n db-system get all
kubectl -n db-system logs deploy/db-controller

test-chart:
runs-on: ubuntu-latest
needs:
- build
- lint-chart
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
fetch-depth: 0

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

- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

- name: Create kind cluster
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0

- name: Download db-controller container
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: db-controller-container
path: /tmp

- name: Load image
run: |
docker load --input /tmp/db-controller-container.tar
docker tag db-controller:latest ghcr.io/doodlescheduling/db-controller:v0.0.0
kind load docker-image ghcr.io/doodlescheduling/db-controller:v0.0.0 --name chart-testing
docker image ls -a

- name: Run chart-testing (install)
run: ct install --target-branch=master --chart-dirs chart
42 changes: 0 additions & 42 deletions .github/workflows/pr-chart.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/pr-label.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: size-label
uses: "pascalgn/size-label-action@b1f4946f381d38d3b5960f76b514afdfef39b609"
uses: "pascalgn/size-label-action@1619680c5ac1ef360b944bb56a57587ba4aa2af8"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6 changes: 5 additions & 1 deletion .github/workflows/rebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:
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')
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
with:
egress-policy: audit
- name: Checkout the latest code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b #v3
with:
fetch-depth: 0
- name: Automatic Rebase
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/release-chart.yaml

This file was deleted.

Loading
Loading