Skip to content

Commit

Permalink
Merge pull request #204 from maratori/deps
Browse files Browse the repository at this point in the history
Downgrade deps to minimum required versions
  • Loading branch information
maratori committed May 9, 2024
2 parents dba69a1 + c8eb128 commit c975239
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
directory: "/.github/latest-deps"
schedule:
interval: "daily"
- package-ecosystem: "docker"
Expand Down
10 changes: 10 additions & 0 deletions .github/latest-deps/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/maratori/testpackage

go 1.22

require golang.org/x/tools v0.20.0

require (
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
)
6 changes: 6 additions & 0 deletions .github/latest-deps/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
7 changes: 7 additions & 0 deletions .github/latest-deps/imports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package imports

import (
_ "golang.org/x/tools/go/analysis"
_ "golang.org/x/tools/go/analysis/analysistest"
_ "golang.org/x/tools/go/analysis/singlechecker"
)
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

test-latest-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.3" # update together with dev.dockerfile
- run: make test-latest-deps

lint:
runs-on: ubuntu-latest
steps:
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ test-cover: ## run all tests with code coverage
go test -race -count 1 -p 8 -parallel 8 -timeout 1m -coverpkg ./... -coverprofile coverage.out ./...
.PHONY: test-cover

test-latest-deps: ## run all tests with latest dependencies
@echo "+ $@"
go test -modfile .github/latest-deps/go.mod -race -p 8 -parallel 8 -timeout 1m ./...
.PHONY: test

lint: build-docker-dev ## run linter
@echo "+ $@"
$(RUN_IN_DOCKER) golangci-lint run
Expand All @@ -28,6 +33,15 @@ bash: build-docker-dev ## run bash inside container for development
endif
.PHONY: bash

IMPORTS = find . -name '*.go' -not -path './.github/*' -exec sed -e '/^import (/,/^)/!d' {} + | sed -e '/\./!d' | grep -v "`head -n 1 go.mod | sed -e 's/module //'`" | sed -E -e 's/\t(.+ )?"/\t_ "/' | sort | uniq | xargs -0 printf 'package imports\n\nimport (\n%s)\n'

tidy: ## keep go.mod and .github/latest-deps tidy
@echo "+ $@"
go mod tidy
$(IMPORTS) > .github/latest-deps/imports.go
go mod tidy -modfile=.github/latest-deps/go.mod
.PHONY: check

check-tidy: ## ensure go.mod is tidy
@echo "+ $@"
cp go.mod go.check.mod
Expand All @@ -36,6 +50,17 @@ check-tidy: ## ensure go.mod is tidy
diff -u go.mod go.check.mod
diff -u go.sum go.check.sum
rm go.check.mod go.check.sum

$(IMPORTS) > .github/latest-deps/imports.check.go
diff -u .github/latest-deps/imports.go .github/latest-deps/imports.check.go
rm .github/latest-deps/imports.check.go

cp .github/latest-deps/go.mod go.check.mod
cp .github/latest-deps/go.sum go.check.sum
go mod tidy -modfile=go.check.mod
diff -u .github/latest-deps/go.mod go.check.mod
diff -u .github/latest-deps/go.sum go.check.sum
rm go.check.mod go.check.sum
.PHONY: check-tidy

build-docker-dev: ## build development image from Dockerfile.dev
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# testpackage <br> [![go.mod version][go-img]][go-url] [![CI][ci-img]][ci-url] [![Codecov][codecov-img]][codecov-url] [![Codebeat][codebeat-img]][codebeat-url] [![Maintainability][codeclimate-img]][codeclimate-url] [![Go Report Card][goreportcard-img]][goreportcard-url] [![License][license-img]][license-url] [![Go Reference][godoc-img]][godoc-url]
# testpackage <br> [![go minimal version][go-img]][go-url] [![go tested version][go-latest-img]][go-latest-url] [![CI][ci-img]][ci-url] [![Codecov][codecov-img]][codecov-url] [![Codebeat][codebeat-img]][codebeat-url] [![Maintainability][codeclimate-img]][codeclimate-url] [![Go Report Card][goreportcard-img]][goreportcard-url] [![License][license-img]][license-url] [![Go Reference][godoc-img]][godoc-url]

**testpackage** is a golang linter that makes you use a separate `_test` package.

Expand Down Expand Up @@ -145,6 +145,8 @@ Flags:

[go-img]: https://img.shields.io/github/go-mod/go-version/maratori/testpackage
[go-url]: /go.mod
[go-latest-img]: https://img.shields.io/github/go-mod/go-version/maratori/testpackage?filename=.github%2Flatest-deps%2Fgo.mod&label=tested
[go-latest-url]: /.github/latest-deps/go.mod
[ci-img]: https://github.com/maratori/testpackage/actions/workflows/ci.yaml/badge.svg
[ci-url]: https://github.com/maratori/testpackage/actions/workflows/ci.yaml
[codecov-img]: https://codecov.io/gh/maratori/testpackage/branch/main/graph/badge.svg?token=Pa334H8xEh
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/maratori/testpackage

go 1.22
go 1.18 // tested all go versions from 1.18 to 1.22

require golang.org/x/tools v0.20.0
require golang.org/x/tools v0.13.0

require (
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)
13 changes: 7 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=

0 comments on commit c975239

Please sign in to comment.