Skip to content

Commit

Permalink
workflows: reuse org-wide linter job
Browse files Browse the repository at this point in the history
Adjust Makefile as well to fetch appropriate config.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Sep 23, 2024
1 parent 0eb69b0 commit c1ae557
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 84 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,7 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: 'go.mod'

- name: Get tree-service client
run: make sync-tree

- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
uses: nspcc-dev/.github/.github/workflows/go-linter.yml@master

cover:
name: Coverage
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ coverage.html

# debhelpers
**/.debhelper

.golangci.yml
54 changes: 0 additions & 54 deletions .golangci.yml

This file was deleted.

19 changes: 7 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
REPO ?= $(shell go list -m)
VERSION ?= $(shell git describe --tags --dirty --match "v*" --always --abbrev=8 | sed 's/^v//' 2>/dev/null || cat VERSION 2>/dev/null || echo "develop")
GO_VERSION ?= 1.22
LINT_VERSION ?= 1.49.0
BINDIR = bin

# Binaries to build
Expand All @@ -15,7 +14,7 @@ BINS = $(addprefix $(BINDIR)/, $(CMDS))
REPO_BASENAME = $(shell basename `go list -m`)
HUB_IMAGE ?= "nspccdev/$(REPO_BASENAME)"

.PHONY: all $(BINS) $(BINDIR) dep docker/ test cover format image image-push dirty-image lint docker/lint version clean protoc
.PHONY: all $(BINS) $(BINDIR) dep docker/ test cover format image image-push dirty-image version clean protoc

# .deb package versioning
OS_RELEASE = $(shell lsb_release -cs)
Expand Down Expand Up @@ -61,7 +60,7 @@ docker/%:
-u `stat -c "%u:%g" .` \
--env HOME=/src \
golang:$(GO_VERSION) make $*,\
@echo "supported docker targets: all $(BINS) lint")
@echo "supported docker targets: all $(BINS)")

# Run tests
test:
Expand Down Expand Up @@ -102,18 +101,14 @@ dirty-image:
-f .docker/Dockerfile.dirty \
-t $(HUB_IMAGE)-dirty:$(VERSION) .

# Fetch linter configuration.
.golangci.yml:
wget -O $@ https://github.com/nspcc-dev/.github/raw/master/.golangci.yml

# Run linters
lint:
lint: .golangci.yml
@golangci-lint --timeout=5m run

# Run linters in Docker
docker/lint:
docker run --rm -it \
-v `pwd`:/src \
-u `stat -c "%u:%g" .` \
--env HOME=/src \
golangci/golangci-lint:v$(LINT_VERSION) bash -c 'cd /src/ && make lint'

# Show current version
version:
@echo $(VERSION)
Expand Down

0 comments on commit c1ae557

Please sign in to comment.