From c4ca7b99e28cd448150845d4987dccb6b44939d1 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 6 Jan 2023 08:58:40 +0100 Subject: [PATCH 1/4] GitHub: remove Go env variable override For some reason we used to override the GOCACHE and GOPATH variables earlier. This now causes the updated cache action not to pick up any caches. As the overrides shouldn't be needed anymore, we remove them. --- .github/actions/setup-go/action.yml | 5 +++++ .github/workflows/main.yml | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 1db347509..0c1428a3a 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -26,3 +26,8 @@ runs: key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-${{ env.GO_VERSION }}- + + - name: set GOPATH + shell: bash + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5614a387a..da8806135 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,9 +18,6 @@ defaults: shell: bash env: - # go needs absolute directories, using the $HOME variable doesn't work here. - GOCACHE: /home/runner/work/go/pkg/build - GOPATH: /home/runner/work/go BITCOIN_VERSION: "23.0" # If you change this value, please change it in the following files as well: @@ -236,9 +233,6 @@ jobs: windows-integration-test: name: run windows itest runs-on: windows-latest - env: - GOCACHE: ${{ github.workspace }}/go/pkg/build - GOPATH: ${{ github.workspace }}/go steps: - name: git checkout uses: actions/checkout@v3 @@ -320,9 +314,6 @@ jobs: new-windows-integration-test: name: run new windows itest runs-on: windows-latest - env: - GOCACHE: ${{ github.workspace }}/go/pkg/build - GOPATH: ${{ github.workspace }}/go steps: - name: git checkout uses: actions/checkout@v3 From 984fc3a2ec08e13a2b0f80b56525cc8d76b14f16 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 6 Jan 2023 08:58:41 +0100 Subject: [PATCH 2/4] GitHub: make setup-go action more versatile With this commit we allow the Go version that is set up to be configurable and not dependent on a specific environment variable. This will allow us to eventually extract the action into a tooling repository. --- .github/actions/setup-go/action.yml | 16 +++++---- .github/workflows/main.yml | 50 +++++++++++++++++------------ 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 0c1428a3a..175cb78b5 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -1,14 +1,18 @@ -# A resuable workflow that's used to setup the go enviroment and cache. -name: Setup go enviroment +name: "Setup Golang environment" +description: "A reusable workflow that's used to set up the Go environment and cache." +inputs: + go-version: + description: "The version of Golang to set up" + required: true runs: using: "composite" steps: - - name: setup go ${{ env.GO_VERSION }} + - name: setup go ${{ inputs.go-version }} uses: actions/setup-go@v3 with: - go-version: '${{ env.GO_VERSION }}' + go-version: '${{ inputs.go-version }}' - name: go cache uses: actions/cache@v3 @@ -23,9 +27,9 @@ runs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go-${{ env.GO_VERSION }}- + ${{ runner.os }}-go-${{ inputs.go-version }}- - name: set GOPATH shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da8806135..a53e06071 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,9 +39,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: run check run: make rpc-check @@ -68,9 +69,10 @@ jobs: with: fetch-depth: 0 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: fetch and rebase on ${{ github.base_ref }} run: | @@ -95,9 +97,10 @@ jobs: with: fetch-depth: 0 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: check code format run: make fmt-check @@ -115,9 +118,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: build release for all architectures run: make release @@ -132,9 +136,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: check all command line flags exist in sample-lnd.conf file run: make sample-conf-check @@ -158,9 +163,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -204,9 +210,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -237,9 +244,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: run itest run: make itest-parallel windows=1 tranches=2 parallel=2 @@ -285,9 +293,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: install bitcoind run: ./scripts/install_bitcoind.sh @@ -318,9 +327,10 @@ jobs: - name: git checkout uses: actions/checkout@v3 - - id: setup - name: Setup go env + - name: setup go ${{ env.GO_VERSION }} uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' - name: run new itest run: make itest-parallel temptest=true windows=1 tranches=2 parallel=2 From a074c801d197860389934544943c0e8f1e4e37b0 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 6 Jan 2023 08:58:42 +0100 Subject: [PATCH 3/4] GitHub: add job ID to cache key To avoid the problem where multiple jobs try to create the same cache entry, we add the GitHub job ID to the cache key. The two restore keys make it possible that a job can also restore a cache entry from another job if none for the current job exist yet. --- .github/actions/setup-go/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 175cb78b5..f0d7b9abf 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -27,8 +27,9 @@ runs: ~/.cache/go-build ~/Library/Caches/go-build ~\AppData\Local\go-build - key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }} + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} restore-keys: | + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}- ${{ runner.os }}-go-${{ inputs.go-version }}- - name: set GOPATH From f16a2f11df43347dce60b8600309acb33feb94a9 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 6 Jan 2023 08:58:43 +0100 Subject: [PATCH 4/4] docs: add release notes --- docs/release-notes/release-notes-0.16.0.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/release-notes-0.16.0.md b/docs/release-notes/release-notes-0.16.0.md index 6367684f0..d6c889a90 100644 --- a/docs/release-notes/release-notes-0.16.0.md +++ b/docs/release-notes/release-notes-0.16.0.md @@ -312,7 +312,8 @@ certain large transactions](https://github.com/lightningnetwork/lnd/pull/7100). branch](https://github.com/lightningnetwork/lnd/pull/7103) rather than just using the master branch. And [skip the commit check](https://github.com/lightningnetwork/lnd/pull/7114) for all non-PR - events. + events. The Golang build cache [was also optimized to speed up tests and + builds](https://github.com/lightningnetwork/lnd/pull/7295). * Fixed docker image version used in [`tools`](https://github.com/lightningnetwork/lnd/pull/7254).