Skip to content

Commit 919f3f5

Browse files
committed
lint in a container for consistency
1 parent c6954ad commit 919f3f5

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

.github/workflows/lint.yml

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

3044
# Optional: working directory, useful for monorepos
31-
# working-directory: somedir
45+
working-directory: ${{ matrix.modules }}
3246

3347
# Optional: golangci-lint command line arguments.
3448
# args: --issues-exit-code=0
3549

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

.golangci.yml

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

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ docker:
6363
docker manifest create rocketpool/smartnode:${VERSION} --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
6464
docker manifest create rocketpool/smartnode:latest --amend rocketpool/smartnode:${VERSION}-amd64 --amend rocketpool/smartnode:${VERSION}-arm64
6565

66-
.PHONY: clean
67-
clean:
68-
rm -rf ${BUILD_DIR}
69-
66+
define lint-template
67+
.PHONY: lint-$1
68+
lint-$1:
69+
docker run --rm -v .:/go/smartnode --workdir /go/smartnode/$1 golangci/golangci-lint:v2.1-alpine golangci-lint fmt --diff
70+
endef
71+
$(foreach module,$(MODULES),$(eval $(call lint-template,$(module))))
7072
.PHONY: lint
71-
lint:
72-
@echo $(MODULE_GLOBS)
73-
docker run --rm -v .:/go/smartnode --workdir /go/smartnode golangci/golangci-lint:v2.1-alpine golangci-lint fmt --enable goimports $(MODULE_GLOBS)
73+
lint: $(foreach module,$(MODULES),lint-$(module))
7474

7575
.PHONY: test
7676
test:
7777
go test -test.timeout 20m $(MODULE_GLOBS)
78+
79+
.PHONY: clean
80+
clean:
81+
rm -rf ${BUILD_DIR}

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ See the [Smartnode Installer](https://github.com/rocket-pool/smartnode-install)
2828

2929
A [Makefile](./Makefile) is included for building, testing, and linting.
3030

31-
* `make all` will build rocketpool-cli, rocketpool-daemon, and run the linter.
32-
* `make rocketpool-daemon` will build the docker containers required to build the daemon, then build the daemon.
33-
* `make rocketpool-cli` will build the cli for linux and osx.
31+
* `make` or `make all` will build rocketpool-cli, rocketpool-daemon, and run the linter.
32+
* build/rocketpool-cli and build/rocketpool-daemon will be symlinked to the version and architecture specific binaries in build/
33+
* `make release` will build all architecture specific binaries as well as docker images and manifests
34+
* It will tag docker images as latest as well as the version in `shared/version.txt`
35+
* It will put cli and native mode binaries in build/\<version\>
36+
* `make build/rocketpool-cli` builds just the cli
37+
* `make build/rocketpool-daemon` builds just the daemon
38+
* `make docker` builds the rocketpool/smartnode container and tags it with latest as well as the version from `shared/version.txt`
39+
* `make lint` runs the linter.
3440
* `make test` runs all unit tests.
35-
* `make clean` deletes any binaries. It does not clear your go caches.
41+
* `make clean` deletes any binaries. It does not clear your go caches. It does not clean up old docker images.
3642

3743
## CLI Commands
3844

0 commit comments

Comments
 (0)