Added devp linter

This commit is contained in:
a.pivkin 2025-12-23 06:40:56 +03:00
parent ab3a912c5a
commit 20a59dceae
52 changed files with 1341 additions and 30 deletions

View File

@ -0,0 +1,23 @@
# IntelliJ IDEA
.idea
*.iml
*.ipr
*.iws
# macOS
.DS_Store
# Golang
*.prof
*.exe
*.test
*.report
*.out
/bin/
/tmp/
/.build/
/vendor/
# test results
coverage.txt
coverage.xml

44
rbd_exporter/.gitignore vendored Normal file
View File

@ -0,0 +1,44 @@
# IntelliJ IDEA
.idea/
*.iml
*.ipr
*.iws
dist/
# VSCode
.vscode/
# zed
.zed/
# macOS
.DS_Store
# Golang
*.prof
*.exe
*.test
*.report
*.out
/bin/
/tmp/
/.build/
/.devp/
/vendor/
go.work
go.work.sum
# test results
coverage.txt
coverage.xml
# Platform
scripts/golangci-merged.yml
graph.svg
devp_lint_report.json
.public
/dist/
# Other
*.tmp

25
rbd_exporter/Makefile Normal file
View File

@ -0,0 +1,25 @@
include scripts/devp/platform.mk
.PHONY: generate
generate: devp/generate-go
.PHONY: test
test: devp/test-go
.PHONY: lint
lint: devp/lint-go-default
.PHONY: format
format: devp/format-go
.PHONY: go-mod-tidy
go-mod-tidy: devp/go-mod-tidy
.PHONY: ci/check
ci/check: devp/ci/check
@# This target is called during Big Bang 'Validate' CI job
.PHONY: ci/test/unit
ci/test/unit: devp/coverage
@# This target is called during Big Bang 'Test' CI job

12
rbd_exporter/devp.yaml Normal file
View File

@ -0,0 +1,12 @@
version: 3
cloud:
service: "my-service"
my-cloud-component:
type: "cloud"
stands:
- "dev"
build:
template: "golang"
config:
builder-version: 0.75.0
uses: []

View File

@ -2,13 +2,14 @@ module rbd_exporter
go 1.25.5
require github.com/prometheus/client_golang v1.23.2
require (
github.com/prometheus/client_golang v1.23.2
go.uber.org/mock v0.6.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/mock v0.6.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@ -6,8 +6,18 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -20,9 +30,12 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
@ -31,34 +44,12 @@ go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -0,0 +1,5 @@
BUILD_REL_PATH := .build
BUILD_PATH := ${PWD_PATH}/${BUILD_REL_PATH}
${BUILD_PATH}:
$(Q) mkdir -p $@

View File

@ -0,0 +1,37 @@
DEVP_CHANGIE_CONFIG_PATH := $(if $(DEVP_CHANGIE_CONFIG_PATH),$(DEVP_CHANGIE_CONFIG_PATH),"./.changes/.changie.yaml")
DEVP_CHANGIE_EDITOR := $(if $(DEVP_CHANGIE_EDITOR),$(DEVP_CHANGIE_EDITOR),$(EDITOR))
DEVP_CHANGIE_USE_EDITOR := $(if $(DEVP_CHANGIE_EDITOR),true,false)
DEVP_CHANGIE_CMD := CHANGIE_CONFIG_PATH=${DEVP_CHANGIE_CONFIG_PATH} EDITOR="${DEVP_CHANGIE_EDITOR}" ${DEVP_CHANGIE_EXE}
.PHONY: devp/changes/new
devp/changes/new: ${DEVP_CHANGIE_EXE}
@# Add changelog record
$(Q) ${DEVP_CHANGIE_CMD} new --editor=${DEVP_CHANGIE_USE_EDITOR} ${DEVP_CHANGIE_NEW_ARGS}
.PHONY: devp/changes/render
devp/changes/render: ${DEVP_CHANGIE_EXE}
@# Renders changelog. Debug target that allows developer to see how his changes will be displayed in a changelog
$(Q) ${DEVP_CHANGIE_CMD} batch patch --keep
.PHONY: devp/changes/release
devp/changes/release: ${DEVP_CHANGIE_EXE}
@# Renders changelog for release
$(Q) ${DEVP_CHANGIE_CMD} batch ${DEVP_CHANGIE_NEXT_VERSION}
.PHONY: devp/changes/merge
devp/changes/merge: ${DEVP_CHANGIE_EXE}
@# Merges last changelog to the main changelog file
$(Q) ${DEVP_CHANGIE_CMD} merge
.PHONY: devp/changes/latest
devp/changes/latest: ${DEVP_CHANGIE_EXE}
@# Get latest release version
$(Q) ${DEVP_CHANGIE_CMD} latest
.PHONY: devp/changes/get-text
devp/changes/get-text: ${DEVP_DEVPTOOL_EXE} ${DEVP_CHANGIE_EXE}
@# Generates latest release announce text and copies it to clipboard
$(Q) DEVP_CHANGIE_CONFIG_PATH=${DEVP_CHANGIE_CONFIG_PATH} \
DEVP_CHANGES_TITLE=${DEVP_CHANGES_TITLE} \
DEVP_CHANGES_FOOTER=${DEVP_CHANGES_FOOTER} \
${DEVP_DEVPTOOL_EXE} changes get-text

View File

@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
COMMANDS=${1:-}
REPLACED_MESSAGE=${REPLACED_MESSAGE:-}
# Note that when running locally this will check for untracked files.
if [ -z "$(git status --porcelain)" ]; then
echo "OK, working tree is clean."
exit 0
fi
echo -e "\e[0Ksection_start:$(date +%s):git_status[collapsed=true]\r\e[0Kgit status"
git status
echo -e "\e[0Ksection_end:$(date +%s):git_status\r\e[0K"
echo -e "\e[0Ksection_start:$(date +%s):git_diff[collapsed=true]\r\e[0Kgit diff"
git diff
echo -e "\e[0Ksection_end:$(date +%s):git_diff\r\e[0K"
echo
if [ -n "$REPLACED_MESSAGE" ]; then
echo "$REPLACED_MESSAGE"
elif [ -n "$COMMANDS" ]; then
echo "❗Please run '$COMMANDS' locally and commit the changes."
else
echo "❗There are uncommitted changes. Check git diff/status above. Try running 'make devp/format-go devp/go-mod-tidy' locally and make sure everything is generated."
fi
exit 1

View File

@ -0,0 +1,27 @@
.PHONY: devp/check/git
devp/check/git:
@# Check that git tree is clean. You can pass $REPLACED_MESSAGE variable to replace message text when working tree is not clean
$(Q) echo "Checking that git tree is clean"
$(Q) ${DEVP_SCRIPTS}/check-clean-working-tree.sh
.PHONY: devp/ci/check
devp/ci/check: devp/ci/check/go-mod-tidy \
devp/ci/check/reinstall \
devp/ci/check/format-go \
devp/lint-go-default
@# Perform default platform CI checks
.PHONY: devp/ci/check/go-mod-tidy
devp/ci/check/go-mod-tidy: devp/go-mod-tidy
@# Check there are no changes after devp/go-mod-tidy
$(Q) ${DEVP_SCRIPTS}/check-clean-working-tree.sh "make devp/go-mod-tidy"
.PHONY: devp/ci/check/reinstall
devp/ci/check/reinstall: devp/reinstall
@# Check there are no changes in platform files
$(Q) REPLACED_MESSAGE="There are changes in platform files. Undo the changes in 'scripts/devp' folder." ${DEVP_SCRIPTS}/check-clean-working-tree.sh
.PHONY: devp/ci/check/format-go
devp/ci/check/format-go: devp/format-go
@# Check there is no changes after devp/format-go
$(Q) ${DEVP_SCRIPTS}/check-clean-working-tree.sh "make devp/format-go"

View File

@ -0,0 +1,24 @@
include scripts/devp/platform.mk
.PHONY: generate
generate: devp/generate-go
.PHONY: test
test: devp/test-go
.PHONY: lint
lint: devp/lint-go-default
.PHONY: format
format: devp/format-go
.PHONY: go-mod-tidy
go-mod-tidy: devp/go-mod-tidy
.PHONY: ci/check
ci/check: devp/ci/check
@# This target is called during Big Bang 'Validate' CI job
.PHONY: ci/test/unit
ci/test/unit: devp/coverage
@# This target is called during Big Bang 'Test' CI job

View File

@ -0,0 +1,12 @@
version: 3
cloud:
service: "my-service"
my-cloud-component:
type: "cloud"
stands:
- "dev"
build:
template: "golang"
config:
builder-version: 0.75.0
uses: []

View File

@ -0,0 +1,23 @@
# IntelliJ IDEA
.idea
*.iml
*.ipr
*.iws
# macOS
.DS_Store
# Golang
*.prof
*.exe
*.test
*.report
*.out
/bin/
/tmp/
/.build/
/vendor/
# test results
coverage.txt
coverage.xml

View File

@ -0,0 +1,44 @@
# IntelliJ IDEA
.idea/
*.iml
*.ipr
*.iws
dist/
# VSCode
.vscode/
# zed
.zed/
# macOS
.DS_Store
# Golang
*.prof
*.exe
*.test
*.report
*.out
/bin/
/tmp/
/.build/
/.devp/
/vendor/
go.work
go.work.sum
# test results
coverage.txt
coverage.xml
# Platform
scripts/golangci-merged.yml
graph.svg
devp_lint_report.json
.public
/dist/
# Other
*.tmp

View File

@ -0,0 +1,26 @@
#!/bin/bash
set -euo pipefail
VERSION=0.75.0
SRC_DIR=$(realpath $(dirname -- "${BASH_SOURCE[0]}"))
# TODO(mitya): group for files created in docker container is still incorrect
mkdir -p ${HOME}/.devp/ci-builder-golang/${VERSION}/go
docker run -w /work \
-v $(pwd):/work \
-e HOST_USER=${USER} \
-e HOST_UID=$(id -u ${USER}) \
-e HOST_GID=$(id -g ${USER}) \
-v ${SRC_DIR}/dockerentry.sh:/dockerentry.sh:ro \
-v ${HOME}/.devp/ci-builder-golang/${VERSION}/go:/tmp/go:rw \
-e GOCACHE=/tmp/go/.cache \
-e GOMODCACHE=/tmp/go/.modcache \
-e GOLANGCI_LINT_CACHE=/tmp/go/.lintcache \
-e BIN_PATH=/work/bin/docker \
--rm -it harbor.mws-team.ru/mws-devp/infra/ci-builder-golang:${VERSION} \
/dockerentry.sh $@

View File

@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail
echo UID_MAX ${HOST_UID} >> /etc/login.defs
USER_HOME="/home/${HOST_USER}"
useradd -m -u ${HOST_UID} ${HOST_USER} -s /bin/bash
su ${HOST_USER} -m -c "HOME='$USER_HOME' PATH='$PATH' $*"

View File

@ -0,0 +1,24 @@
.PHONY: devp/format-go
devp/format-go: ${DEVP_FORMAT_EXE}
@# Run formatter for project
$(Q) ${DEVP_FORMAT_EXE} project ${VERBOSE_FLAG}
.PHONY: devp/format-go/vscode-enable
devp/format-go/vscode-enable: ${DEVP_DEVPTOOL_EXE} ${DEVP_FORMAT_EXE}
@# Enable platform formatting in VS Code
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide vscode formatter --tool-path=${DEVP_FORMAT_EXE}
.PHONY: devp/format-go/vscode-disable
devp/format-go/vscode-disable: ${DEVP_DEVPTOOL_EXE} ${DEVP_FORMAT_EXE}
@# Disable platform formatting in VS Code
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide vscode formatter --tool-path=${DEVP_FORMAT_EXE} --enable=false
.PHONY: devp/format-go/goland-enable
devp/format-go/goland-enable: ${DEVP_DEVPTOOL_EXE} ${DEVP_FORMAT_EXE}
@# Enable platform formatting in Goland
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide goland formatter --tool-path=${DEVP_FORMAT_EXE}
.PHONY: devp/format-go/goland-disable
devp/format-go/goland-disable: ${DEVP_DEVPTOOL_EXE} ${DEVP_FORMAT_EXE}
@# Disable platform formatting in Goland
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide goland formatter --tool-path=${DEVP_FORMAT_EXE} --enable=false

View File

@ -0,0 +1,4 @@
.PHONY: devp/generate-go
devp/generate-go:
@# Run 'go generate' for project
$(Q) go generate ./...

View File

@ -0,0 +1,9 @@
.PHONY: devp/godeviz/show
devp/godeviz/show: ${DEVP_GODEVIZ_EXE}
@# Show interactive dependency graph for the current project
$(Q) ${DEVP_GODEVIZ_EXE} show
.PHONY: devp/godeviz/svg
devp/godeviz/svg: ${DEVP_GODEVIZ_EXE}
@# Show dependency graph for the current project
$(Q) ${DEVP_GODEVIZ_EXE} svg

View File

@ -0,0 +1,4 @@
.PHONY: devp/go-mod-tidy
devp/go-mod-tidy:
@# Run 'go mod tidy' for project
$(Q) go mod tidy

View File

@ -0,0 +1,9 @@
.PHONY: devp/help
devp/help:
@# List all targets
$(Q) ${DEVP_SCRIPTS}/list-targets.sh $(MAKE) $(firstword $(MAKEFILE_LIST))
.PHONY: devp/help/short
devp/help/short:
@# List Makefile targets only
$(Q) ${DEVP_SCRIPTS}/list-targets.sh $(MAKE) $(firstword $(MAKEFILE_LIST)) true

View File

@ -0,0 +1,13 @@
include ${DEVP_SCRIPTS}/install/install.gen.mk
.PHONY: devp/remove
devp/remove:
@# Remove all installed platform files
@echo Removing folder ${DEVP_ROOT}
$(Q) rm -rf ${DEVP_ROOT}
.PHONY: devp/reinstall
devp/reinstall: ${DEVP_DEVPTOOL_EXE}
@# Reinstalling current platform version
$(Q) echo "Reinstalling current platform version..."
$(Q) ${DEVP_DEVPTOOL_EXE} golang install --force --files-only --output=${DEVP_SCRIPTS_ROOT}

View File

@ -0,0 +1,20 @@
DEVP_CHANGIE_VERSION = v1.24.0
DEVP_CHANGIE_DIR = ${DEVP_TOOLS_ROOT}/changie/${DEVP_CHANGIE_VERSION}
DEVP_CHANGIE_EXE = ${DEVP_CHANGIE_DIR}/changie
${DEVP_CHANGIE_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[changie] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_CHANGIE_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_CHANGIE_DIR} go install github.com/miniscruff/changie@${DEVP_CHANGIE_VERSION}
$(call green,"changie installed as $@")
.PHONY: devp/install/changie
devp/install/changie: ${DEVP_CHANGIE_EXE}
@# Install changie - v1.24.0

View File

@ -0,0 +1,20 @@
DEVP_DEVPTOOL_VERSION = v${DEVP_VERSION}
DEVP_DEVPTOOL_DIR = ${DEVP_TOOLS_ROOT}/devp/${DEVP_DEVPTOOL_VERSION}
DEVP_DEVPTOOL_EXE = ${DEVP_DEVPTOOL_DIR}/devp
${DEVP_DEVPTOOL_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[devp] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_DEVPTOOL_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_DEVPTOOL_DIR} go install git.mws-team.ru/mws/devp/platform-go-tools/cmd/devp@${DEVP_DEVPTOOL_VERSION}
$(call green,"devp installed as $@")
.PHONY: devp/install/devp
devp/install/devp: ${DEVP_DEVPTOOL_EXE}
@# Install devp - v${DEVP_VERSION}

View File

@ -0,0 +1,20 @@
DEVP_FORMAT_VERSION = v0.3.1
DEVP_FORMAT_DIR = ${DEVP_TOOLS_ROOT}/devpformat/${DEVP_FORMAT_VERSION}
DEVP_FORMAT_EXE = ${DEVP_FORMAT_DIR}/devpformat
${DEVP_FORMAT_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[devpformat] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_FORMAT_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_FORMAT_DIR} go install git.mws-team.ru/mws/devp/devpformat/cmd/devpformat@${DEVP_FORMAT_VERSION}
$(call green,"devpformat installed as $@")
.PHONY: devp/install/devpformat
devp/install/devpformat: ${DEVP_FORMAT_EXE}
@# Install devpformat - v0.3.1

View File

@ -0,0 +1,20 @@
DEVP_LINT_VERSION = v${DEVP_VERSION}
DEVP_LINT_DIR = ${DEVP_TOOLS_ROOT}/devplint/${DEVP_LINT_VERSION}
DEVP_LINT_EXE = ${DEVP_LINT_DIR}/devplint
${DEVP_LINT_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[devplint] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_LINT_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_LINT_DIR} go install git.mws-team.ru/mws/devp/platform-go-tools/cmd/devplint@${DEVP_LINT_VERSION}
$(call green,"devplint installed as $@")
.PHONY: devp/install/devplint
devp/install/devplint: ${DEVP_LINT_EXE}
@# Install devplint - v${DEVP_VERSION}

View File

@ -0,0 +1,20 @@
DEVP_DLV_VERSION = v1.25.2
DEVP_DLV_DIR = ${DEVP_TOOLS_ROOT}/dlv/${DEVP_DLV_VERSION}
DEVP_DLV_EXE = ${DEVP_DLV_DIR}/dlv
${DEVP_DLV_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[dlv] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_DLV_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_DLV_DIR} go install github.com/go-delve/delve/cmd/dlv@${DEVP_DLV_VERSION}
$(call green,"dlv installed as $@")
.PHONY: devp/install/dlv
devp/install/dlv: ${DEVP_DLV_EXE}
@# Install dlv - v1.25.2

View File

@ -0,0 +1,22 @@
DEVP_GOCOVER_COBERTURA_VERSION = v1.4.0
DEVP_GOCOVER_COBERTURA_DIR = ${DEVP_TOOLS_ROOT}/gocover-cobertura/${DEVP_GOCOVER_COBERTURA_VERSION}
DEVP_GOCOVER_COBERTURA_EXE = ${DEVP_GOCOVER_COBERTURA_DIR}/gocover-cobertura
${DEVP_GOCOVER_COBERTURA_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[gocover-cobertura] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_GOCOVER_COBERTURA_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_GOCOVER_COBERTURA_DIR} go install github.com/boumenot/gocover-cobertura@${DEVP_GOCOVER_COBERTURA_VERSION}
$(call green,"gocover-cobertura installed as $@")
.PHONY: devp/install/gocover-cobertura
devp/install/gocover-cobertura: ${DEVP_GOCOVER_COBERTURA_EXE}
@# Install gocover-cobertura - v1.4.0
DEVP_COBERTURA := ${DEVP_BUILD}/cobertura

View File

@ -0,0 +1,20 @@
DEVP_GODEVIZ_VERSION = v0.0.3
DEVP_GODEVIZ_DIR = ${DEVP_TOOLS_ROOT}/godeviz/${DEVP_GODEVIZ_VERSION}
DEVP_GODEVIZ_EXE = ${DEVP_GODEVIZ_DIR}/godeviz
${DEVP_GODEVIZ_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[godeviz] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_GODEVIZ_DIR}
$(Q) CGO_ENABLED=1 GOBIN=${DEVP_GODEVIZ_DIR} go install git.mws-team.ru/mws/devp/godeviz/cmd/godeviz@${DEVP_GODEVIZ_VERSION}
$(call green,"godeviz installed as $@")
.PHONY: devp/install/godeviz
devp/install/godeviz: ${DEVP_GODEVIZ_EXE}
@# Install godeviz - v0.0.3

View File

@ -0,0 +1,21 @@
DEVP_GOLANG_CI_LINT_VERSION = v2.7.2
DEVP_GOLANG_CI_LINT_DIR = ${DEVP_TOOLS_ROOT}/golangci-lint/${DEVP_GOLANG_CI_LINT_VERSION}/curl
DEVP_GOLANG_CI_LINT_EXE = ${DEVP_GOLANG_CI_LINT_DIR}/golangci-lint
${DEVP_GOLANG_CI_LINT_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[golangci-lint] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_GOLANG_CI_LINT_DIR}
# https://golangci-lint.run/usage/install/#local-installation
$(Q) bash -eo pipefail -c "curl -m 60 -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b ${DEVP_GOLANG_CI_LINT_DIR} ${DEVP_GOLANG_CI_LINT_VERSION} $(if $(VERBOSE),, 2>/dev/null)"
$(call green,"golangci-lint installed as $@")
.PHONY: devp/install/golangci-lint
devp/install/golangci-lint: ${DEVP_GOLANG_CI_LINT_EXE}
@# Install golangci-lint - v2.7.2

View File

@ -0,0 +1,24 @@
DEVP_GOTESTSUM_VERSION = v1.13.0
DEVP_GOTESTSUM_DIR = ${DEVP_TOOLS_ROOT}/gotestsum/${DEVP_GOTESTSUM_VERSION}
DEVP_GOTESTSUM_EXE = ${DEVP_GOTESTSUM_DIR}/gotestsum
${DEVP_GOTESTSUM_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[gotestsum] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_GOTESTSUM_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_GOTESTSUM_DIR} go install gotest.tools/gotestsum@${DEVP_GOTESTSUM_VERSION}
$(call green,"gotestsum installed as $@")
.PHONY: devp/install/gotestsum
devp/install/gotestsum: ${DEVP_GOTESTSUM_EXE}
@# Install gotestsum - v1.13.0
DEVP_JUNIT := ${DEVP_BUILD}/junit
DEVP_JUNIT_TESTSUM := ${DEVP_JUNIT}/gotestsum.xml
DEVP_GOTESTSUM_CMD := mkdir -p ${DEVP_JUNIT} && ${DEVP_GOTESTSUM_EXE} --junitfile ${DEVP_JUNIT_TESTSUM} -- -race -coverprofile=${DEVP_BUILD}/coverage.out ./...

View File

@ -0,0 +1,20 @@
DEVP_GOWRAP_VERSION = v1.4.3
DEVP_GOWRAP_DIR = ${DEVP_TOOLS_ROOT}/gowrap/${DEVP_GOWRAP_VERSION}
DEVP_GOWRAP_EXE = ${DEVP_GOWRAP_DIR}/gowrap
${DEVP_GOWRAP_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[gowrap] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_GOWRAP_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_GOWRAP_DIR} go install github.com/hexdigest/gowrap/cmd/gowrap@${DEVP_GOWRAP_VERSION}
$(call green,"gowrap installed as $@")
.PHONY: devp/install/gowrap
devp/install/gowrap: ${DEVP_GOWRAP_EXE}
@# Install gowrap - v1.4.3

View File

@ -0,0 +1,42 @@
DEVP_INSTALL_SCRIPTS := ${DEVP_SCRIPTS}/install
include ${DEVP_INSTALL_SCRIPTS}/golangci-lint.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/mockgen.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/ogen.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/devp.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/devpformat.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/dlv.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/protoc.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/protoc-gen-go.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/protoc-gen-go-grpc.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/yq.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/gotestsum.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/godeviz.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/gowrap.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/gocover-cobertura.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/devplint.gen.mk
include ${DEVP_INSTALL_SCRIPTS}/changie.gen.mk
.PHONY: devp/install/all
devp/install/all: ${DEVP_GOLANG_CI_LINT_EXE} ${DEVP_MOCKGEN_EXE} ${DEVP_OGEN_EXE} ${DEVP_DEVPTOOL_EXE} ${DEVP_FORMAT_EXE} ${DEVP_DLV_EXE} ${DEVP_PROTOC_EXE} ${DEVP_PROTOC_GEN_GO_EXE} ${DEVP_PROTOC_GEN_GO_GRPC_EXE} ${DEVP_YQ_EXE} ${DEVP_GOTESTSUM_EXE} ${DEVP_GODEVIZ_EXE} ${DEVP_GOWRAP_EXE} ${DEVP_GOCOVER_COBERTURA_EXE} ${DEVP_LINT_EXE} ${DEVP_CHANGIE_EXE}
@# Install all tools
.PHONY: devp/install/list
devp/install/list:
@# Show location of used tools
@echo 'DEVP_GOLANG_CI_LINT_EXE = "${DEVP_GOLANG_CI_LINT_EXE}"'
@echo 'DEVP_MOCKGEN_EXE = "${DEVP_MOCKGEN_EXE}"'
@echo 'DEVP_OGEN_EXE = "${DEVP_OGEN_EXE}"'
@echo 'DEVP_DEVPTOOL_EXE = "${DEVP_DEVPTOOL_EXE}"'
@echo 'DEVP_FORMAT_EXE = "${DEVP_FORMAT_EXE}"'
@echo 'DEVP_DLV_EXE = "${DEVP_DLV_EXE}"'
@echo 'DEVP_PROTOC_EXE = "${DEVP_PROTOC_EXE}"'
@echo 'DEVP_PROTOC_GEN_GO_EXE = "${DEVP_PROTOC_GEN_GO_EXE}"'
@echo 'DEVP_PROTOC_GEN_GO_GRPC_EXE = "${DEVP_PROTOC_GEN_GO_GRPC_EXE}"'
@echo 'DEVP_YQ_EXE = "${DEVP_YQ_EXE}"'
@echo 'DEVP_GOTESTSUM_EXE = "${DEVP_GOTESTSUM_EXE}"'
@echo 'DEVP_GODEVIZ_EXE = "${DEVP_GODEVIZ_EXE}"'
@echo 'DEVP_GOWRAP_EXE = "${DEVP_GOWRAP_EXE}"'
@echo 'DEVP_GOCOVER_COBERTURA_EXE = "${DEVP_GOCOVER_COBERTURA_EXE}"'
@echo 'DEVP_LINT_EXE = "${DEVP_LINT_EXE}"'
@echo 'DEVP_CHANGIE_EXE = "${DEVP_CHANGIE_EXE}"'

View File

@ -0,0 +1,20 @@
DEVP_MOCKGEN_VERSION = v0.6.0
DEVP_MOCKGEN_DIR = ${DEVP_TOOLS_ROOT}/mockgen/${DEVP_MOCKGEN_VERSION}
DEVP_MOCKGEN_EXE = ${DEVP_MOCKGEN_DIR}/mockgen
${DEVP_MOCKGEN_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[mockgen] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_MOCKGEN_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_MOCKGEN_DIR} go install go.uber.org/mock/mockgen@${DEVP_MOCKGEN_VERSION}
$(call green,"mockgen installed as $@")
.PHONY: devp/install/mockgen
devp/install/mockgen: ${DEVP_MOCKGEN_EXE}
@# Install mockgen - v0.6.0

View File

@ -0,0 +1,20 @@
DEVP_OGEN_VERSION = v1.18.0
DEVP_OGEN_DIR = ${DEVP_TOOLS_ROOT}/ogen/${DEVP_OGEN_VERSION}
DEVP_OGEN_EXE = ${DEVP_OGEN_DIR}/ogen
${DEVP_OGEN_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[ogen] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_OGEN_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_OGEN_DIR} go install github.com/ogen-go/ogen/cmd/ogen@${DEVP_OGEN_VERSION}
$(call green,"ogen installed as $@")
.PHONY: devp/install/ogen
devp/install/ogen: ${DEVP_OGEN_EXE}
@# Install ogen - v1.18.0

View File

@ -0,0 +1,22 @@
DEVP_PROTOC_GEN_GO_GRPC_VERSION = v1.6.0
DEVP_PROTOC_GEN_GO_GRPC_DIR = ${DEVP_TOOLS_ROOT}/protoc-gen-go-grpc/${DEVP_PROTOC_GEN_GO_GRPC_VERSION}
DEVP_PROTOC_GEN_GO_GRPC_EXE = ${DEVP_PROTOC_GEN_GO_GRPC_DIR}/protoc-gen-go-grpc
${DEVP_PROTOC_GEN_GO_GRPC_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[protoc-gen-go-grpc] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_PROTOC_GEN_GO_GRPC_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_PROTOC_GEN_GO_GRPC_DIR} go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@${DEVP_PROTOC_GEN_GO_GRPC_VERSION}
$(call green,"protoc-gen-go-grpc installed as $@")
.PHONY: devp/install/protoc-gen-go-grpc
devp/install/protoc-gen-go-grpc: ${DEVP_PROTOC_GEN_GO_GRPC_EXE}
@# Install protoc-gen-go-grpc - v1.6.0
DEVP_PROTOC_GO_GRPC_CMD := ${DEVP_PROTOC_CMD} --plugin=protoc-gen-go=${DEVP_PROTOC_GEN_GO_EXE} --plugin=protoc-gen-go-grpc=${DEVP_PROTOC_GEN_GO_GRPC_EXE}

View File

@ -0,0 +1,22 @@
DEVP_PROTOC_GEN_GO_VERSION = v1.36.10
DEVP_PROTOC_GEN_GO_DIR = ${DEVP_TOOLS_ROOT}/protoc-gen-go/${DEVP_PROTOC_GEN_GO_VERSION}
DEVP_PROTOC_GEN_GO_EXE = ${DEVP_PROTOC_GEN_GO_DIR}/protoc-gen-go
${DEVP_PROTOC_GEN_GO_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[protoc-gen-go] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_PROTOC_GEN_GO_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_PROTOC_GEN_GO_DIR} go install google.golang.org/protobuf/cmd/protoc-gen-go@${DEVP_PROTOC_GEN_GO_VERSION}
$(call green,"protoc-gen-go installed as $@")
.PHONY: devp/install/protoc-gen-go
devp/install/protoc-gen-go: ${DEVP_PROTOC_GEN_GO_EXE}
@# Install protoc-gen-go - v1.36.10
DEVP_PROTOC_GO_CMD := ${DEVP_PROTOC_CMD} --plugin=protoc-gen-go=${DEVP_PROTOC_GEN_GO_EXE}

View File

@ -0,0 +1,22 @@
DEVP_PROTOC_VERSION = 33.2
DEVP_PROTOC_DIR = ${DEVP_TOOLS_ROOT}/protoc/${DEVP_PROTOC_VERSION}
DEVP_PROTOC_EXE = ${DEVP_PROTOC_DIR}/protoc/bin/protoc
${DEVP_PROTOC_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[protoc] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_PROTOC_DIR}
$(Q) ${DEVP_INSTALL_SCRIPTS}/protoc.sh "${DEVP_PROTOC_DIR}" ${DEVP_PROTOC_VERSION} "$(OS)"
$(call green,"protoc installed as $@")
.PHONY: devp/install/protoc
devp/install/protoc: ${DEVP_PROTOC_EXE}
@# Install protoc - 33.2
DEVP_PROTOC_CMD := ${DEVP_PROTOC_EXE} -I ${DEVP_PROTOC_DIR}/protoc/include

View File

@ -0,0 +1,51 @@
#!/bin/bash
set -euo pipefail
# Checking that we got all arguments
if [[ $# -ne 3 ]]; then
echo "Illegal number of arguments: $#. Expected: 3"
exit 1
fi
DEVP_BIN=$1
PROTOC_VERSION=$2
OS_VERSION=$3
if [ "${OS_VERSION}" = "Windows_NT" ]
then
echo "Unsupported OS ${OS_VERSION}"
exit 1
fi
# Preparing protoc zip file name
UNAME_S=$(uname -s)
if [ "Linux" = "${UNAME_S}" ];
then
OSNAME="linux"
elif [ "Darwin" = "${UNAME_S}" ];
then
OSNAME="osx"
else
echo "Unsupported OS ${UNAME_S}"
exit 1
fi
UNAME_M=$(uname -m)
if [ "x86_64" = "${UNAME_M}" ] || [ "arm64" = "${UNAME_M}" ];
then
PROTOC_ARCH="${OSNAME}-x86_64"
else
PROTOC_ARCH="${OSNAME}-x86_32"
fi
PROTOC_ZIP_NAME="protoc-${PROTOC_VERSION}-${PROTOC_ARCH}.zip"
PROTOC_URL="https://nexus.mws-team.ru/repository/github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP_NAME}"
PROTOC_DIR="${DEVP_BIN}/protoc"
PROTOC_ZIP_PATH="${PROTOC_DIR}/${PROTOC_ZIP_NAME}"
mkdir "${PROTOC_DIR}"
curl -sSLO --output-dir "${PROTOC_DIR}" "${PROTOC_URL}"
unzip -qq "${PROTOC_ZIP_PATH}" -d "${PROTOC_DIR}"
rm "${PROTOC_ZIP_PATH}"

View File

@ -0,0 +1,20 @@
DEVP_YQ_VERSION = v4.49.2
DEVP_YQ_DIR = ${DEVP_TOOLS_ROOT}/yq/${DEVP_YQ_VERSION}
DEVP_YQ_EXE = ${DEVP_YQ_DIR}/yq
${DEVP_YQ_EXE}:
ifdef DEVP_NO_INSTALL
ifneq ($(DEVP_VERSION),$(DEVP_CI_BUILDER_VERSION))
$(call error_message,"Platform version is [${DEVP_VERSION}] image version is [${DEVP_CI_BUILDER_VERSION}]. Same version is expected. Updating with [make devp/update] might help. DEVP_NO_INSTALL == 1. See: https://mws.pages.mws-team.ru/devp/platform-go-tools/pgt/user/pages/platform-update.html")
@exit 1
endif
$(call error_message,"[yq] is expected to be installed but it is not. Please contact /duty golang for support.")
@exit 1
endif
$(Q) mkdir -p ${DEVP_YQ_DIR}
$(Q) CGO_ENABLED=0 GOBIN=${DEVP_YQ_DIR} go install github.com/mikefarah/yq/v4@${DEVP_YQ_VERSION}
$(call green,"yq installed as $@")
.PHONY: devp/install/yq
devp/install/yq: ${DEVP_YQ_EXE}
@# Install yq - v4.49.2

View File

@ -0,0 +1,150 @@
version: "2"
run:
concurrency: 4
relative-path-mode: gomod
linters:
default: none
enable:
- asasalint
- asciicheck
- bodyclose
- containedctx
- copyloopvar
- cyclop
- dogsled
- err113
- errcheck
- errname
- errorlint
- exptostd
- forbidigo
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- gocritic
- gomoddirectives
- goprintffuncname
- gosec
- govet
- grouper
- ineffassign
- lll
- misspell
- nakedret
- nilerr
- nilnesserr
- noctx
- nolintlint
- prealloc
- predeclared
- revive
- staticcheck
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- whitespace
settings:
cyclop:
max-complexity: 15
goconst:
match-constant: false
gocritic:
disabled-checks:
- commentFormatting
gosec:
config:
G306: "0644"
govet:
disable:
- fieldalignment
enable-all: true
lll:
line-length: 160
mnd:
ignored-numbers:
- "0644"
- "0755"
nolintlint:
require-explanation: true
require-specific: true
staticcheck:
checks:
- -ST1000
- -ST1003
- -ST1020
- -ST1021
- -ST1022
- all
usestdlibvars:
time-month: true
time-layout: true
crypto-hash: true
default-rpc-path: true
tls-signature-scheme: true
constant-kind: true
usetesting:
os-temp-dir: true
revive:
rules:
- name: var-naming
arguments:
- [] # AllowList
- [] # DenyList
- - skip-package-name-collision-with-go-std: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: 'SA1019:'
- linters:
- err113
path-except: pkg\/
- linters:
- err113
- errcheck
- funlen
- gocyclo
- gosec
- lll
- mnd
- prealloc
path: _test\.go
- linters:
- goconst
path: (.+)_test\.go
paths:
- .*\_gen\.go$
- .*\.gen\.go$
- .*\_gen\_test\.go$
- .*\.gen\_test\.go$
- .*\.pb\.go$
- mock
- vendor
- testdata
- test_data
- third_party$
- third-party$
- builtin$
- examples$
- example$
issues:
max-issues-per-linter: 0
max-same-issues: 0
uniq-by-line: false
formatters:
exclusions:
generated: lax
paths:
- third_party$
- third-party$
- builtin$
- examples$
- example$

View File

@ -0,0 +1,104 @@
DEVP_LINT_GOGC := $(if $(DEVP_LINT_GOGC),$(DEVP_LINT_GOGC),100)
DEVP_LINT_ARGS := $(if $(DEVP_LINT_ARGS),$(DEVP_LINT_ARGS),)
.PHONY: devp/lint-go
devp/lint-go: ${DEVP_GOLANG_CI_LINT_EXE}
@# Run linter with local config
$(Q) GOGC=${DEVP_LINT_GOGC} ${DEVP_GOLANG_CI_LINT_EXE} -v run ./...
.PHONY: devp/lint-go-fix
devp/lint-go-fix: ${DEVP_GOLANG_CI_LINT_EXE}
@# Run linter with local config and --fix flag
$(Q) GOGC=${DEVP_LINT_GOGC} ${DEVP_GOLANG_CI_LINT_EXE} -v run ./... --fix
.PHONY: devp/lint-go/vscode-enable
devp/lint-go/vscode-enable: ${DEVP_DEVPTOOL_EXE} ${DEVP_LINT_EXE}
@# Enable platform linting in VS Code
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide vscode linter --devplint-path=${DEVP_LINT_EXE} --golangci-lint-path=${DEVP_GOLANG_CI_LINT_EXE}
.PHONY: devp/lint-go/vscode-disable
devp/lint-go/vscode-disable: ${DEVP_DEVPTOOL_EXE} ${DEVP_GOLANG_CI_LINT_EXE} ${DEVP_LINT_EXE}
@# Disable platform linting in VS Code
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide vscode linter --devplint-path=${DEVP_LINT_EXE} --golangci-lint-path=${DEVP_GOLANG_CI_LINT_EXE} --enable=false
.PHONY: devp/lint-go/goland-enable
devp/lint-go/goland-enable: ${DEVP_DEVPTOOL_EXE} ${DEVP_GOLANG_CI_LINT_EXE} ${DEVP_LINT_EXE}
@# Enable platform linting in Goland
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide goland linter --devplint-path=${DEVP_LINT_EXE} --golangci-lint-path=${DEVP_GOLANG_CI_LINT_EXE}
.PHONY: devp/lint-go/goland-disable
devp/lint-go/goland-disable: ${DEVP_DEVPTOOL_EXE} ${DEVP_GOLANG_CI_LINT_EXE} ${DEVP_LINT_EXE}
@# Disable platform linting in Goland
$(Q) ${DEVP_DEVPTOOL_EXE} golang configure-ide goland linter --devplint-path=${DEVP_LINT_EXE} --golangci-lint-path=${DEVP_GOLANG_CI_LINT_EXE} --enable=false
DEVP_LINT_SCRIPTS_ROOT := $(if $(DEVP_LINT_SCRIPTS_ROOT),$(DEVP_LINT_SCRIPTS_ROOT),.)
DEVP_LINT_DEFAULT_PATH = ${DEVP_SCRIPTS}/lint/golangci.yml
DEVP_LINT_FIX_PATH := ${DEVP_LINT_SCRIPTS_ROOT}/scripts/golangci-fix.yml
DEVP_LINT_MERGED_PATH := ${DEVP_LINT_SCRIPTS_ROOT}/scripts/golangci-merged.yml
# If 'scripts/golangci-fix.yml' file exists, we need to merge it with the default config
# Otherwise we just use the default config directly
ifeq ($(wildcard ${DEVP_LINT_FIX_PATH}),)
DEVP_LINT_CONFIG_PATH = ${DEVP_LINT_DEFAULT_PATH}
DEVP_LINT_FIX = 0
else
DEVP_LINT_CONFIG_PATH = ${DEVP_LINT_MERGED_PATH}
DEVP_LINT_FIX = 1
endif
DEVP_GOLANG_CI_LINT_CMD := ${DEVP_GOLANG_CI_LINT_EXE} -v --config ${DEVP_LINT_CONFIG_PATH} ${DEVP_LINT_ARGS} run
.PHONY: devp/lint-clean-config
devp/lint-clean-config:
@# Remove merged config if 'scripts/golangci-fix.yml' doesn't exist
ifeq ($(DEVP_LINT_FIX), 0)
$(Q) rm -f ${DEVP_LINT_MERGED_PATH}
endif
${DEVP_LINT_MERGED_PATH}: ${DEVP_YQ_EXE} ${DEVP_LINT_DEFAULT_PATH} $(wildcard ${DEVP_LINT_FIX_PATH})
@# Config file merged from the default platform config and 'scripts/golangci-fix.yml'
$(Q) echo "Generating merged config into '${@}'"
$(Q) ${DEVP_SCRIPTS}/lint/merge-lint-config.sh $@ $^
.PHONY: devp/lint-config-verify
devp/lint-config-verify:
@# Verify linting config
$(Q) echo "Verifying linting config"
$(Q) ${DEVP_GOLANG_CI_LINT_EXE} config verify --config ${DEVP_LINT_CONFIG_PATH}
.PHONY: devp/lint-deps
devp/lint-deps: devp/lint-clean-config ${DEVP_GOLANG_CI_LINT_EXE} ${DEVP_LINT_CONFIG_PATH}
@# Prepare linter config, install golangci-lint if needed and call `devp/lint-config-verify` if `golangci-fix.yml`exists
ifeq ($(DEVP_LINT_FIX), 1)
$(Q) $(MAKE) devp/lint-config-verify
endif
.PHONY: devp/lint-go-default
devp/lint-go-default: devp/lint-deps
@# Run linter with the platform config
$(Q) GOGC=${DEVP_LINT_GOGC} ${DEVP_GOLANG_CI_LINT_CMD} ./...
.PHONY: devp/lint-go-default-report
devp/lint-go-default-report: devp/lint-deps
@# Generate linting json report for the platform linting config
$(Q) GOGC=${DEVP_LINT_GOGC} ${DEVP_GOLANG_CI_LINT_CMD} --output.json.path=devp_lint_report.json
.PHONY: devp/lint-go-default-fix
devp/lint-go-default-fix: devp/lint-deps
@# Run linter with the platform config and --fix flag
$(Q) GOGC=${DEVP_LINT_GOGC} ${DEVP_GOLANG_CI_LINT_CMD} ./... --fix
.PHONY: devp/lint-cache-clean
devp/lint-cache-clean: ${DEVP_GOLANG_CI_LINT_EXE}
@# Clean linter cache
$(Q) ${DEVP_GOLANG_CI_LINT_EXE} cache clean
.PHONY: devp/lint-cache-status
devp/lint-cache-status: ${DEVP_GOLANG_CI_LINT_EXE}
@# Show cache directory path and size
$(Q) ${DEVP_GOLANG_CI_LINT_EXE} cache status
.PHONY: .devp/lint-go-nolint-gen
.devp/lint-go-nolint-gen: ${DEVP_DEVPTOOL_EXE}
@# [For Devp team. Do not call directly.] Generate 'nolint' directives for all linting issues.
$(Q) ${DEVP_DEVPTOOL_EXE} golang lint nolint-gen

View File

@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
if [[ $# -eq 3 ]]; then
echo "Fix config doesn't exist, nothing to merge"
exit
fi
DEVP_MERGED_LINT_CONFIG=$1
DEVP_YQ_EXE=$2
DEFAULT_CONFIG=$3
FIX_CONFIG=$4
TEMP_CONFIG="${DEVP_MERGED_LINT_CONFIG}.tmp"
${DEVP_YQ_EXE} eval-all 'select(fileIndex == 0) *+ select(fileIndex == 1)' "${DEFAULT_CONFIG}" "${FIX_CONFIG}" > "${TEMP_CONFIG}"
(echo "# Generated and used by devp/lint-go-default. Can be safely added to .gitignore" ; cat "${TEMP_CONFIG}") > "${DEVP_MERGED_LINT_CONFIG}"
rm "${TEMP_CONFIG}"
echo "File '${FIX_CONFIG}' merged into final config '${DEVP_MERGED_LINT_CONFIG}'"

View File

@ -0,0 +1,57 @@
#!/bin/bash
set -euo pipefail
MAKE=$1 # make tool
MAKEFILE=$2 # root makefile
ROOT_TARGETS_ONLY=${3:-false} # print root Makefile targets only
# Get number of available colors
COLORS_NUM=$(tput colors)
# Then check if it's a terminal and we have enough colors
if [ -t 1 ] && [ -n "$COLORS_NUM" ] && [ "$COLORS_NUM" -ge 4 ]; then
RESET="$(tput sgr0)"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
else
RESET=
RED=
GREEN=
fi
# See https://stackoverflow.com/a/26339924 for different approaches.
# Here ":" is a non-existing target, -q doesn't run anything.
MAKE_DB=$(LC_ALL=C $MAKE \
--print-data-base \
--no-builtin-rules \
--no-builtin-variables \
-q \
--makefile="$MAKEFILE" \
: 2>/dev/null || true)
echo "Detailed platform usage description: ${BLUE}https://git.mws-team.ru/mws/devp/platform-go/-/blob/master/README.md${RESET}"
echo "${RED}Makefile targets:${RESET}"
# -v RS= splits MAKE_DB into "paragraphs" separated with "\n\n+"
# -F: splits into ":"-separated fields, we use only the first field $1
# -v FILTER="$ROOT_TARGETS_ONLY" if 'true' - filters out just root Makefile targets
# /^[A-Za-z]/ filters out "# Not a target:" and internal targets like .DEFAULT
# match+substr extracts help string which is a command that is a comment - "@# ...".
# (Because MAKE_DB doesn't preserve Makefile comments)
echo "$MAKE_DB" | awk \
-v RS= \
-F: \
-v GREEN=$GREEN -v RESET=$RESET \
-v FILTER="$ROOT_TARGETS_ONLY" \
'/^[A-Za-z]/ {
if (FILTER == "true" && $0 !~ /from `Makefile/) next;
match($0, /@#[^\n]*/);
HELP_STR=substr($0, RSTART+1, RLENGTH-1);
printf("%s:%s%s%s\n", $1, GREEN, HELP_STR, RESET);
}' | sort | column -s ':' -t

View File

@ -0,0 +1,41 @@
DEVP_ROOT := $(if $(DEVP_ROOT),$(DEVP_ROOT),${HOME}/.devp)
DEVP_TOOLS_ROOT := ${DEVP_ROOT}/tools
PWD_PATH = $(shell pwd)
BIN_PATH := $(if $(BIN_PATH),$(BIN_PATH),${PWD_PATH}/bin)
DEVP_BIN_PATH := ${BIN_PATH}/devp
DEVP_BIN_PATH_FOLDER := ${DEVP_BIN_PATH}/.check
${DEVP_BIN_PATH_FOLDER}:
$(Q) mkdir -p ${DEVP_BIN_PATH}
$(Q) touch $@
DEVP_BUILD ?= .devp
DEVP_SCRIPTS_ROOT := $(if $(DEVP_SCRIPTS_ROOT),$(DEVP_SCRIPTS_ROOT),.)
DEVP_SCRIPTS := $(if $(DEVP_SCRIPTS),$(DEVP_SCRIPTS),${DEVP_SCRIPTS_ROOT}/scripts/devp)
include ${DEVP_SCRIPTS}/print.mk
# Print adds $(Q) and colors, include other scripts after it.
include ${DEVP_SCRIPTS}/version.mk
include ${DEVP_SCRIPTS}/help.mk
include ${DEVP_SCRIPTS}/build.mk
include ${DEVP_SCRIPTS}/install.mk
include ${DEVP_SCRIPTS}/lint/lint.mk
include ${DEVP_SCRIPTS}/format.mk
include ${DEVP_SCRIPTS}/test/test.mk
include ${DEVP_SCRIPTS}/generate.mk
include ${DEVP_SCRIPTS}/update.mk
include ${DEVP_SCRIPTS}/check.mk
include ${DEVP_SCRIPTS}/protoc.mk
include ${DEVP_SCRIPTS}/gomod.mk
include ${DEVP_SCRIPTS}/godeviz.mk
include ${DEVP_SCRIPTS}/releaser.mk
include ${DEVP_SCRIPTS}/changes.mk
.PHONY: devp/version
devp/version:
@# Print devp version
@echo "v${DEVP_VERSION}"

View File

@ -0,0 +1,27 @@
ifeq ($(VERBOSE),1)
Q =
VERBOSE_FLAG = --verbose
else
Q = @
VERBOSE_FLAG =
endif
ifneq (,$(findstring xterm,${TERM}))
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
BLUE := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
else
RED := ""
GREEN := ""
RESET := ""
BLUE := ""
endif
define green
@echo "${GREEN}$(1)${RESET}"
endef
define error_message
@echo "error: ${RED}$(1)${RESET}"
endef

View File

@ -0,0 +1,7 @@
.PHONY: devp/install/protoc-gen-go-dep
devp/install/protoc-gen-go-dep: ${DEVP_PROTOC_EXE} ${DEVP_PROTOC_GEN_GO_EXE}
@# Install all protoc-gen-go dependencies
.PHONY: devp/install/protoc-gen-go-grpc-dep
devp/install/protoc-gen-go-grpc-dep: ${DEVP_PROTOC_EXE} ${DEVP_PROTOC_GEN_GO_EXE} ${DEVP_PROTOC_GEN_GO_GRPC_EXE}
@# Install all protoc-gen-go-grpc dependencies

View File

@ -0,0 +1,25 @@
.PHONY: devp/releaser/init
devp/releaser/init: ${DEVP_DEVPTOOL_EXE}
@# Initialize configs for binreleaser
$(Q) ${DEVP_DEVPTOOL_EXE} golang release init
.PHONY: devp/releaser/publish
devp/releaser/publish: ${DEVP_DEVPTOOL_EXE}
@# Build and publishes release artifacts
$(Q) ${DEVP_DEVPTOOL_EXE} golang release publish --dry-run=false --is-latest=false
.PHONY: devp/releaser/publish/latest
devp/releaser/publish/latest: ${DEVP_DEVPTOOL_EXE}
@# Build and publishes release artifacts
$(Q) ${DEVP_DEVPTOOL_EXE} golang release publish --dry-run=false --is-latest=true
.PHONY: devp/releaser/publish/dry-run
devp/releaser/publish/dry-run: ${DEVP_DEVPTOOL_EXE}
@# Validation only, nothing is built and published
$(Q) ${DEVP_DEVPTOOL_EXE} golang release publish --dry-run=true --is-latest=false
.PHONY: devp/releaser/build
devp/releaser/build: ${DEVP_DEVPTOOL_EXE}
@# Build only. Skip publish and release artifacts
$(Q) ${DEVP_DEVPTOOL_EXE} golang release build

View File

@ -0,0 +1,27 @@
.PHONY: devp/test-go
devp/test-go:
@# Test all
$(Q) go test -race ./...
.PHONY: devp/coverage/deps
devp/coverage/deps: ${DEVP_DEVPTOOL_EXE} ${DEVP_GOTESTSUM_EXE} ${DEVP_GOCOVER_COBERTURA_EXE}
@# helper target for coverage reports
DEVP_COVERAGE_CMD := ${DEVP_DEVPTOOL_EXE} golang coverage --gotestsum-exe=${DEVP_GOTESTSUM_EXE} --gocover-cobertura-exe=${DEVP_GOCOVER_COBERTURA_EXE} --default-junit-path=${DEVP_JUNIT} --default-cobertura-path=${DEVP_COBERTURA} --devp-build-path=${DEVP_BUILD}/coverage
.PHONY: devp/coverage
devp/coverage: devp/coverage/deps
@# Test all with coverage reports
$(Q) ${DEVP_COVERAGE_CMD} --detailed=false
$(Q) echo "For more detailed report run 'make devp/coverage/detailed' or look at test reports in artifacts"
.PHONY: devp/coverage/detailed
devp/coverage/detailed: devp/coverage/deps
@# Test all with detailed coverage reports
$(Q) ${DEVP_COVERAGE_CMD}
# To be used for golden tests
.PHONY: devp/test-go/update
devp/test-go/update:
@# Update golden files
$(Q) go list -f '{{.XTestImports}}{{.TestImports}}{{.Dir}}' ./... | grep 'git.mws-team.ru/mws/devp/platform-go/pkg/golden' | awk -F ']' '{print $$3}' | xargs -I {} go test {} -update

View File

@ -0,0 +1,4 @@
.PHONY: devp/update
devp/update: ${DEVP_BIN_PATH_FOLDER}
@# Update platform
$(Q) DEVP_VERSION=${DEVP_VERSION} DEVP_BIN_PATH=${DEVP_BIN_PATH} ${DEVP_SCRIPTS}/update.sh

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail
echo "Checking for a newer version"
mkdir -p ${DEVP_BIN_PATH}
git archive --remote git@git.mws-team.ru:mws/devp/platform-go-tools.git HEAD latest.txt -o ${DEVP_BIN_PATH}/latest.tar
$(cd ${DEVP_BIN_PATH} && tar xf latest.tar && rm latest.tar)
VERSION=$(cat ${DEVP_BIN_PATH}/latest.txt | xargs)
rm ${DEVP_BIN_PATH}/latest.txt
if [[ "$DEVP_VERSION" == "$VERSION" ]]; then
echo "Up to date $VERSION"
exit 0
fi
GOBIN=${DEVP_BIN_PATH} go install git.mws-team.ru/mws/devp/platform-go-tools/cmd/devp@v${VERSION}
EXE=${DEVP_BIN_PATH}/devp-$(echo ${VERSION} | tr . -)
mv ${DEVP_BIN_PATH}/devp ${EXE}
${EXE} golang install --skip-defaults

View File

@ -0,0 +1 @@
DEVP_VERSION = 0.75.0