Skip to content

Commit 569b7be

Browse files
Merge pull request #400 from YusukeShimizu/feat/harness-setup-refactor
2 parents 6986d6f + e2def71 commit 569b7be

35 files changed

+4925
-11245
lines changed

.github/workflows/ci.yml

Lines changed: 147 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,147 @@
1-
name: CI
2-
3-
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
types: [opened, synchronize, reopened]
9-
10-
env:
11-
SLOW_MACHINE: 1
12-
13-
jobs:
14-
unit-tests:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v3
20-
21-
- name: Set up Go
22-
uses: actions/setup-go@v4
23-
id: setup-go
24-
with:
25-
go-version-file: "go.mod"
26-
27-
- name: Download Go modules
28-
shell: bash
29-
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
30-
run: go mod download
31-
32-
- name: Build
33-
run: make bins
34-
35-
- name: Test
36-
run: make test
37-
38-
integration-tests:
39-
runs-on: ubuntu-latest
40-
strategy:
41-
matrix:
42-
test-vector: [bitcoin-cln, bitcoin-lnd, liquid-cln, liquid-lnd, misc-integration, lwk-cln, lwk-lnd]
43-
steps:
44-
- name: Checkout code
45-
uses: actions/checkout@v4
46-
with:
47-
fetch-depth: 0
48-
49-
- uses: cachix/install-nix-action@v31
50-
- uses: cachix/cachix-action@v16
51-
with:
52-
name: peerswap
53-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
54-
useDaemon: true
55-
# Switch to nix-shell for integration tests instead of nix develop.
56-
# The 'nix develop' command can be unstable in some CI environments,
57-
# causing issues like "clightning-1: Lost connection to the RPC socket."
58-
# While the root cause is unclear, switching to nix-shell provides a more stable alternative for CI.
59-
# For more context, see the issue in this failed job: https://github.com/ElementsProject/peerswap/actions/runs/16064376179/job/45336040866?pr=385
60-
- name: Run integration tests
61-
run: |
62-
nix-shell --run "make test-${{matrix.test-vector}}"
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
workflow_dispatch:
10+
11+
env:
12+
SLOW_MACHINE: 1
13+
14+
jobs:
15+
unit-tests:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v4
24+
id: setup-go
25+
with:
26+
go-version-file: "go.mod"
27+
28+
- name: Download Go modules
29+
shell: bash
30+
if: ${{ steps.setup-go.outputs.cache-hit != 'true' }}
31+
run: go mod download
32+
33+
- name: Build
34+
run: make bins
35+
36+
- name: Test
37+
run: make test
38+
39+
integration-tests:
40+
runs-on: ubuntu-latest
41+
concurrency:
42+
group: integration-${{ github.ref }}-${{ matrix.vector }}
43+
cancel-in-progress: true
44+
needs: [build-test-bins]
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
vector:
49+
[
50+
bitcoin_clncln,
51+
bitcoin_mixed,
52+
bitcoin_lndlnd,
53+
liquid_clncln,
54+
liquid_mixed,
55+
liquid_lndlnd,
56+
misc_1,
57+
misc_2,
58+
misc_3,
59+
lnd,
60+
]
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 1
66+
67+
- name: Set up Go
68+
uses: actions/setup-go@v4
69+
with:
70+
go-version-file: "go.mod"
71+
72+
- name: Cache Go modules
73+
id: go-cache
74+
uses: actions/cache@v3
75+
with:
76+
path: |
77+
~/.cache/go-build
78+
~/go/pkg/mod
79+
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
80+
restore-keys: |
81+
${{ runner.os }}-go-
82+
83+
- name: Download Go modules
84+
if: ${{ steps.go-cache.outputs.cache-hit != 'true' }}
85+
run: go mod download
86+
87+
# Test binaries are prebuilt and downloaded as artifact
88+
- name: Download test binaries
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: test-bins
92+
path: out/test-builds
93+
94+
- uses: cachix/install-nix-action@v31
95+
- uses: cachix/cachix-action@v16
96+
with:
97+
name: peerswap
98+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
99+
useDaemon: true
100+
# Switch to nix-shell for integration tests instead of nix develop.
101+
# The 'nix develop' command can be unstable in some CI environments,
102+
# causing issues like "clightning-1: Lost connection to the RPC socket."
103+
# While the root cause is unclear, switching to nix-shell provides a more stable alternative for CI.
104+
# For more context, see the issue in this failed job: https://github.com/ElementsProject/peerswap/actions/runs/16064376179/job/45336040866?pr=385
105+
- name: Run integration tests
106+
env:
107+
INTEGRATION_TEST_PARALLEL: "6"
108+
SKIP_BUILD_TEST_BINS: "1"
109+
run: |
110+
nix-shell --run "RUN_INTEGRATION_TESTS=1 PAYMENT_RETRY_TIME=10 PEERSWAP_TEST_FILTER=$PEERSWAP_TEST_FILTER INTEGRATION_TEST_PARALLEL=$INTEGRATION_TEST_PARALLEL make test-matrix-${{ matrix.vector }}"
111+
112+
build-test-bins:
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v4
117+
with:
118+
fetch-depth: 1
119+
120+
- name: Set up Go
121+
uses: actions/setup-go@v4
122+
with:
123+
go-version-file: "go.mod"
124+
125+
- name: Cache Go modules
126+
id: go-cache
127+
uses: actions/cache@v3
128+
with:
129+
path: |
130+
~/.cache/go-build
131+
~/go/pkg/mod
132+
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
133+
restore-keys: |
134+
${{ runner.os }}-go-
135+
136+
- name: Download Go modules
137+
if: ${{ steps.go-cache.outputs.cache-hit != 'true' }}
138+
run: go mod download
139+
140+
- name: Build test binaries
141+
run: make test-bins
142+
143+
- name: Upload test binaries
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: test-bins
147+
path: out/test-builds

.golangci.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
version: "2"
2+
3+
run:
4+
tests: true
5+
timeout: 5m
6+
7+
linters:
8+
# Default v2 linter set options (standard/all/none/fast)
9+
default: standard
10+
enable:
11+
# Critical / foundational
12+
- staticcheck
13+
- govet
14+
- errcheck
15+
- ineffassign
16+
- unused
17+
- errorlint
18+
- revive
19+
- gocritic
20+
- makezero
21+
- durationcheck
22+
- nilerr
23+
- bodyclose
24+
- rowserrcheck
25+
- sqlclosecheck
26+
- noctx
27+
- perfsprint
28+
- sloglint
29+
- nolintlint
30+
- tparallel
31+
- gosec
32+
# Policy / helper
33+
- depguard
34+
- forbidigo
35+
- copyloopvar
36+
# Complexity / duplication (enabled for main code)
37+
- goconst
38+
- cyclop
39+
- gocognit
40+
- dupl
41+
- unparam
42+
- unconvert
43+
disable:
44+
# Linters with preference-dependent behavior; keep disabled for now
45+
- exhaustruct
46+
- varnamelen
47+
- wsl
48+
- nlreturn
49+
- nonamedreturns
50+
- funlen
51+
- nakedret
52+
- err113
53+
- gochecknoglobals
54+
55+
# Test-only relaxations (disable specific linters for _test.go files)
56+
exclusions:
57+
rules:
58+
- path: '(^|.*/)test/.*\.go'
59+
linters:
60+
- forbidigo # Allow fmt.Print / time.Sleep in tests
61+
- revive # Ignore minor style issues inside tests
62+
- gosec # Reduce false positives for simple test I/O
63+
- dupl # Accept similar duplicated test cases
64+
- gocognit # Relax complexity requirements for readability
65+
- cyclop
66+
- goconst # Loosen constant enforcement within tests
67+
- funlen # Allow longer test functions
68+
- nlreturn
69+
- varnamelen
70+
- wsl
71+
- nolintlint # Allow simpler usage of //nolint in tests
72+
- perfsprint # Relax performance-focused checks for tests
73+
- unparam # Avoid false positives for unused parameters
74+
- unconvert
75+
76+
settings:
77+
# Detect loop variable capture issues
78+
govet:
79+
enable:
80+
- loopclosure
81+
# Block testify usage in tests (applies only to $test)
82+
depguard:
83+
rules:
84+
main:
85+
files:
86+
- $all
87+
- "!$test"
88+
deny:
89+
- pkg: syscall
90+
desc: |
91+
Deprecated: This package is locked down.
92+
Callers should use the corresponding package in the golang.org/x/sys repository instead.
93+
That is also where updates required by new systems or versions should be applied.
94+
See https://golang.org/s/go1.4-syscall for more information.
95+
- pkg: github.com/satori/go.uuid
96+
desc: |
97+
This package have vulnerability. Please use alternative uuid package such as "github.com/google/uuid".
98+
- pkg: github.com/golang/protobuf/proto
99+
desc: |
100+
Deprecated: Use the "google.golang.org/protobuf/proto" package instead.
101+
- pkg: github.com/golang/protobuf/ptypes
102+
desc: |
103+
Deprecated: Use the "google.golang.org/protobuf/types/known/anypb" package instead.
104+
- pkg: github.com/golang/protobuf/ptypes/any
105+
desc: |
106+
Deprecated: Use the "google.golang.org/protobuf/types/known/anypb" package instead.
107+
- pkg: github.com/golang/protobuf/ptypes/duration
108+
desc: |
109+
Deprecated: Use the "google.golang.org/protobuf/types/known/durationpb" package instead.
110+
- pkg: github.com/golang/protobuf/ptypes/empty
111+
desc: |
112+
Deprecated: Use the "google.golang.org/protobuf/types/known/emptypb" package instead.
113+
- pkg: github.com/golang/protobuf/ptypes/struct
114+
desc: |
115+
Deprecated: Use the "google.golang.org/protobuf/types/known/structpb" package instead.
116+
- pkg: github.com/golang/protobuf/ptypes/timestamp
117+
desc: |
118+
Deprecated: Use the "google.golang.org/protobuf/types/known/timestamppb" package instead.
119+
- pkg: github.com/golang/protobuf/ptypes/wrappers
120+
desc: |
121+
Deprecated: Use the "google.golang.org/protobuf/types/known/wrapperspb" package instead.
122+
- pkg: github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap
123+
desc: |
124+
DO NOT USE ctxzap. Please check grpcserver/internal#LogWithFields.
125+
- pkg: github.com/pkg/errors
126+
desc: Should be replaced by standard lib errors package
127+
- pkg: golang.org/x/sync/errgroup
128+
desc: |
129+
Use panic recoverable version github.com/kouzoh-mercoin/mercoin-core-kit/sync/recoverable or github.com/sourcegraph/conc instead.
130+
test:
131+
files:
132+
- $test
133+
deny:
134+
- pkg: github.com/stretchr/testify
135+
desc: |
136+
DO NOT USE testing framework.
137+
138+
gocognit:
139+
min-complexity: 20
140+
goconst:
141+
min-len: 3
142+
min-occurrences: 3
143+
dupl:
144+
threshold: 200
145+
146+
revive:
147+
rules:
148+
- name: error-strings
149+
- name: indent-error-flow
150+
- name: exported
151+
- name: package-comments
152+
- name: redefines-builtin-id
153+
- name: if-return
154+
- name: superfluous-else
155+
- name: var-naming
156+
157+
nolintlint:
158+
require-explanation: true
159+
require-specific: true
160+
161+
# v2 formatters (used by `golangci-lint fmt`)
162+
formatters:
163+
enable:
164+
- gofmt
165+
- goimports
166+
- gofumpt
167+
- gci
168+
- golines
169+
settings:
170+
golines:
171+
max-len: 120
172+
gci:
173+
sections:
174+
- standard
175+
- default
176+
- prefix(github.com/your/module) # Replace with your module path

0 commit comments

Comments
 (0)