Skip to content

Commit

Permalink
feat: bump go to 1.21 (#4846)
Browse files Browse the repository at this point in the history
* bump go to 1.21, add toolchain go1.21.7

* bump go to 1.21

* fix test

---------

Co-authored-by: Egor Balakin <[email protected]>
  • Loading branch information
m1ron0xFF and Egor Balakin authored Apr 18, 2024
1 parent df0b288 commit 077ecfe
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'

- name: Install Groovy
run: sudo apt-get update && sudo apt-get install groovy -y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-go-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Perform update
run: |
git checkout -B gh-action-update-golang-dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-go-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- env:
CGO_ENABLED: 0
run: |
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/verify-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: styfle/[email protected]
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand All @@ -63,8 +63,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
# action requires [email protected]
go-version: '1.21.x'
- name: checkout
uses: actions/checkout@v4
with:
Expand All @@ -79,7 +78,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand All @@ -99,7 +98,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.20.x'
go-version: '1.21.x'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 AS build-env
FROM golang:1.21 AS build-env
COPY . /build
WORKDIR /build

Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/SAP/jenkins-library

go 1.20
go 1.21

toolchain go1.21.9

// It is a locked dependency of github.com/buildpacks/[email protected]. The maintainers may remove the lock
// in future releases. Check if 'replace' statement still there in their go.mod file. Remove line below if not.
Expand Down
50 changes: 50 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/example/golang-app

go 1.20
go 1.21

require github.com/gorilla/mux v1.8.0
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/example/golang-app

go 1.20
go 1.21
10 changes: 5 additions & 5 deletions pkg/http/http_cert_logon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestCertificateLogon(t *testing.T) {

clientPemKey, clientPemCert := GenerateSelfSignedClientAuthCertificate()

//server
// server
clientCertPool := x509.NewCertPool()
clientCertPool.AppendCertsFromPEM(clientPemCert)

Expand All @@ -102,7 +102,7 @@ func TestCertificateLogon(t *testing.T) {
server.StartTLS()
defer server.Close()

//client
// client
tlsKeyPair, err := tls.X509KeyPair(clientPemCert, clientPemKey)
if err != nil {
log.Fatal("Failed to create clients tls key pair")
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestCertificateLogon(t *testing.T) {
})

_, err := c.SendRequest("GET", server.URL, nil, nil, nil)
assert.ErrorContains(t, err, "bad certificate")
assert.ErrorContains(t, err, "certificate required")
})

t.Run("Failure - Login with wrong certificate", func(t *testing.T) {
Expand All @@ -150,14 +150,14 @@ func TestCertificateLogon(t *testing.T) {
})

_, err = c.SendRequest("GET", server.URL, nil, nil, nil)
assert.ErrorContains(t, err, "bad certificate")
assert.ErrorContains(t, err, "unknown certificate authority")
})

t.Run("SanityCheck", func(t *testing.T) {
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
//RootCAs: certPool,
// RootCAs: certPool,
InsecureSkipVerify: true,
Certificates: []tls.Certificate{tlsKeyPair},
},
Expand Down
2 changes: 1 addition & 1 deletion src/com/sap/piper/PiperGoUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PiperGoUtils implements Serializable {

if (steps.env.REPOSITORY_UNDER_TEST && steps.env.LIBRARY_VERSION_UNDER_TEST) {
steps.echo("Running in a consumer test, building unit-under-test binary for verification.")
steps.dockerExecute(script: steps, dockerImage: 'golang:1.20', dockerOptions: '-u 0', dockerEnvVars: [
steps.dockerExecute(script: steps, dockerImage: 'golang:1.21', dockerOptions: '-u 0', dockerEnvVars: [
REPOSITORY_UNDER_TEST: steps.env.REPOSITORY_UNDER_TEST,
LIBRARY_VERSION_UNDER_TEST: steps.env.LIBRARY_VERSION_UNDER_TEST
]) {
Expand Down

0 comments on commit 077ecfe

Please sign in to comment.