Skip to content

Commit f1182e4

Browse files
authored
Merge pull request #9521 from guggero/coverage-fixes
unit: remove GOACC, use Go 1.20 native coverage functionality
2 parents dc0ba72 + 7761e37 commit f1182e4

File tree

9 files changed

+39
-136
lines changed

9 files changed

+39
-136
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ jobs:
218218
fail-fast: false
219219
matrix:
220220
unit_type:
221-
- btcd unit-cover
221+
- unit-cover
222222
- unit tags="kvdb_etcd"
223223
- unit tags="kvdb_postgres"
224224
- unit tags="kvdb_sqlite"
225-
- btcd unit-race
225+
- unit-race
226226
- unit-module
227227

228228
steps:
@@ -259,13 +259,18 @@ jobs:
259259
- name: run ${{ matrix.unit_type }}
260260
run: make ${{ matrix.unit_type }}
261261

262+
- name: Clean coverage
263+
run: grep -Ev '(\.pb\.go|\.pb\.json\.go|\.pb\.gw\.go)' coverage.txt > coverage-norpc.txt
264+
if: matrix.unit_type == 'unit-cover'
265+
262266
- name: Send coverage
263-
uses: ziggie1984/actions-goveralls@c440f43938a4032b627d2b03d61d4ae1a2ba2b5c
264-
if: matrix.unit_type == 'btcd unit-cover'
267+
uses: coverallsapp/github-action@v2
268+
if: matrix.unit_type == 'unit-cover'
265269
continue-on-error: true
266270
with:
267-
path-to-profile: coverage.txt
271+
file: coverage-norpc.txt
268272
flag-name: 'unit'
273+
format: 'golang'
269274
parallel: true
270275

271276

@@ -314,13 +319,18 @@ jobs:
314319
- name: run ${{ matrix.name }}
315320
run: make itest-parallel tranches=${{ env.TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}
316321

322+
- name: Clean coverage
323+
run: grep -Ev '(\.pb\.go|\.pb\.json\.go|\.pb\.gw\.go)' coverage.txt > coverage-norpc.txt
324+
if: ${{ contains(matrix.args, 'cover=1') }}
325+
317326
- name: Send coverage
318327
if: ${{ contains(matrix.args, 'cover=1') }}
319328
continue-on-error: true
320-
uses: ziggie1984/actions-goveralls@c440f43938a4032b627d2b03d61d4ae1a2ba2b5c
329+
uses: coverallsapp/github-action@v2
321330
with:
322-
path-to-profile: coverage.txt
331+
file: coverage-norpc.txt
323332
flag-name: 'itest-${{ matrix.name }}'
333+
format: 'golang'
324334
parallel: true
325335

326336
- name: Zip log files on failure
@@ -382,13 +392,18 @@ jobs:
382392
- name: run ${{ matrix.name }}
383393
run: make itest-parallel tranches=${{ env.SMALL_TRANCHES }} ${{ matrix.args }} shuffleseed=${{ github.run_id }}${{ strategy.job-index }}
384394

395+
- name: Clean coverage
396+
run: grep -Ev '(\.pb\.go|\.pb\.json\.go|\.pb\.gw\.go)' coverage.txt > coverage-norpc.txt
397+
if: ${{ contains(matrix.args, 'cover=1') }}
398+
385399
- name: Send coverage
386400
if: ${{ contains(matrix.args, 'cover=1') }}
387401
continue-on-error: true
388-
uses: ziggie1984/actions-goveralls@c440f43938a4032b627d2b03d61d4ae1a2ba2b5c
402+
uses: coverallsapp/github-action@v2
389403
with:
390-
path-to-profile: coverage.txt
404+
file: coverage-norpc.txt
391405
flag-name: 'itest-${{ matrix.name }}'
406+
format: 'golang'
392407
parallel: true
393408

394409
- name: Zip log files on failure
@@ -552,7 +567,7 @@ jobs:
552567
runs-on: ubuntu-latest
553568
steps:
554569
- name: Send coverage
555-
uses: ziggie1984/actions-goveralls@c440f43938a4032b627d2b03d61d4ae1a2ba2b5c
570+
uses: coverallsapp/github-action@v2
556571
continue-on-error: true
557572
with:
558573
parallel-finished: true

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ jobs:
121121
```
122122
tar -xvzf vendor.tar.gz
123123
tar -xvzf lnd-source-${{ env.RELEASE_VERSION }}.tar.gz
124-
GO111MODULE=on go install -v -mod=vendor -ldflags "-X github.com/lightningnetwork/lnd/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/lnd
125-
GO111MODULE=on go install -v -mod=vendor -ldflags "-X github.com/lightningnetwork/lnd/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/lncli
124+
go install -v -mod=vendor -ldflags "-X github.com/lightningnetwork/lnd/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/lnd
125+
go install -v -mod=vendor -ldflags "-X github.com/lightningnetwork/lnd/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/lncli
126126
```
127127
128128
The `-mod=vendor` flag tells the `go build` command that it doesn't need to fetch the dependencies, and instead, they're all enclosed in the local vendor directory.

Makefile

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
PKG := github.com/lightningnetwork/lnd
2-
ESCPKG := github.com\/lightningnetwork\/lnd
32
MOBILE_PKG := $(PKG)/mobile
43
TOOLS_DIR := tools
54

65
GOCC ?= go
76
PREFIX ?= /usr/local
87

98
BTCD_PKG := github.com/btcsuite/btcd
10-
GOACC_PKG := github.com/ory/go-acc
119
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
1210

1311
GO_BIN := ${GOPATH}/bin
1412
BTCD_BIN := $(GO_BIN)/btcd
1513
GOIMPORTS_BIN := $(GO_BIN)/gosimports
1614
GOMOBILE_BIN := $(GO_BIN)/gomobile
17-
GOACC_BIN := $(GO_BIN)/go-acc
1815

1916
MOBILE_BUILD_DIR :=${GOPATH}/src/$(MOBILE_PKG)/build
2017
IOS_BUILD_DIR := $(MOBILE_BUILD_DIR)/ios
@@ -28,19 +25,14 @@ COMMIT := $(shell git describe --tags --dirty)
2825
ACTIVE_GO_VERSION := $(shell $(GOCC) version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p')
2926
ACTIVE_GO_VERSION_MINOR := $(shell echo $(ACTIVE_GO_VERSION) | cut -d. -f2)
3027

31-
LOOPVARFIX :=
32-
ifeq ($(shell expr $(ACTIVE_GO_VERSION_MINOR) \>= 21), 1)
33-
LOOPVARFIX := GOEXPERIMENT=loopvar
34-
endif
35-
3628
# GO_VERSION is the Go version used for the release build, docker files, and
3729
# GitHub Actions. This is the reference version for the project. All other Go
3830
# versions are checked against this version.
3931
GO_VERSION = 1.23.6
4032

41-
GOBUILD := $(LOOPVARFIX) $(GOCC) build -v
42-
GOINSTALL := $(LOOPVARFIX) $(GOCC) install -v
43-
GOTEST := $(LOOPVARFIX) $(GOCC) test
33+
GOBUILD := $(GOCC) build -v
34+
GOINSTALL := $(GOCC) install -v
35+
GOTEST := $(GOCC) test
4436

4537
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go")
4638

@@ -92,10 +84,6 @@ all: scratch check install
9284
# ============
9385
# DEPENDENCIES
9486
# ============
95-
$(GOACC_BIN):
96-
@$(call print, "Installing go-acc.")
97-
cd $(TOOLS_DIR); $(GOCC) install -trimpath -tags=tools $(GOACC_PKG)
98-
9987
$(BTCD_BIN):
10088
@$(call print, "Installing btcd.")
10189
cd $(TOOLS_DIR); $(GOCC) install -trimpath $(BTCD_PKG)
@@ -258,12 +246,12 @@ unit-debug: $(BTCD_BIN)
258246
$(UNIT_DEBUG)
259247

260248
#? unit-cover: Run unit tests in coverage mode
261-
unit-cover: $(GOACC_BIN)
249+
unit-cover: $(BTCD_BIN)
262250
@$(call print, "Running unit coverage tests.")
263-
$(GOACC)
251+
$(UNIT_COVER)
264252

265253
#? unit-race: Run unit tests in race detector mode
266-
unit-race:
254+
unit-race: $(BTCD_BIN)
267255
@$(call print, "Running unit race tests.")
268256
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
269257

make/builder.Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ MAINTAINER Olaoluwa Osuntokun <laolu@lightning.engineering>
77
# Golang build related environment variables that are static and used for all
88
# architectures/OSes.
99
ENV GODEBUG netdns=cgo
10-
ENV GO111MODULE=auto
1110
ENV CGO_ENABLED=0
1211

1312
# Set up cache directories. Those will be mounted from the host system to speed

make/testing_flags.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ITEST_FLAGS =
66
ITEST_COVERAGE =
77
COLLECT_ITEST_COVERAGE =
88
EXEC_SUFFIX =
9-
COVER_PKG = $$($(GOCC) list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)' | grep -v lnrpc)
9+
COVER_PKG = $$($(GOCC) list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)')
10+
COVER_FLAGS = -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(PKG)/...
1011
NUM_ITEST_TRANCHES = 4
1112
ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
1213
POSTGRES_START_DELAY = 5
@@ -116,7 +117,6 @@ TEST_FLAGS += -test.count=1
116117
endif
117118

118119
GOLIST := $(GOCC) list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
119-
GOLISTCOVER := $(shell $(GOCC) list -tags="$(DEV_TAGS)" -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
120120

121121
# UNIT_TARGTED is undefined iff a specific package and/or unit test case is
122122
# not being targeted.
@@ -150,4 +150,4 @@ endif
150150
ITEST_TAGS := $(DEV_TAGS) $(RPC_TAGS) integration $(backend)
151151

152152
# Construct the coverage test command with the added build flags.
153-
GOACC := $(GOACC_BIN) $(COVER_PKG) -- -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
153+
UNIT_COVER := $(GOTEST) $(COVER_FLAGS) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(COVER_PKG)

scripts/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function check_tag_correct() {
9898
fi
9999

100100
# Build lnd to extract version.
101-
env GOEXPERIMENT=loopvar go build ${PKG}/cmd/lnd
101+
go build ${PKG}/cmd/lnd
102102

103103
# Extract version command output.
104104
lnd_version_output=$(./lnd --version)
@@ -189,8 +189,8 @@ required Go version ($goversion)."
189189
pushd "${dir}"
190190

191191
green " - Building: ${os} ${arch} ${arm} with build tags '${buildtags}'"
192-
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lnd
193-
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli
192+
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lnd
193+
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli
194194
popd
195195

196196
# Add the hashes for the individual binaries as well for easy verification

tools/go.mod

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.23.6
55
require (
66
github.com/btcsuite/btcd v0.24.2
77
github.com/golangci/golangci-lint v1.64.5
8-
github.com/ory/go-acc v0.2.8
98
github.com/rinchsan/gosimports v0.1.5
109
)
1110

@@ -48,7 +47,6 @@ require (
4847
github.com/butuzov/mirror v1.3.0 // indirect
4948
github.com/catenacyber/perfsprint v0.8.1 // indirect
5049
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
51-
github.com/cespare/xxhash v1.1.0 // indirect
5250
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5351
github.com/charithe/durationcheck v0.0.10 // indirect
5452
github.com/chavacava/garif v0.1.0 // indirect
@@ -60,7 +58,6 @@ require (
6058
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
6159
github.com/decred/dcrd/lru v1.0.0 // indirect
6260
github.com/denis-tingaikin/go-header v0.5.0 // indirect
63-
github.com/dgraph-io/ristretto v0.0.2 // indirect
6461
github.com/ettle/strcase v0.2.0 // indirect
6562
github.com/fatih/color v1.18.0 // indirect
6663
github.com/fatih/structtag v1.2.0 // indirect
@@ -90,7 +87,6 @@ require (
9087
github.com/golangci/revgrep v0.8.0 // indirect
9188
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
9289
github.com/google/go-cmp v0.6.0 // indirect
93-
github.com/google/uuid v1.6.0 // indirect
9490
github.com/gordonklaus/ineffassign v0.1.0 // indirect
9591
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
9692
github.com/gostaticanalysis/comment v1.4.2 // indirect
@@ -139,8 +135,6 @@ require (
139135
github.com/nishanths/predeclared v0.2.2 // indirect
140136
github.com/nunnatsa/ginkgolinter v0.19.0 // indirect
141137
github.com/olekukonko/tablewriter v0.0.5 // indirect
142-
github.com/ory/viper v1.7.5 // indirect
143-
github.com/pborman/uuid v1.2.0 // indirect
144138
github.com/pelletier/go-toml v1.9.5 // indirect
145139
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
146140
github.com/pmezard/go-difflib v1.0.0 // indirect

0 commit comments

Comments
 (0)