From b9b88cd6543e747e7ec0587eee8df8d08d39ac69 Mon Sep 17 00:00:00 2001 From: sbp-bvanb Date: Mon, 28 Oct 2024 08:25:58 +0100 Subject: [PATCH] fix: [#100] Prevent code duplication by using a Taskfile --- Taskfile.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Taskfile.yml diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..c9fbae6 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,53 @@ +--- +version: "3" + +vars: + GCI_VERSION: 0.13.5 + GOLANGCI_LINT_VERSION: 1.61.0 + +tasks: + gci: + silent: true + cmds: + - | + if ! ~/go/bin/gci --version | grep "gci version {{.GCI_VERSION}}"; then + go install github.com/daixiang0/gci@v{{.GCI_VERSION}} + fi + #~/go/bin/gci write --skip-generated -s standard -s default . + if ~/go/bin/gci list --skip-generated . | grep "\.go$"; then + echo "One or more golang files detected with: 'incorrect import order':" + echo " * Observe: '~/go/bin/gci diff --skip-generated .'" + echo " * Resolve: '~/go/bin/gci write --skip-generated .'" + exit 1 + fi + golangci-lint-install: + silent: true + cmds: + - | + if ! golangci-lint --version | grep "has version {{.GOLANGCI_LINT_VERSION}}"; then + curl \ + -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |\ + sh -s -- -b $(go env GOPATH)/bin v{{.GOLANGCI_LINT_VERSION}} + fi + golangci-lint-run: + silent: true + cmds: + - | + golangci-lint run \ + -v + golangci-lint: + silent: true + cmds: + - task: golangci-lint-install + - task: golangci-lint-run + golangci-lint-without-cache: + silent: true + cmds: + - task: golangci-lint-install + - golangci-lint cache clean + - task: golangci-lint-run + lint: + silent: true + deps: + - task: gci + - task: golangci-lint