From 474080fa310c4208121e9a5aa06f82ed4dc67e31 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 09:18:05 +0100 Subject: [PATCH 1/6] GitHub: update actions/checkout to v4 --- .github/workflows/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6a6e65035..d1c4b5e17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -68,7 +68,7 @@ jobs: steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -96,7 +96,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -132,7 +132,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -160,7 +160,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -190,7 +190,7 @@ jobs: - unit steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -210,7 +210,7 @@ jobs: runs-on: ubuntu-latest steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -253,7 +253,7 @@ jobs: if: '!contains(github.event.pull_request.labels.*.name, ''no-changelog'')' steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: release notes check run: scripts/check-release-notes.sh From f8881cc1a5fca681e44438f7e7043913ef1a39cd Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 09:18:06 +0100 Subject: [PATCH 2/6] GitHub: add key-prefix and use-build-cache to setup-go action This allows us to control the cache key and whether we want to cache the Go build cache (which can grow very large). --- .github/actions/setup-go/action.yml | 52 +++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup-go/action.yml b/.github/actions/setup-go/action.yml index 489f608d5..b9d287a22 100644 --- a/.github/actions/setup-go/action.yml +++ b/.github/actions/setup-go/action.yml @@ -4,6 +4,15 @@ inputs: go-version: description: "The version of Golang to set up" required: true + key-prefix: + description: "A prefix to use for the cache key, to separate cache entries from other workflows" + required: false + use-build-cache: + description: "Whether to use the build cache" + required: false + # Boolean values aren't supported in the workflow syntax, so we use a + # string. To not confuse the value with true/false, we use 'yes' and 'no'. + default: 'yes' runs: using: "composite" @@ -16,19 +25,42 @@ runs: git config --global core.autocrlf false - name: setup go ${{ inputs.go-version }} - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: '${{ inputs.go-version }}' - - name: go cache - uses: actions/cache@v3 + - name: go module and build cache + if: ${{ inputs.use-build-cache == 'yes' }} + uses: actions/cache@v4 with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) path: | - /home/runner/go/pkg/mod - /home/runner/.cache/go-build - key: litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + ~\AppData\Local\go-build + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} restore-keys: | - litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }} - litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}- - litd-${{ runner.os }}-go-${{ inputs.go-version }}- - litd-${{ runner.os }}-go- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}- + + - name: go module cache + if: ${{ inputs.use-build-cache == 'no' }} + uses: actions/cache@v4 + with: + # Just the module download cache. + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}- + ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache- + + - name: set GOPATH + shell: bash + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV From 4a3a628b83f9a4e21ed52a29c99ce5ba16650740 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 09:18:07 +0100 Subject: [PATCH 3/6] GitHub: add Golang cross compilation check --- .github/workflows/main.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1c4b5e17..a0730ed8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,6 +88,40 @@ jobs: - name: build CLI binaries run: make go-install-cli + ######################## + # cross compilation + ######################## + cross-compile: + name: cross compilation + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + # Please keep this list in sync with make/release_flags.mk! + include: + - name: i386 + sys: linux-386 + - name: amd64 + sys: darwin-amd64 linux-amd64 windows-amd64 + - name: arm + sys: darwin-arm64 linux-armv6 linux-armv7 linux-arm64 + steps: + - name: cleanup space + run: rm -rf /opt/hostedtoolcache + + - name: git checkout + uses: actions/checkout@v4 + + - name: setup go ${{ env.GO_VERSION }} + uses: ./.github/actions/setup-go + with: + go-version: '${{ env.GO_VERSION }}' + key-prefix: cross-compile + use-build-cache: 'no' + + - name: build release for all architectures (skip app build) + run: make go-release sys="${{ matrix.sys }}" + ######################## # proto compile check ######################## From 1657584eb9560767ff00b1eb00a3d9ea6a5ab9b7 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 09:22:07 +0100 Subject: [PATCH 4/6] accounts: fix compilation issue for i386 systems Apparently the %d formatting directive implicitly uses `int` as its data type, which on i386 systems is int32. So the value math.MaxInt64 overflows that value, which causes the compilation to fail. --- accounts/store_kvdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/store_kvdb.go b/accounts/store_kvdb.go index 54c25beb7..017079898 100644 --- a/accounts/store_kvdb.go +++ b/accounts/store_kvdb.go @@ -244,8 +244,8 @@ func (s *BoltStore) IncreaseAccountBalance(_ context.Context, id AccountID, update := func(account *OffChainBalanceAccount) error { if amount > math.MaxInt64 { - return fmt.Errorf("amount %d exceeds the maximum of %d", - amount, math.MaxInt64) + return fmt.Errorf("amount %v exceeds the maximum of %v", + amount, int64(math.MaxInt64)) } account.CurrentBalance += int64(amount) From 2f72da0490e4c864c5dbd78a00c3fa4ba5b7dc93 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 10:10:56 +0100 Subject: [PATCH 5/6] GitHub: fix permission denied in lint CI step This attempts to fix the following error that sometimes occurs on the GitHub runners: go: github.com/lightninglabs/lightning-terminal imports github.com/lightningnetwork/lnd/kvdb imports github.com/lightningnetwork/lnd/kvdb/etcd imports go.etcd.io/etcd/server/v3/embed: mkdir /home/runner/go/pkg/mod/cache/download/go.etcd.io/etcd/server: permission denied The suspicion is that the lint step that runs as root within docker changes the permissions of some of the module cache directories. So by simply changing the order of operations, this should be fixed. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0730ed8d..d26c4210c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -207,7 +207,7 @@ jobs: run: mkdir -p app/build; touch app/build/index.html - name: run check - run: make lint mod-check + run: make mod-check && make lint ######################## # unit tests From 415e589c6370603814c85a2a50dd6418c448f380 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 23 Jan 2025 10:15:43 +0100 Subject: [PATCH 6/6] GitHub: cancel jobs for previous pushes of PR This takes over two more settings we have in the lnd repo. The first is to cancel existing CI runs for the same PR if it is pushed again before the previous run has completed. The second is just for consistency, to make sure all shells are bash shells. --- .github/workflows/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d26c4210c..9dd797002 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,15 @@ on: branches: - "*" +concurrency: + # Cancel any previous workflows if they are from a PR or push. + group: ${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + env: # If you change this value, please change it in the following files as well: # /Dockerfile