Skip to content

Commit

Permalink
Reduce go binary size by updating to go 1.15 (#1968)
Browse files Browse the repository at this point in the history
* Update go to 1.15 to reduce binary size

Go made improvements to reduce binary size, cf https://golang.org/doc/go1.15

> Go 1.15 reduces typical binary sizes by around 5% compared to Go 1.14 by eliminating certain types of GC metadata and more aggressively eliminating unused type metadata.

In my test, this equates to about 3 mb diff between Go 1.13 and Go 1.15:

-rwxr-xr-x 1 root root 36M Aug 31 14:43 piper-go-113
-rwxr-xr-x 1 root root 33M Aug 31 14:44 piper-go-115

* Go Generate

* go mod tidy

Co-authored-by: Stephan Aßmus <[email protected]>
Co-authored-by: Oliver Nocon <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2020
1 parent d589038 commit 485faed
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.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/integration-tests-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "pending", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: build
env:
CGO_ENABLED: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "pending", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: build
env:
CGO_ENABLED: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-go-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.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 @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- env:
CGO_ENABLED: 0
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/verify-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
Expand All @@ -38,7 +38,7 @@ jobs:
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
Expand All @@ -58,7 +58,7 @@ jobs:
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
with:
Expand All @@ -78,7 +78,7 @@ jobs:
steps:
- uses: actions/setup-go@v1
with:
go-version: '1.13.x'
go-version: '1.15.x'
- name: Cache Golang Packages
uses: actions/cache@v1
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.13 AS build-env
FROM golang:1.15 AS build-env
COPY . /build
WORKDIR /build

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

go 1.13
go 1.15

require (
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.0
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 @@ -25,7 +25,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.13', dockerOptions: '-u 0', dockerEnvVars: [
steps.dockerExecute(script: steps, dockerImage: 'golang:1.15', 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 485faed

Please sign in to comment.