Skip to content

Commit 789b090

Browse files
authored
build: Test against Go 1.25 and Node LTS (#2022)
1 parent 3d37aae commit 789b090

File tree

9 files changed

+95
-36
lines changed

9 files changed

+95
-36
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,26 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
go: ['1.20', '1.21']
12+
go: ['1.24', '1.25']
1313
steps:
14-
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
15-
14+
- name: Check out source
15+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1616
- name: Set up Go
17-
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 #v4.0.1
17+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
1818
with:
1919
go-version: ${{ matrix.go }}
20-
20+
- name: Use lint cache
21+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
22+
with:
23+
path: |
24+
~/.cache/golangci-lint
25+
key: go-lint-${{ matrix.go }}-${{ hashFiles('./go.sum') }}
26+
restore-keys: go-lint-${{ matrix.go }}
27+
- name: Install Linters
28+
run: "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0"
2129
- name: Go Build dcrdata
2230
run: go build -v ./...
2331
working-directory: ./cmd/dcrdata
24-
25-
- name: Install Linters
26-
run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2"
27-
2832
- name: Go Tests
2933
run: |
3034
./run_tests.sh
@@ -34,12 +38,12 @@ jobs:
3438
runs-on: ubuntu-latest
3539
strategy:
3640
matrix:
37-
node-version: [16.x, 18.x]
41+
node-version: ['lts/*']
3842
steps:
39-
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
43+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4044

4145
- name: Use nodejs ${{ matrix.node-version }}
42-
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3.6.0
46+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0
4347
with:
4448
node-version: ${{ matrix.node-version }}
4549

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ jobs:
55
build:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
8+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
99
- name: Build the Docker image
1010
run: docker build -t decred/dcrdata:$(date +%s) .

.golangci.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1+
version: "2"
12
run:
23
timeout: 10m
3-
4-
output:
5-
format: github-actions,colored-line-number
6-
74
linters:
8-
disable-all: true
5+
default: none
96
enable:
107
- asciicheck
118
- bidichk
129
- durationcheck
13-
- exportloopref
14-
- gofmt
15-
- goimports
16-
- gosimple
10+
- errchkjson
1711
- govet
1812
- grouper
1913
- ineffassign
2014
- makezero
2115
- misspell
16+
- nilerr
2217
- nosprintfhostport
2318
- reassign
19+
- rowserrcheck
2420
- tparallel
25-
- typecheck
2621
- unconvert
2722
- unparam
23+
exclusions:
24+
generated: lax
25+
presets:
26+
- comments
27+
- common-false-positives
28+
- legacy
29+
- std-error-handling
30+
paths:
31+
- third_party$
32+
- builtin$
33+
- examples$
34+
formatters:
35+
enable:
36+
- gofmt
37+
- goimports
38+
exclusions:
39+
generated: lax
40+
paths:
41+
- third_party$
42+
- builtin$
43+
- examples$

db/dbtypes/types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,8 +1047,11 @@ func (p *VinTxPropertyARRAY) Scan(src interface{}) error {
10471047
if !ok {
10481048
return fmt.Errorf("type assertion .(map[string]interface) failed")
10491049
}
1050-
b, _ := json.Marshal(VinTxPropertyMapIface)
1051-
err := json.Unmarshal(b, &ba[ii])
1050+
b, err := json.Marshal(VinTxPropertyMapIface)
1051+
if err != nil {
1052+
return err
1053+
}
1054+
err = json.Unmarshal(b, &ba[ii])
10521055
if err != nil {
10531056
return err
10541057
}

db/dcrpg/pgblockchain.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (pgb *ChainDB) timeoutError() string {
307307
// replaces a sql.ErrNoRows with a dbtypes.ErrNoResult.
308308
func (pgb *ChainDB) replaceCancelError(err error) error {
309309
if err == nil {
310-
return err
310+
return nil
311311
}
312312

313313
if errors.Is(err, sql.ErrNoRows) {
@@ -5036,7 +5036,7 @@ func (pgb *ChainDB) GetVoteInfo(txhash *chainhash.Hash) (*apitypes.VoteInfo, err
50365036
tx, err := pgb.Client.GetRawTransaction(pgb.ctx, txhash)
50375037
if err != nil {
50385038
log.Errorf("GetRawTransaction failed for: %v", txhash)
5039-
return nil, nil
5039+
return nil, err
50405040
}
50415041

50425042
validation, version, bits, choices, tspendVotes, err := txhelpers.SSGenVoteChoices(tx.MsgTx(), pgb.chainParams)
@@ -5618,7 +5618,6 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
56185618
log.Errorf("GetAddressTransactionsRawWithSkip: SelectVinsForAddress %s: %v", addr, err)
56195619
return nil
56205620
}
5621-
defer rows.Close()
56225621

56235622
type vinIndexed struct {
56245623
*apitypes.VinShort
@@ -5633,6 +5632,7 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
56335632
if err = rows.Scan(&txid, &idx, &vinTxID, &vin.Vout, &vin.Tree, &val,
56345633
&vin.BlockHeight, &vin.BlockIndex); err != nil {
56355634
log.Errorf("GetAddressTransactionsRawWithSkip: SelectVinsForAddress %s: %v", addr, err)
5635+
rows.Close()
56365636
return nil
56375637
}
56385638
vin.Txid = vinTxID.String()
@@ -5643,14 +5643,21 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
56435643
// Coinbase, Stakebase, etc. booleans are set on TxType detection below.
56445644
vins[txid] = append(vins[txid], &vinIndexed{&vin, idx})
56455645
}
5646+
if err = rows.Err(); err != nil {
5647+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5648+
return nil
5649+
}
5650+
if err = rows.Close(); err != nil {
5651+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5652+
return nil
5653+
}
56465654

56475655
// tx
56485656
rows, err = pgb.db.QueryContext(ctx, internal.SelectAddressTxns, addr, count, skip)
56495657
if err != nil {
56505658
log.Errorf("GetAddressTransactionsRawWithSkip: SelectAddressTxns %s: %v", addr, err)
56515659
return nil
56525660
}
5653-
defer rows.Close()
56545661

56555662
txns := make(map[dbtypes.ChainHash]*apitypes.AddressTxRaw)
56565663

@@ -5663,6 +5670,7 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
56635670
if err = rows.Scan(&txid, &blockHash, &blockHeight,
56645671
&tx.Time.S, &tx.Version, &tx.Locktime, &tx.Size, &tx.Type, &numVins, &numVouts /*, &vinDbIDs, &voutDbIDs*/); err != nil {
56655672
log.Errorf("GetAddressTransactionsRawWithSkip: Scan %s: %v", addr, err)
5673+
rows.Close()
56665674
return nil
56675675
}
56685676
tx.TxID = txid.String()
@@ -5701,21 +5709,29 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
57015709

57025710
txs = append(txs, &tx)
57035711
}
5712+
if err = rows.Err(); err != nil {
5713+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5714+
return nil
5715+
}
5716+
if err = rows.Close(); err != nil {
5717+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5718+
return nil
5719+
}
57045720

57055721
// vouts
57065722
rows, err = pgb.db.QueryContext(ctx, internal.SelectVoutsForAddress, addr, count, skip)
57075723
if err != nil {
57085724
log.Errorf("GetAddressTransactionsRawWithSkip: SelectVoutsForAddress %s: %v", addr, err)
57095725
return nil
57105726
}
5711-
defer rows.Close()
57125727

57135728
for rows.Next() {
57145729
var txid dbtypes.ChainHash // funding tx
57155730
var vout apitypes.Vout
57165731
var val int64
57175732
if err = rows.Scan(&val, &txid, &vout.N, &vout.Version); err != nil {
57185733
log.Errorf("GetAddressTransactionsRawWithSkip: SelectVoutsForAddress %s: %v", addr, err)
5734+
rows.Close()
57195735
return nil
57205736
}
57215737

@@ -5733,6 +5749,14 @@ func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(addr string, count, skip i
57335749
// vout.ScriptPubKeyDecoded = decPkScript(vout.Version, pkScript, isTicketCommit, pgb.chainParams)
57345750
tx.Vout = append(tx.Vout, vout)
57355751
}
5752+
if err = rows.Err(); err != nil {
5753+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5754+
return nil
5755+
}
5756+
if err = rows.Close(); err != nil {
5757+
log.Errorf("GetAddressTransactionsRawWithSkip: %v", err)
5758+
return nil
5759+
}
57365760

57375761
// Get pkscripts that db doesn't have.
57385762
for hash, atx := range txns {

db/dcrpg/queries.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,10 +3634,13 @@ func insertBlock(db *sql.DB, dbBlock *dbtypes.Block, isValid, isMainchain, check
36343634
func insertBlockPrevNext(db *sql.DB, blockDbID uint64,
36353635
hash, prev, next *dbtypes.ChainHash) error {
36363636
rows, err := db.Query(internal.InsertBlockPrevNext, blockDbID, prev, hash, next)
3637-
if err == nil {
3638-
return rows.Close()
3637+
if err != nil {
3638+
return err
36393639
}
3640-
return err
3640+
if err = rows.Err(); err != nil {
3641+
return err
3642+
}
3643+
return rows.Close()
36413644
}
36423645

36433646
// insertBlockStats inserts the block stats into the stats table.

db/dcrpg/system.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ func retrieveSysSettings(stmt string, db *sql.DB) (PGSettings, error) {
197197
SourceLine: line,
198198
}
199199
}
200+
if err = rows.Err(); err != nil {
201+
return nil, err
202+
}
200203

201204
return settings, nil
202205
}

db/dcrpg/tables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TableExists(db *sql.DB, tableName string) (bool, error) {
5959
log.Errorf("Close of Query failed: %v", e)
6060
}
6161
}()
62-
return rows.Next(), nil
62+
return rows.Next(), rows.Err()
6363
}
6464

6565
func dropTable(db SqlExecutor, tableName string) error {

pubsub/psclient/client_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,10 @@ func TestDecodeMsgNewBlock(t *testing.T) {
788788

789789
func TestDecodeMsgPing(t *testing.T) {
790790
expectedInt := 2
791-
MessageJSON, _ := json.Marshal(expectedInt)
791+
MessageJSON, err := json.Marshal(expectedInt)
792+
if err != nil {
793+
t.Fatalf("Failed to marshal %d: %v", expectedInt, err)
794+
}
792795
msgPing := &pstypes.WebSocketMessage{
793796
EventId: "ping",
794797
Message: MessageJSON,
@@ -806,7 +809,10 @@ func TestDecodeMsgPing(t *testing.T) {
806809

807810
func TestDecodeMsgString(t *testing.T) {
808811
expectedStr := "meow"
809-
MessageJSON, _ := json.Marshal(expectedStr)
812+
MessageJSON, err := json.Marshal(expectedStr)
813+
if err != nil {
814+
t.Fatalf("Failed to marshal %q: %v", expectedStr, err)
815+
}
810816
msgPing := &pstypes.WebSocketMessage{
811817
EventId: "message",
812818
Message: MessageJSON,

0 commit comments

Comments
 (0)