Skip to content

Commit a71eaa9

Browse files
authored
Merge pull request #73 from maratori/bump
Update linter and makefile
2 parents a761179 + c3720cf commit a71eaa9

File tree

7 files changed

+226
-135
lines changed

7 files changed

+226
-135
lines changed

.github/dependabot.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
version: 2
22
updates:
3-
- package-ecosystem: gomod
4-
directory: "/"
5-
schedule:
6-
interval: daily
7-
- package-ecosystem: github-actions
8-
directory: "/"
9-
schedule:
10-
interval: daily
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "docker"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"
11+
- package-ecosystem: "github-actions"
12+
directory: "/"
13+
schedule:
14+
interval: "daily"

.github/workflows/ci.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v3
2626
- uses: actions/setup-go@v3
2727
with:
28-
go-version: "1.x"
28+
go-version: "1.20.1" # update together with Dockerfile.dev
2929
- name: Debug with tmate SSH if enabled
3030
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_ssh }}
3131
uses: mxschmitt/action-tmate@v3
@@ -38,10 +38,10 @@ jobs:
3838
- uses: actions/checkout@v3
3939
- uses: actions/setup-go@v3
4040
with:
41-
go-version: "1.x"
41+
go-version: "1.20.1" # update together with Dockerfile.dev
4242
- uses: golangci/golangci-lint-action@v3
4343
with:
44-
version: "v1.48.0"
44+
version: "v1.51.1" # update together with Dockerfile.dev
4545

4646
check-tidy:
4747
name: go mod tidy
@@ -50,7 +50,7 @@ jobs:
5050
- uses: actions/checkout@v3
5151
- uses: actions/setup-go@v3
5252
with:
53-
go-version: "1.x"
53+
go-version: "1.20.1" # update together with Dockerfile.dev
5454
- run: make check-tidy
5555

5656
typos:

.golangci.yml

+150-103
Large diffs are not rendered by default.

Dockerfile.dev

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# update together with .github/workflows/ci.yml
2+
FROM golang:1.20.1 AS go
3+
4+
# update together with .github/workflows/ci.yml
5+
FROM golangci/golangci-lint:v1.51.2 AS linter
6+
7+
FROM go AS dev
8+
ENV INSIDE_DEV_CONTAINER 1
9+
WORKDIR /app
10+
COPY --from=linter /usr/bin/golangci-lint /usr/bin/

Makefile

+40-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
ci: test lint check-tidy
2-
.PHONY: ci
1+
help: ## show this message
2+
@echo "All commands can be run on local machine as well as inside dev container."
3+
@echo ""
4+
@sed -nE 's/^ *([^[:blank:]]+)[[:blank:]]*:[^#]*##[[:blank:]]*(.+)/\1\n\2/p' $(MAKEFILE_LIST) | tr '\n' '\0' | xargs -0 -n 2 printf '%-25s%s\n'
5+
.PHONY: help
36

4-
test:
5-
go test -race ./...
7+
.DEFAULT_GOAL := help
8+
9+
test: ## run all tests
10+
@echo "+ $@"
11+
go test -race -count 1 -p 8 -parallel 8 -timeout 1m ./...
612
.PHONY: test
713

8-
lint:
9-
docker run --rm --name lint -v `pwd`:/app -w /app golangci/golangci-lint:v1.48.0 golangci-lint run
10-
.PHONY: lint
14+
test-cover: ## run all tests with code coverage
15+
@echo "+ $@"
16+
go test -race -count 1 -p 8 -parallel 8 -timeout 1m -coverpkg ./... -coverprofile coverage.out ./...
17+
.PHONY: test-cover
1118

12-
tidy:
13-
go mod tidy
14-
.PHONY: tidy
19+
lint: build-docker-dev ## run linter
20+
@echo "+ $@"
21+
$(RUN_IN_DOCKER) golangci-lint run
22+
.PHONY: lint
1523

16-
update-deps:
17-
go get -u -t ./...
18-
go mod tidy
19-
.PHONY: update-deps
24+
bash: build-docker-dev ## run bash inside container for development
25+
ifndef INSIDE_DEV_CONTAINER
26+
@echo "+ $@"
27+
$(RUN_IN_DOCKER) bash
28+
endif
29+
.PHONY: bash
2030

21-
check-tidy:
31+
check-tidy: ## ensure go.mod is tidy
32+
@echo "+ $@"
2233
cp go.mod go.check.mod
2334
cp go.sum go.check.sum
2435
go mod tidy -modfile=go.check.mod
@@ -27,6 +38,17 @@ check-tidy:
2738
rm go.check.mod go.check.sum
2839
.PHONY: check-tidy
2940

30-
test-cover:
31-
go test -race -coverpkg ./... -coverprofile=coverage.out ./...
32-
.PHONY: test-cover
41+
build-docker-dev: ## build development image from Dockerfile.dev
42+
ifndef INSIDE_DEV_CONTAINER
43+
@echo "+ $@"
44+
DOCKER_BUILDKIT=1 docker build --tag pairedbrackets:dev - < Dockerfile.dev
45+
endif
46+
.PHONY: build-docker-dev
47+
48+
ifndef INSIDE_DEV_CONTAINER
49+
RUN_IN_DOCKER = docker run --rm \
50+
-it \
51+
-w /app \
52+
--mount type=bind,consistency=delegated,source="`pwd`",target=/app \
53+
pairedbrackets:dev
54+
endif

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ Flags:
111111

112112
## Changelog
113113

114+
### [v1.1.1] - 2023-03-07
115+
116+
#### Changed
117+
* Update golang to 1.20
118+
* Update dependencies
119+
* Update golangci-lint to v1.51.2
120+
* Update Makefile
121+
114122
### [v1.1.0] - 2022-06-22
115123

116124
#### Changed
@@ -150,4 +158,4 @@ Flags:
150158
[license-img]: https://img.shields.io/github/license/maratori/testpackage.svg
151159
[license-url]: /LICENSE
152160
[godoc-img]: https://pkg.go.dev/badge/github.com/maratori/testpackage.svg
153-
[godoc-url]: https://pkg.go.dev/github.com/maratori/testpackage
161+
[godoc-url]: https://pkg.go.dev/github.com/maratori/testpackage

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/maratori/testpackage
22

3-
go 1.19
3+
go 1.20
44

55
require golang.org/x/tools v0.6.0
66

0 commit comments

Comments
 (0)