Skip to content

Commit 44ba94e

Browse files
authored
Merge pull request #527 from sputn1ck/github_actions
ci: add github actions
2 parents 446f163 + 4803941 commit 44ba94e

19 files changed

+158
-53
lines changed

.github/workflows/main.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
pull_request:
8+
branches:
9+
- "*"
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
env:
16+
# go needs absolute directories, using the $HOME variable doesn't work here.
17+
GOCACHE: /home/runner/work/go/pkg/build
18+
GOPATH: /home/runner/work/go
19+
GO111MODULE: on
20+
21+
# If you change this value, please change it in the following files as well:
22+
# /Dockerfile
23+
GO_VERSION: 1.17
24+
25+
jobs:
26+
########################
27+
# RPC compile and check
28+
########################
29+
rpc-check:
30+
name: RPC compilation check
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: git checkout
34+
uses: actions/checkout@v2
35+
36+
- name: setup go ${{ env.GO_VERSION }}
37+
uses: actions/setup-go@v2
38+
with:
39+
go-version: '~${{ env.GO_VERSION }}'
40+
41+
- name: RPC for JS compilation
42+
run: make rpc-js-compile
43+
44+
- name: run check
45+
run: make rpc-check
46+
47+
########################
48+
# go mod check
49+
########################
50+
mod-check:
51+
name: go mod check
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: git checkout
55+
uses: actions/checkout@v2
56+
57+
- name: setup go ${{ env.GO_VERSION }}
58+
uses: actions/setup-go@v2
59+
with:
60+
go-version: '~${{ env.GO_VERSION }}'
61+
62+
- name: run check
63+
run: make mod-check
64+
65+
########################
66+
# build and lint code
67+
########################
68+
lint:
69+
name: build and lint code
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: git checkout
73+
uses: actions/checkout@v2
74+
with:
75+
fetch-depth: 0
76+
77+
- name: go cache
78+
uses: actions/cache@v1
79+
with:
80+
path: /home/runner/work/go
81+
key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
82+
restore-keys: |
83+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
84+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
85+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-
86+
loop-${{ runner.os }}-go-
87+
88+
- name: setup go ${{ env.GO_VERSION }}
89+
uses: actions/setup-go@v2
90+
with:
91+
go-version: '~${{ env.GO_VERSION }}'
92+
93+
- name: build
94+
run: make build tags=dev
95+
96+
- name: lint
97+
run: make lint
98+
99+
########################
100+
# run unit tests
101+
########################
102+
unit-test:
103+
name: run unit tests
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: git checkout
107+
uses: actions/checkout@v2
108+
109+
- name: go cache
110+
uses: actions/cache@v1
111+
with:
112+
path: /home/runner/work/go
113+
key: lnd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
114+
restore-keys: |
115+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
116+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
117+
loop-${{ runner.os }}-go-${{ env.GO_VERSION }}-
118+
loop-${{ runner.os }}-go-
119+
120+
- name: setup go ${{ env.GO_VERSION }}
121+
uses: actions/setup-go@v2
122+
with:
123+
go-version: '~${{ env.GO_VERSION }}'
124+
125+
- name: run unit tests
126+
run: make unit

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ linters:
106106
- nilnil
107107
- stylecheck
108108
- thelper
109-
109+
- revive
110+
110111
# Additions compared to LND
111112
- exhaustruct
112113

@@ -120,6 +121,7 @@ issues:
120121
- path: _test\.go
121122
linters:
122123
- forbidigo
124+
- unparam
123125

124126
# Allow fmt.Printf() in loopd
125127
- path: cmd/loopd/*

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (s *Client) resumeSwaps(ctx context.Context,
355355
if pend.State().State.Type() != loopdb.StateTypePending {
356356
continue
357357
}
358-
swap, err := resumeLoopOutSwap(ctx, swapCfg, pend)
358+
swap, err := resumeLoopOutSwap(swapCfg, pend)
359359
if err != nil {
360360
log.Errorf("resuming loop out swap: %v", err)
361361
continue

client_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ func TestLoopOutFailWrongAmount(t *testing.T) {
141141
m.prepayInvoiceAmt += 10
142142
}, ErrPrepayAmountTooHigh)
143143
})
144-
145144
}
146145

147146
// TestLoopOutResume tests that swaps in various states are properly resumed

cmd/loop/loopin.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ func loopIn(ctx *cli.Context) error {
9494
amtStr = ctx.String("amt")
9595
case ctx.NArg() > 0:
9696
amtStr = args[0]
97-
args = args.Tail()
9897
default:
9998
// Show command help if no arguments and flags were provided.
10099
return cli.ShowCommandHelp(ctx, "in")

executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type executorConfig struct {
3838

3939
// executor is responsible for executing swaps.
4040
//
41-
// TODO(roasbeef): rename to SubSwapper
41+
// TODO(roasbeef): rename to SubSwapper.
4242
type executor struct {
4343
wg sync.WaitGroup
4444
newSwaps chan genericSwap
@@ -134,9 +134,9 @@ func (s *executor) run(mainCtx context.Context,
134134

135135
swapDoneChan := make(chan int)
136136
nextSwapID := 0
137+
137138
for {
138139
select {
139-
140140
case newSwap := <-s.newSwaps:
141141
queue := queue.NewConcurrentQueue(10)
142142
queue.Start()

interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ type SwapInfo struct {
363363
OutgoingChanSet loopdb.ChannelSet
364364
}
365365

366-
// LastUpdate returns the last update time of the swap
366+
// LastUpdate returns the last update time of the swap.
367367
func (s *In) LastUpdate() time.Time {
368368
return s.LastUpdateTime
369369
}

loopdb/loop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type SwapContract struct {
5858
ProtocolVersion ProtocolVersion
5959
}
6060

61-
// Loop contains fields shared between LoopIn and LoopOut
61+
// Loop contains fields shared between LoopIn and LoopOut.
6262
type Loop struct {
6363
Hash lntypes.Hash
6464
Events []*LoopEvent

loopdb/meta.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func syncVersions(db *bbolt.DB, chainParams *chaincfg.Params) error {
9292
"db_version=%v", latestDBVersion, currentVersion)
9393

9494
switch {
95-
9695
// If the database reports a higher version that we are aware of, the
9796
// user is probably trying to revert to a prior version of lnd. We fail
9897
// here to prevent reversions and unintended corruption.

loopin.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
221221

222222
// Validate the response parameters the prevent us continuing with a
223223
// swap that is based on parameters outside our allowed range.
224-
err = validateLoopInContract(cfg.lnd, currentHeight, request, swapResp)
224+
err = validateLoopInContract(currentHeight, swapResp)
225225
if err != nil {
226226
return nil, err
227227
}
@@ -387,11 +387,7 @@ func resumeLoopInSwap(_ context.Context, cfg *swapConfig,
387387

388388
// validateLoopInContract validates the contract parameters against our
389389
// request.
390-
func validateLoopInContract(lnd *lndclient.LndServices,
391-
height int32,
392-
request *LoopInRequest,
393-
response *newLoopInResponse) error {
394-
390+
func validateLoopInContract(height int32, response *newLoopInResponse) error {
395391
// Verify that we are not forced to publish an htlc that locks up our
396392
// funds for too long in case the server doesn't follow through.
397393
if response.expiry-height > MaxLoopInAcceptDelta {
@@ -640,7 +636,6 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) (
640636
var conf *chainntnfs.TxConfirmation
641637
for conf == nil {
642638
select {
643-
644639
// P2WSH htlc confirmed.
645640
case conf = <-confChanP2WSH:
646641
s.htlc = s.htlcP2WSH
@@ -756,7 +751,6 @@ func (s *loopInSwap) publishOnChainHtlc(ctx context.Context) (bool, error) {
756751
}
757752

758753
return true, nil
759-
760754
}
761755

762756
// getTxFee calculates our fee for a transaction that we have broadcast. We use
@@ -875,7 +869,6 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
875869
update.State)
876870

877871
switch update.State {
878-
879872
// Swap invoice was paid, so update server cost balance.
880873
case channeldb.ContractSettled:
881874
s.cost.Server -= update.AmtPaid

0 commit comments

Comments
 (0)