From 9020e0c16cca659f2e02c342cbb30807a3744fd5 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Thu, 31 Aug 2023 15:12:18 +0200 Subject: [PATCH 1/3] Migrate tests to GHA --- .github/workflows/run-tests.yaml | 13 ++----- .github/workflows/run-validation.yaml | 37 +++++++++++++++++++ ...kyma-project.io_applicationconnectors.yaml | 2 +- hack/ci/Makefile | 9 ++++- hack/common/Makefile | 4 +- 5 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/run-validation.yaml diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index a9d6f650..efd583ef 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -3,20 +3,15 @@ on: push: branches: [ "main" ] pull_request: - # Trigger for Pull Request - branches: [ "main" ] permissions: contents: read jobs: - lint: -############################################################################################ - validate: + test: runs-on: ubuntu-latest steps: -############################################################################################ - name: Checkout code uses: actions/checkout@v3 -############################################################################################ + - name: Set up cache uses: actions/cache@v3 with: @@ -27,11 +22,11 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- -############################################################################################ + - name: Set up go environment uses: actions/setup-go@v4 with: go-version: 1.19 -############################################################################################ + - name: Run unit tests run: make test diff --git a/.github/workflows/run-validation.yaml b/.github/workflows/run-validation.yaml new file mode 100644 index 00000000..dcd1aca6 --- /dev/null +++ b/.github/workflows/run-validation.yaml @@ -0,0 +1,37 @@ +name: Run integration tests + +on: + push: + branches: [ "main" ] + + pull_request: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up cache + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + /home/runner/work/application-connector-manager/application-connector-manager/bin + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Set up go environment + uses: actions/setup-go@v4 + with: + go-version: 1.19 + + - name: Run integration tests without lifecycle-manager + run: make -C hack/ci run-without-lifecycle-manager diff --git a/config/crd/bases/operator.kyma-project.io_applicationconnectors.yaml b/config/crd/bases/operator.kyma-project.io_applicationconnectors.yaml index d2a17656..87693549 100644 --- a/config/crd/bases/operator.kyma-project.io_applicationconnectors.yaml +++ b/config/crd/bases/operator.kyma-project.io_applicationconnectors.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.10.0 + controller-gen.kubebuilder.io/version: v0.9.2 creationTimestamp: null name: applicationconnectors.operator.kyma-project.io spec: diff --git a/hack/ci/Makefile b/hack/ci/Makefile index 35ce361e..1ccfd28f 100644 --- a/hack/ci/Makefile +++ b/hack/ci/Makefile @@ -1,6 +1,9 @@ PROJECT_ROOT ?= ../.. PROJECT_COMMON ?= ../common +K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh +DEFAULT_K3D_VERSION=v5.4.6 + include ${PROJECT_ROOT}/.env ifndef MODULE_SHA @@ -53,11 +56,15 @@ k3d-upgrade-test: \ render-manifest: @make -C ${PROJECT_ROOT} render-manifest +.PHONY: install-k3d +install-k3d: + curl --silent --fail ${K3D_URL} | TAG=${DEFAULT_K3D_VERSION} bash + .PHONY: run-with-lifecycle-manager run-with-lifecycle-manager: @make -C ${PROJECT_COMMON} run-with-lifecycle-manager .PHONY: run-without-lifecycle-manager -run-without-lifecycle-manager: +run-without-lifecycle-manager: install-k3d @make -C ${PROJECT_COMMON} run-without-lifecycle-manager diff --git a/hack/common/Makefile b/hack/common/Makefile index 96ef06cb..3a578bb2 100644 --- a/hack/common/Makefile +++ b/hack/common/Makefile @@ -48,7 +48,7 @@ run-without-lifecycle-manager: \ .PHONY: create-k3d create-k3d: ## Create k3d with kyma CRDs. - ${KYMA} provision k3d --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} --ci + ${KYMA} provision k3d --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} -p 8080:80@loadbalancer -p 8443:443@loadbalancer --ci .PHONY: delete-k3d delete-k3d: ## Delete k3d with kyma CRDs. @@ -64,7 +64,7 @@ patch-with-istio-crds: ## Delete k3d kyma cluster. .PHONY: create-k3d create-k3d: ## Create k3d with kyma CRDs. - ${KYMA} provision k3d --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} --ci + ${KYMA} provision k3d --registry-port ${REGISTRY_PORT} --name ${CLUSTER_NAME} -p 8080:80@loadbalancer -p 8443:443@loadbalancer --ci ##@ Module management From 8233a74df8a90b7b0b262bbd046a45a8d64f8fe3 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Mon, 4 Sep 2023 10:14:49 +0200 Subject: [PATCH 2/3] add govulncheck --- .github/workflows/golangci-lint.yaml | 2 +- .github/workflows/run-tests.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index e7fd545f..65a8434f 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -48,7 +48,7 @@ jobs: # skip-cache: true # Optional: if set to true, then the action won't cache or restore ~/go/pkg. - # skip-pkg-cache: true + skip-pkg-cache: true # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. # skip-build-cache: true diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index efd583ef..0435164c 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -30,3 +30,4 @@ jobs: - name: Run unit tests run: make test + From 0a5312ecfca206d247e52329ebb61404d99403df Mon Sep 17 00:00:00 2001 From: m00g3n Date: Mon, 4 Sep 2023 10:57:08 +0200 Subject: [PATCH 3/3] add govulncheck --- .github/workflows/run-vuln-check.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/run-vuln-check.yaml diff --git a/.github/workflows/run-vuln-check.yaml b/.github/workflows/run-vuln-check.yaml new file mode 100644 index 00000000..76c37561 --- /dev/null +++ b/.github/workflows/run-vuln-check.yaml @@ -0,0 +1,16 @@ +name: Run vuln check +on: + push: + branches: [ "main" ] + pull_request: +permissions: + contents: read +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: vulncheck + uses: golang/govulncheck-action@v1