From 60095f0b2e5e8b0593947c82ab3d5694004b93ea Mon Sep 17 00:00:00 2001 From: Filip Strozik Date: Wed, 10 Apr 2024 09:24:37 +0200 Subject: [PATCH] Upgrade project go version (#870) --- .github/workflows/operator-verify.yaml | 59 ++++++++++++------- .github/workflows/serverless-verify.yaml | 15 +++++ components/operator/Dockerfile | 2 +- .../operator/internal/state/state_test.go | 17 +++--- .../serverless/deploy/webhook/Dockerfile | 4 +- go.mod | 4 +- 6 files changed, 63 insertions(+), 38 deletions(-) diff --git a/.github/workflows/operator-verify.yaml b/.github/workflows/operator-verify.yaml index e0702fbd6..e656a001b 100644 --- a/.github/workflows/operator-verify.yaml +++ b/.github/workflows/operator-verify.yaml @@ -1,5 +1,8 @@ name: Operator verify +env: + SETUP_GO_VERSION: '1.22' + on: push: branches: [ "main", "release-*" ] @@ -21,6 +24,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - uses: golangci/golangci-lint-action@v3 with: version: latest @@ -32,6 +38,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - name: run test run: make -C components/operator test @@ -42,6 +51,9 @@ jobs: if: github.event_name == 'push' steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - name: create single cluster uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0 with: @@ -61,25 +73,28 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: save sa - shell: bash - run: 'echo "$GARDENER_SA" > /tmp/gardener-sa.yaml' - env: - GARDENER_SA: ${{ secrets.GARDENER_SA }} - - name: provision gardener - run: make -C hack provision-gardener - env: - GARDENER_SECRET_NAME: ${{ secrets.GARDENER_SECRET_NAME }} - GARDENER_PROJECT: ${{ secrets.GARDENER_PROJECT }} - GARDENER_SA_PATH: /tmp/gardener-sa.yaml - - name: run test - run: make -C hack integration-test-on-cluster - env: - IMG: europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.sha }} - - name: deprovision gardener -# https://docs.github.com/en/actions/learn-github-actions/expressions#always - if: ${{ always() }} - run: make -C hack deprovision-gardener - env: - GARDENER_SA_PATH: /tmp/gardener-sa.yaml + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} + - name: save sa + shell: bash + run: 'echo "$GARDENER_SA" > /tmp/gardener-sa.yaml' + env: + GARDENER_SA: ${{ secrets.GARDENER_SA }} + - name: provision gardener + run: make -C hack provision-gardener + env: + GARDENER_SECRET_NAME: ${{ secrets.GARDENER_SECRET_NAME }} + GARDENER_PROJECT: ${{ secrets.GARDENER_PROJECT }} + GARDENER_SA_PATH: /tmp/gardener-sa.yaml + - name: run test + run: make -C hack integration-test-on-cluster + env: + IMG: europe-docker.pkg.dev/kyma-project/prod/serverless-operator:${{ github.sha }} + - name: deprovision gardener +# https://docs.github.com/en/actions/learn-github-actions/expressions#always + if: ${{ always() }} + run: make -C hack deprovision-gardener + env: + GARDENER_SA_PATH: /tmp/gardener-sa.yaml diff --git a/.github/workflows/serverless-verify.yaml b/.github/workflows/serverless-verify.yaml index 49765ee93..04ee15dba 100644 --- a/.github/workflows/serverless-verify.yaml +++ b/.github/workflows/serverless-verify.yaml @@ -1,5 +1,8 @@ name: Serverless verify +env: + SETUP_GO_VERSION: '1.22' + on: push: branches: [ "main", "release-*" ] @@ -21,6 +24,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - uses: ./.github/actions/setup-libgit2 - uses: golangci/golangci-lint-action@v3 with: @@ -33,6 +39,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - uses: ./.github/actions/setup-libgit2 - name: run test run: make -C components/serverless test @@ -42,6 +51,9 @@ jobs: if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - name: create single cluster uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0 with: @@ -69,6 +81,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.SETUP_GO_VERSION }} - name: create single cluster uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0 with: diff --git a/components/operator/Dockerfile b/components/operator/Dockerfile index 8f00be5b2..b574a78bb 100644 --- a/components/operator/Dockerfile +++ b/components/operator/Dockerfile @@ -4,7 +4,7 @@ # Build the operator binary -FROM golang:1.22.1 as builder +FROM golang:1.22.2 as builder WORKDIR /workspace diff --git a/components/operator/internal/state/state_test.go b/components/operator/internal/state/state_test.go index a11ceb61d..562970e19 100644 --- a/components/operator/internal/state/state_test.go +++ b/components/operator/internal/state/state_test.go @@ -58,9 +58,11 @@ func fixManifestCache(manifest string) chart.ManifestCache { return cache } +// requireEqualFunc compares two stateFns based on their names returned from the reflect package +// names returned from the package may be different for any go/dlv compiler version +// for go1.22 returned name is in format: +// github.com/kyma-project/keda-manager/pkg/reconciler.Test_sFnServedFilter.func4.sFnUpdateStatus.3 func requireEqualFunc(t *testing.T, expected, actual stateFn) { - require.NotNil(t, actual) - expectedFnName := getFnName(expected) actualFnName := getFnName(actual) @@ -73,12 +75,14 @@ func requireEqualFunc(t *testing.T, expected, actual stateFn) { actualElems := strings.Split(actualFnName, "/") // check package paths (prefix) + // e.g. 'github.com/kyma-project/keda-manager/pkg' require.Equal(t, strings.Join(expectedElems[0:len(expectedElems)-2], "/"), strings.Join(actualElems[0:len(actualElems)-2], "/"), ) // check direct fn names (suffix) + // e.g. 'reconciler.Test_sFnServedFilter.func4.sFnUpdateStatus.3' require.Equal(t, getDirectFnName(expectedElems[len(expectedElems)-1]), getDirectFnName(actualElems[len(actualElems)-1]), @@ -87,14 +91,7 @@ func requireEqualFunc(t *testing.T, expected, actual stateFn) { func getDirectFnName(nameSuffix string) string { elements := strings.Split(nameSuffix, ".") - for i := range elements { - elemI := len(elements) - i - 1 - if !strings.HasPrefix(elements[elemI], "func") { - return elements[elemI] - } - } - - return "" + return elements[len(elements)-2] } func getFnName(fn stateFn) string { diff --git a/components/serverless/deploy/webhook/Dockerfile b/components/serverless/deploy/webhook/Dockerfile index 4167116ac..72bc6e3e4 100644 --- a/components/serverless/deploy/webhook/Dockerfile +++ b/components/serverless/deploy/webhook/Dockerfile @@ -1,5 +1,5 @@ -# image builder base on golang:1.21.4-alpine3.18 -FROM golang@sha256:f475434ea2047a83e9ba02a1da8efc250fa6b2ed0e9e8e4eb8c5322ea6997795 as builder +# image builder base on golang:1.22.2-alpine3.19 +FROM golang@sha256:cdc86d9f363e8786845bea2040312b4efa321b828acdeb26f393faa864d887b0 as builder ENV BASE_APP_DIR=/workspace/go/src/github.com/kyma-project/serverless \ CGO_ENABLED=0 \ diff --git a/go.mod b/go.mod index 675db6605..d2ce1ec02 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/kyma-project/serverless -go 1.21 - -toolchain go1.21.3 +go 1.22 require ( github.com/avast/retry-go v3.0.0+incompatible