Skip to content

Commit

Permalink
Upgrade project go version (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel authored Apr 10, 2024
1 parent 5765a7a commit 60095f0
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 38 deletions.
59 changes: 37 additions & 22 deletions .github/workflows/operator-verify.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Operator verify

env:
SETUP_GO_VERSION: '1.22'

on:
push:
branches: [ "main", "release-*" ]
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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
15 changes: 15 additions & 0 deletions .github/workflows/serverless-verify.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Serverless verify

env:
SETUP_GO_VERSION: '1.22'

on:
push:
branches: [ "main", "release-*" ]
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion components/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


# Build the operator binary
FROM golang:1.22.1 as builder
FROM golang:1.22.2 as builder

WORKDIR /workspace

Expand Down
17 changes: 7 additions & 10 deletions components/operator/internal/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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]),
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions components/serverless/deploy/webhook/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 60095f0

Please sign in to comment.