Skip to content

Commit e4f64ec

Browse files
committed
Revert "Merge pull request lightninglabs#1028 from starius/downgrade-deps"
This reverts commit b11c959, reversing changes made to 0a182ee.
1 parent 2b41fe2 commit e4f64ec

File tree

15 files changed

+318
-37
lines changed

15 files changed

+318
-37
lines changed

.github/workflows/main.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020

2121
# If you change this value, please change it in the following files as well:
2222
# /Dockerfile
23-
GO_VERSION: 1.23.12
23+
GO_VERSION: 1.24.6
2424

2525
jobs:
2626
########################
@@ -103,6 +103,26 @@ jobs:
103103
- name: lint
104104
run: make lint
105105

106+
########################
107+
# Verify documentation
108+
########################
109+
docs-check:
110+
name: verify that auto-generated documentation is up-to-date
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: git checkout
114+
uses: actions/checkout@v2
115+
with:
116+
fetch-depth: 0
117+
118+
- name: setup go ${{ env.GO_VERSION }}
119+
uses: actions/setup-go@v5
120+
with:
121+
go-version: '~${{ env.GO_VERSION }}'
122+
123+
- name: check
124+
run: make docs-check
125+
106126
########################
107127
# run unit tests
108128
########################

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "2"
22
run:
3-
go: "1.23"
3+
go: "1.24"
44

55
# timeout for analysis
66
timeout: 4m

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=${BUILDPLATFORM} golang:1.23.12-alpine as builder
1+
FROM --platform=${BUILDPLATFORM} golang:1.24.6-alpine as builder
22

33
# Copy in the local repository to build from.
44
COPY . /go/src/github.com/lightningnetwork/loop

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ sqlc-check: sqlc
170170
@$(call print, "Verifying sql code generation.")
171171
if test -n "$$(git status --porcelain '*.go')"; then echo "SQL models not properly generated!"; git status --porcelain '*.go'; exit 1; fi
172172

173+
docs: build
174+
@$(call print, "Building man and markdown files in docs/")
175+
./loop-debug man > docs/loop.1
176+
./loop-debug markdown > docs/loop.md
177+
178+
docs-check: docs
179+
@$(call print, "Verifying man and markdown files in docs/")
180+
if test -n "$$(git status --porcelain 'docs/loop.*')"; then echo "Man and markdown files not properly generated!"; git diff; exit 1; fi
181+
173182
fsm:
174183
@$(call print, "Generating state machine docs")
175184
./scripts/fsm-generate.sh;

cmd/loop/docs.go

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package main
2+
3+
import (
4+
"context"
5+
_ "embed"
6+
"fmt"
7+
8+
docs "github.com/urfave/cli-docs/v3"
9+
"github.com/urfave/cli/v3"
10+
)
11+
12+
//go:embed markdown_tabular.md.gotmpl
13+
var markdownTabularDocTemplate string
14+
15+
// We have a copy of this template taken from
16+
// https://github.com/urfave/cli-docs where we remove column
17+
// "Environment variables" if it has no values.
18+
// TODO: remove this when https://github.com/urfave/cli-docs/pull/15
19+
// is merged.
20+
func init() {
21+
docs.MarkdownTabularDocTemplate = markdownTabularDocTemplate
22+
}
23+
24+
var printManCommand = &cli.Command{
25+
Name: "man",
26+
Usage: "prints man file",
27+
Description: "Prints documentation of loop CLI in man format",
28+
Action: printMan,
29+
Hidden: true,
30+
}
31+
32+
func printMan(_ context.Context, cmd *cli.Command) error {
33+
root := filterNestedHelpCommands(cmd.Root())
34+
35+
const userCommandsSection = 1
36+
man, err := docs.ToManWithSection(root, userCommandsSection)
37+
if err != nil {
38+
return fmt.Errorf("failed to produce man: %w", err)
39+
}
40+
41+
fmt.Println(man)
42+
43+
return nil
44+
}
45+
46+
var printMarkdownCommand = &cli.Command{
47+
Name: "markdown",
48+
Usage: "prints markdown file",
49+
Description: "Prints documentation of loop CLI in markdown format",
50+
Action: printMarkdown,
51+
Hidden: true,
52+
}
53+
54+
func printMarkdown(_ context.Context, cmd *cli.Command) error {
55+
root := filterNestedHelpCommands(cmd.Root())
56+
57+
md, err := docs.ToTabularMarkdown(root, "loop")
58+
if err != nil {
59+
return fmt.Errorf("failed to produce man: %w", err)
60+
}
61+
62+
fmt.Println(md)
63+
64+
return nil
65+
}
66+
67+
// filterNestedHelpCommands clones cmd, drops nested help commands, and normalises
68+
// flag defaults so generated documentation avoids absolute paths.
69+
func filterNestedHelpCommands(cmd *cli.Command) *cli.Command {
70+
cloned := cloneCommand(cmd, 0)
71+
overrideDocFlags(cloned)
72+
return cloned
73+
}
74+
75+
// cloneCommand clones the command, filtering out nested "help" subcommands.
76+
func cloneCommand(cmd *cli.Command, depth int) *cli.Command {
77+
if cmd == nil {
78+
return nil
79+
}
80+
81+
cloned := *cmd
82+
if len(cmd.Commands) == 0 {
83+
return &cloned
84+
}
85+
86+
filtered := make([]*cli.Command, 0, len(cmd.Commands))
87+
for _, sub := range cmd.Commands {
88+
if sub == nil {
89+
continue
90+
}
91+
childDepth := depth + 1
92+
93+
// TODO: remove when https://github.com/urfave/cli-docs/pull/16
94+
if childDepth > 0 && sub.Name == "help" {
95+
continue
96+
}
97+
98+
filtered = append(filtered, cloneCommand(sub, childDepth))
99+
}
100+
101+
cloned.Commands = filtered
102+
return &cloned
103+
}
104+
105+
// overrideDocFlags walks the command tree and replaces string flag defaults
106+
// that leak user-specific filesystem paths, keeping generated docs stable.
107+
func overrideDocFlags(cmd *cli.Command) {
108+
if cmd == nil {
109+
return
110+
}
111+
112+
if len(cmd.Flags) > 0 {
113+
clonedFlags := make([]cli.Flag, len(cmd.Flags))
114+
for i, fl := range cmd.Flags {
115+
clonedFlags[i] = cloneFlagWithOverrides(fl)
116+
}
117+
cmd.Flags = clonedFlags
118+
}
119+
120+
for _, sub := range cmd.Commands {
121+
overrideDocFlags(sub)
122+
}
123+
}
124+
125+
// docFlagOverrides maps global flag names to the canonical values we want to
126+
// show in documentation instead of user-specific absolute paths.
127+
var docFlagOverrides = map[string]string{
128+
loopDirFlag.Name: "~/.loop",
129+
tlsCertFlag.Name: "~/.loop/mainnet/tls.cert",
130+
macaroonPathFlag.Name: "~/.loop/mainnet/loop.macaroon",
131+
}
132+
133+
// cloneFlagWithOverrides returns a copy of flag with overridden default values
134+
// when the flag participates in docFlagOverrides. Non-string flags are reused
135+
// unchanged to minimise allocations.
136+
func cloneFlagWithOverrides(flag cli.Flag) cli.Flag {
137+
sf, ok := flag.(*cli.StringFlag)
138+
if !ok {
139+
return flag
140+
}
141+
142+
value, ok := docFlagOverrides[sf.Name]
143+
if !ok {
144+
return flag
145+
}
146+
147+
cloned := *sf
148+
cloned.Value = value
149+
cloned.DefaultText = value
150+
151+
return &cloned
152+
}

cmd/loop/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ var (
9090
setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand,
9191
getInfoCommand, abandonSwapCommand, reservationsCommands,
9292
instantOutCommand, listInstantOutsCommand,
93+
printManCommand, printMarkdownCommand,
9394
}
9495
)
9596

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{ define "flags" }}
2+
{{- $hasEnvVars := false -}}
3+
{{- range . -}}
4+
{{- if and (not $hasEnvVars) .EnvVars -}}
5+
{{- $hasEnvVars = true -}}
6+
{{- end -}}
7+
{{- end }}
8+
| Name | Description | Type | Default value {{ if $hasEnvVars }}| Environment variables {{ end }}|
9+
|------|-------------|------|:-------------:{{ if $hasEnvVars }}|:---------------------:{{ end }}|
10+
{{ range $flag := . -}}
11+
{{- /**/ -}} | `{{ $flag.Name }}{{ if $flag.TakesValue }}="…"{{ end }}` {{ if $flag.Aliases }}(`{{ join $flag.Aliases "`, `" }}`) {{ end }}
12+
{{- /**/ -}} | {{ $flag.Usage }}
13+
{{- /**/ -}} | {{ $flag.Type }}
14+
{{- /**/ -}} | {{ if $flag.Default }}`{{ $flag.Default }}`{{ end }}
15+
{{- if $hasEnvVars -}}
16+
{{- /**/ -}} | {{ if $flag.EnvVars }}`{{ join $flag.EnvVars "`, `" }}`{{ else }}*none*{{ end }}
17+
{{- end -}}
18+
{{- /**/ -}} |
19+
{{ end }}
20+
{{ end }}
21+
22+
{{ define "command" }}
23+
### `{{ .Name }}` {{ if gt .Level 0 }}sub{{ end }}command{{ if .Aliases }} (aliases: `{{ join .Aliases "`, `" }}`){{ end }}
24+
{{ if .Usage }}
25+
{{ .Usage }}.
26+
{{ end }}
27+
{{ if .UsageText }}
28+
{{ range $line := .UsageText -}}
29+
> {{ $line }}
30+
{{ end -}}
31+
{{ end }}
32+
{{ if .Description }}
33+
{{ .Description }}.
34+
{{ end }}
35+
Usage:
36+
37+
```bash
38+
$ {{ .AppPath }} [GLOBAL FLAGS] {{ .Name }}{{ if .Flags }} [COMMAND FLAGS]{{ end }} {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }}
39+
```
40+
41+
{{ if .Flags -}}
42+
The following flags are supported:
43+
{{ template "flags" .Flags }}
44+
{{ end -}}
45+
46+
{{ if .SubCommands -}}
47+
{{ range $subCmd := .SubCommands -}}
48+
{{ template "command" $subCmd }}
49+
{{ end -}}
50+
{{ end -}}
51+
{{ end }}
52+
53+
## CLI interface{{ if .Name }} - {{ .Name }}{{ end }}
54+
55+
{{ if .Description }}{{ .Description }}.
56+
{{ end }}
57+
{{ if .Usage }}{{ .Usage }}.
58+
{{ end }}
59+
{{ if .UsageText }}
60+
{{ range $line := .UsageText -}}
61+
> {{ $line }}
62+
{{ end -}}
63+
{{ end }}
64+
Usage:
65+
66+
```bash
67+
$ {{ .AppPath }}{{ if .GlobalFlags }} [GLOBAL FLAGS]{{ end }} [COMMAND] [COMMAND FLAGS] {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[ARGUMENTS...]{{ end }}
68+
```
69+
70+
{{ if .GlobalFlags }}
71+
Global flags:
72+
73+
{{ template "flags" .GlobalFlags }}
74+
75+
{{ end -}}
76+
{{ if .Commands -}}
77+
{{ range $cmd := .Commands -}}
78+
{{ template "command" $cmd }}
79+
{{ end }}
80+
{{- end }}

docs/release.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ for a release using the following commands:
6767
```bash
6868
$ go version
6969
go version go1.25.0 linux/amd64
70-
$ go install golang.org/dl/go1.23.12@latest
71-
$ go1.23.12 download
72-
Unpacking /home/user/sdk/go1.23.12/go1.23.12.linux-amd64.tar.gz ...
73-
Success. You may now run 'go1.23.12'
74-
$ go1.23.12 version
75-
go version go1.23.12 linux/amd64
76-
77-
$ GO_CMD=/home/user/go/bin/go1.23.12 ./release.sh v0.31.5
70+
$ go install golang.org/dl/go1.24.6@latest
71+
$ go1.24.6 download
72+
Unpacking /home/user/sdk/go1.24.6/go1.24.6.linux-amd64.tar.gz ...
73+
Success. You may now run 'go1.24.6'
74+
$ go1.24.6 version
75+
go version go1.24.6 linux/amd64
76+
77+
$ GO_CMD=/home/user/go/bin/go1.24.6 ./release.sh v0.31.3
7878
```
7979

8080
On MacOS, you will need to install GNU tar and GNU gzip, which can be done with

go.mod

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ require (
2020
github.com/jessevdk/go-flags v1.4.0
2121
github.com/lib/pq v1.10.9
2222
github.com/lightninglabs/aperture v0.3.13-beta
23-
github.com/lightninglabs/lndclient v0.19.0-12
23+
github.com/lightninglabs/lndclient v0.20.0-1
2424
github.com/lightninglabs/loop/looprpc v1.0.7
2525
github.com/lightninglabs/loop/swapserverrpc v1.0.14
26-
github.com/lightninglabs/taproot-assets v0.6.1
27-
github.com/lightninglabs/taproot-assets/taprpc v1.0.8-0.20250716163904-2ef55ba74036
28-
github.com/lightningnetwork/lnd v0.19.3-beta
26+
github.com/lightninglabs/taproot-assets v0.7.0-rc1.0.20251014172227-e6ae082c0b4b
27+
github.com/lightninglabs/taproot-assets/taprpc v1.0.10-0.20251014172227-e6ae082c0b4b
28+
github.com/lightningnetwork/lnd v0.20.0-beta.rc1
2929
github.com/lightningnetwork/lnd/cert v1.2.2
3030
github.com/lightningnetwork/lnd/clock v1.1.1
3131
github.com/lightningnetwork/lnd/queue v1.1.1
@@ -34,6 +34,7 @@ require (
3434
github.com/lightningnetwork/lnd/tor v1.1.6
3535
github.com/ory/dockertest/v3 v3.10.0
3636
github.com/stretchr/testify v1.10.0
37+
github.com/urfave/cli-docs/v3 v3.1.0
3738
github.com/urfave/cli/v3 v3.4.1
3839
go.etcd.io/bbolt v1.4.3
3940
golang.org/x/sync v0.13.0
@@ -72,6 +73,7 @@ require (
7273
github.com/coreos/go-semver v0.3.0 // indirect
7374
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
7475
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
76+
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
7577
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
7678
github.com/decred/dcrd/lru v1.1.2 // indirect
7779
github.com/docker/cli v28.1.1+incompatible // indirect
@@ -121,11 +123,11 @@ require (
121123
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3 // indirect
122124
github.com/lightninglabs/neutrino v0.16.1 // indirect
123125
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
124-
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb // indirect
126+
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 // indirect
125127
github.com/lightningnetwork/lnd/fn/v2 v2.0.8 // indirect
126128
github.com/lightningnetwork/lnd/healthcheck v1.2.6 // indirect
127129
github.com/lightningnetwork/lnd/kvdb v1.4.16 // indirect
128-
github.com/lightningnetwork/lnd/sqldb v1.0.10 // indirect
130+
github.com/lightningnetwork/lnd/sqldb v1.0.11 // indirect
129131
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
130132
github.com/mattn/go-isatty v0.0.20 // indirect
131133
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
@@ -149,6 +151,7 @@ require (
149151
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
150152
github.com/rogpeppe/fastuuid v1.2.0 // indirect
151153
github.com/rogpeppe/go-internal v1.14.1 // indirect
154+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
152155
github.com/sirupsen/logrus v1.9.3 // indirect
153156
github.com/soheilhy/cmux v0.1.5 // indirect
154157
github.com/spf13/pflag v1.0.6 // indirect
@@ -216,4 +219,4 @@ replace github.com/lightninglabs/loop/swapserverrpc => ./swapserverrpc
216219

217220
replace github.com/lightninglabs/loop/looprpc => ./looprpc
218221

219-
go 1.23.12
222+
go 1.24.6

0 commit comments

Comments
 (0)