From 62dab91a3d0bb789c8e24d55bd948b93cf3854cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Thu, 25 Jul 2024 13:00:19 +0200 Subject: [PATCH 1/4] feat(ci): add basic CI --- .github/PULL_REQUEST_TEMPLATE.md | 13 ++++++ .github/dependabot.yml | 14 ++++++ .github/workflows/tests.yaml | 77 ++++++++++++++++++++++++++++++++ Makefile | 11 ++++- config/samples/.gitignore | 0 scripts/verify-diff.sh | 17 +++++++ 6 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/tests.yaml create mode 100644 config/samples/.gitignore create mode 100755 scripts/verify-diff.sh diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b4b571d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ +**What this PR does / why we need it**: + +**Which issue this PR fixes** + +Fixes # + +**Special notes for your reviewer**: + +**PR Readiness Checklist**: + +Complete these before marking the PR as `ready to review`: + +- [ ] the `CHANGELOG.md` release notes have been updated to reflect significant changes diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e941920 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: / + schedule: + interval: daily + labels: + - dependencies +- package-ecosystem: github-actions + directory: / + schedule: + interval: daily + labels: + - github_actions diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..51d54e7 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,77 @@ +name: tests +run-name: tests, branch:${{ github.ref_name }}, triggered by @${{ github.actor }} + +concurrency: + # Run only for most recent commit in PRs but for all tags and commits on main + # Ref: https://docs.github.com/en/actions/using-jobs/using-concurrency + group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} + cancel-in-progress: true + +on: + pull_request: + branches: + - '*' + push: + branches: + - 'main' + - 'release/*' + tags: + - '*' + workflow_dispatch: {} + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - uses: jdx/mise-action@v2 + with: + install: false + + - name: Generate + run: make generate + + - name: Verify + run: make verify.diff + + apply: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - uses: jdx/mise-action@v2 + with: + install: false + + - name: Create k8s KinD Cluster + uses: helm/kind-action@v1.10.0 + + - name: Verify installing CRDs via kustomize works + run: make install + + - name: Install and delete each sample one by one + run: make test.samples + + # We need this step to fail the workflow if any of the previous steps failed or were cancelled. + # It allows to use this particular job as a required check for PRs. + # Ref: https://github.com/orgs/community/discussions/26822#discussioncomment-3305794 + passed: + runs-on: ubuntu-latest + needs: + - generate + - apply + if: always() + steps: + - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + run: | + echo "Some jobs failed or were cancelled." + exit 1 diff --git a/Makefile b/Makefile index 6cda9e7..fbb6f2d 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,7 @@ verify.repo: .PHONY: verify.diff verify.diff: - ./scripts/verify-diff.sh + @$(PROJECT_DIR)/scripts/verify-diff.sh $(PROJECT_DIR) .PHONY: verify.versions verify.versions: @@ -169,3 +169,12 @@ generate.apidocs: crd-ref-docs # .PHONY: generate.cli-arguments # generate.cli-arguments-docs: # go run ./scripts/cli-arguments-docs-gen/main.go > ./docs/cli-arguments.md + +# Install CRDs into the K8s cluster specified in ~/.kube/config. +.PHONY: install +install: generate.crds kustomize + $(KUSTOMIZE) build config/crd | kubectl apply -f - + +.PHONY: test.samples +test.samples: kustomize + find ./config/samples -not -name "kustomization.*" -type f | sort | xargs -I{} bash -c "kubectl apply -f {}; kubectl delete -f {}" diff --git a/config/samples/.gitignore b/config/samples/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/scripts/verify-diff.sh b/scripts/verify-diff.sh new file mode 100755 index 0000000..409ae17 --- /dev/null +++ b/scripts/verify-diff.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +DIR="${1}" + +if git diff --quiet "${DIR}" +then + echo "${DIR} up to date." +else + echo "${DIR} appears to be out of date (make sure you've run 'make manifests' and 'make generate')" + echo "Diff output:" + git --no-pager diff "${DIR}" + exit 1 +fi From 570224d69bf12f37383234970690ea2bd259a3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Thu, 25 Jul 2024 13:16:21 +0200 Subject: [PATCH 2/4] feat(ci): enable merge queue --- .github/workflows/tests.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 51d54e7..e4a49f5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,9 +8,12 @@ concurrency: cancel-in-progress: true on: + merge_group: + branches: + - 'main' pull_request: branches: - - '*' + - 'main' push: branches: - 'main' From 7c0ebcd605b689713b1fa94458ec159c46d4f0b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:11:25 +0200 Subject: [PATCH 3/4] chore(deps): bump k8s.io/apimachinery from 0.30.2 to 0.30.3 (#2) Bumps [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) from 0.30.2 to 0.30.3. - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.30.2...v0.30.3) --- updated-dependencies: - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index adab643..d268e2b 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/kong/go-kong v0.57.0 k8s.io/api v0.30.2 k8s.io/apiextensions-apiserver v0.30.2 - k8s.io/apimachinery v0.30.2 + k8s.io/apimachinery v0.30.3 k8s.io/client-go v0.30.2 sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/gateway-api v1.1.0 diff --git a/go.sum b/go.sum index 0a6c003..df0cbb4 100644 --- a/go.sum +++ b/go.sum @@ -150,8 +150,8 @@ k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= k8s.io/apiextensions-apiserver v0.30.2 h1:l7Eue2t6QiLHErfn2vwK4KgF4NeDgjQkCXtEbOocKIE= k8s.io/apiextensions-apiserver v0.30.2/go.mod h1:lsJFLYyK40iguuinsb3nt+Sj6CmodSI4ACDLep1rgjw= -k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg= -k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= +k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= From 29dc2dd2009d871b2ef745ee3d4d4dd473f057ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:12:30 +0000 Subject: [PATCH 4/4] chore(deps): bump k8s.io/client-go from 0.30.2 to 0.30.3 Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.30.2 to 0.30.3. - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.30.2...v0.30.3) --- updated-dependencies: - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index d268e2b..315649e 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.22.4 require ( github.com/Kong/sdk-konnect-go v0.0.0-20240723160412-999d9a987e1a github.com/kong/go-kong v0.57.0 - k8s.io/api v0.30.2 + k8s.io/api v0.30.3 k8s.io/apiextensions-apiserver v0.30.2 k8s.io/apimachinery v0.30.3 - k8s.io/client-go v0.30.2 + k8s.io/client-go v0.30.3 sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/gateway-api v1.1.0 ) diff --git a/go.sum b/go.sum index df0cbb4..e1b4956 100644 --- a/go.sum +++ b/go.sum @@ -146,14 +146,14 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= -k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= +k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= +k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= k8s.io/apiextensions-apiserver v0.30.2 h1:l7Eue2t6QiLHErfn2vwK4KgF4NeDgjQkCXtEbOocKIE= k8s.io/apiextensions-apiserver v0.30.2/go.mod h1:lsJFLYyK40iguuinsb3nt+Sj6CmodSI4ACDLep1rgjw= k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= -k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= +k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= +k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM=