Skip to content

Commit 59ea5e9

Browse files
committed
fixup! lint in a container for consistency
1 parent 04deeee commit 59ea5e9

4 files changed

Lines changed: 40 additions & 13 deletions

File tree

.github/workflows/lint.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,41 @@ permissions:
1313
# Optional: allow read access to pull request. Use with `only-new-issues` option.
1414
# pull-requests: read
1515
jobs:
16-
golangci:
16+
detect-modules:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
modules: ${{ steps.set-modules.outputs.modules }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: 1.21.8
25+
- id: set-modules
26+
run: "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT
27+
golangci-lint:
28+
needs: detect-modules
1729
name: lint
1830
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}}
1934
steps:
20-
- uses: actions/setup-go@v4
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-go@v5
2137
with:
2238
go-version: 1.21.8
23-
- uses: actions/checkout@v3
24-
- name: golangci-lint
39+
- name: golangci-lint ${{ matrix.modules }}
2540
uses: golangci/golangci-lint-action@v8
2641
with:
2742
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
2843
version: v2.1
2944

3045
# Optional: working directory, useful for monorepos
31-
# working-directory: somedir
46+
working-directory: ${{ matrix.modules }}
3247

3348
# Optional: golangci-lint command line arguments.
3449
# args: --issues-exit-code=0
3550

36-
# For now, Smart Node will only enforce goimports linting
37-
args: --disable-all --enable goimports addons/... shared/... rocketpool/... rocketpool-cli/...
38-
3951
# Optional: show only new issues if it's a pull request. The default value is `false`.
4052
# only-new-issues: true
4153

.golangci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
formatters:
5+
default: none
6+
enable:
7+
- goimports
8+
run:
9+
relative-path-mode: cfg
10+
go: '1.21.8'
11+
output:
12+
path: stderr

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ CLI_TARGET_STRINGS:=$(foreach oos,$(CLI_TARGET_OOS), $(foreach arch,$(ARCHS),${C
1212
DAEMON_TARGET_STRINGS:=$(foreach arch,$(ARCHS),${DAEMON_DIR}/rocketpool-daemon-linux-$(arch))
1313

1414
MODULES:=$(foreach path,$(shell find . -name go.mod),$(dir $(path)))
15-
MODULE_GLOBS:=$(foreach module,$(MODULES),$(module)...)
1615

1716
define rocketpool-cli-template
1817
.PHONY: ${CLI_DIR}/rocketpool-cli-$1-$2
@@ -63,10 +62,14 @@ docker:
6362
docker manifest create rocketpool/smartnode:${VERSION} --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
6463
docker manifest create rocketpool/smartnode:latest --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
6564

65+
define lint-template
66+
.PHONY: lint-$1
67+
lint-$1:
68+
docker run --rm -v .:/go/smartnode --workdir /go/smartnode/$1 golangci/golangci-lint:v2.1-alpine golangci-lint fmt --diff
69+
endef
70+
$(foreach module,$(MODULES),$(eval $(call lint-template,$(module))))
6671
.PHONY: lint
67-
lint:
68-
@echo $(MODULE_GLOBS)
69-
docker run --rm -v .:/go/smartnode --workdir /go/smartnode golangci/golangci-lint:v2.1-alpine golangci-lint fmt --enable goimports $(MODULE_GLOBS)
72+
lint: $(foreach module,$(MODULES),lint-$(module))
7073

7174
.PHONY: test
7275
test:

addons/rescue_node/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
type RescueNodeConfig struct {
88
Title string `yaml:"-"`
99

10-
Enabled config.Parameter `yaml:"enabled,omitempty"`
10+
Enabled config.Parameter `yaml:"enabled,omitempty"`
1111

1212
Username config.Parameter `yaml:"username,omitempty"`
1313
Password config.Parameter `yaml:"username,omitempty"`

0 commit comments

Comments
 (0)