diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a29ad0e6f..e359372a8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,6 +13,11 @@ updates: schedule: interval: "weekly" + - package-ecosystem: "npm" + directory: "/docs" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.go-tools b/.go-tools deleted file mode 100644 index 3c4cc0df0..000000000 --- a/.go-tools +++ /dev/null @@ -1,2 +0,0 @@ -github.com/oligot/go-mod-upgrade@v0.9.1 -sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20230817155522-304027bcbe4b diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61ee4dfbd..586bd3306 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: - id: actionlint-system stages: [commit] - repo: https://github.com/hadolint/hadolint - rev: v2.12.0 + rev: v2.12.1-beta hooks: - id: hadolint - repo: https://github.com/jorisroovers/gitlint @@ -73,19 +73,19 @@ repos: - id: script-must-have-extension stages: [commit] - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.2 + rev: v0.9.0.5 hooks: - id: shellcheck stages: [commit] args: ["-e", "SC2211", "-x"] - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.34.0 + rev: v0.36.0 hooks: - id: markdownlint stages: [commit] exclude: ^(CHANGELOG.md|charts/.+/README.md)$ - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.1 + rev: v1.5.4 hooks: - id: insert-license name: License headers - Go @@ -118,7 +118,7 @@ repos: - - --use-current-year - repo: https://github.com/norwoodj/helm-docs - rev: v1.11.0 + rev: v1.11.1 hooks: - id: helm-docs stages: [commit] diff --git a/Dockerfile b/Dockerfile index 11c4758a9..7a7ca1d5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ # hadolint ignore=DL3029 FROM --platform=linux/amd64 gcr.io/distroless/static@sha256:1b4dbd7d38a0fd4bbaf5216a21a615d07b56747a96d3c650689cbb7fdc412b49 as linux-amd64 # hadolint ignore=DL3029 -FROM --platform=linux/arm64 gcr.io/distroless/static@sha256:05810557ec4b4bf01f4df548c06cc915bb29d81cb339495fe1ad2e668434bf8e as linux-arm64 +FROM --platform=linux/arm64 gcr.io/distroless/static@sha256:dcf9c9cafaa9c328eff2ceff5f6057588336b48c9b91ddc0913102b33bbce723 as linux-arm64 # hadolint ignore=DL3006,DL3029 FROM --platform=linux/${TARGETARCH} linux-${TARGETARCH} diff --git a/devbox.json b/devbox.json index 98651e26f..8306ba97e 100644 --- a/devbox.json +++ b/devbox.json @@ -13,6 +13,7 @@ "gnumake@latest", "gnused@latest", "go@latest", + "path:./hack/flakes/go-mod-upgrade", "gojq@latest", "path:./hack/flakes/golangci-lint", "golines@latest", @@ -28,6 +29,7 @@ "kubernetes-helm@latest", "kustomize@latest", "pre-commit@latest", + "path:./hack/flakes/setup-envtest", "shfmt@latest", "upx@latest", "yamale@latest", diff --git a/devbox.lock b/devbox.lock index 0fe880ba5..9ffba902b 100644 --- a/devbox.lock +++ b/devbox.lock @@ -44,10 +44,10 @@ "version": "2.1.0" }, "ginkgo@latest": { - "last_modified": "2023-06-30T04:44:22Z", - "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#ginkgo", + "last_modified": "2023-09-04T16:24:30Z", + "resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#ginkgo", "source": "devbox-search", - "version": "2.11.0" + "version": "2.12.0" }, "git@latest": { "last_modified": "2023-07-23T03:35:12Z", @@ -98,10 +98,10 @@ "version": "433.0.1" }, "goreleaser@latest": { - "last_modified": "2023-07-23T03:35:12Z", - "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#goreleaser", + "last_modified": "2023-09-04T16:24:30Z", + "resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#goreleaser", "source": "devbox-search", - "version": "1.19.2" + "version": "1.20.0" }, "gotestsum@latest": { "last_modified": "2023-07-23T03:35:12Z", @@ -140,16 +140,16 @@ "version": "3.11.1" }, "kubectl@latest": { - "last_modified": "2023-08-08T03:07:33Z", - "resolved": "github:NixOS/nixpkgs/844ffa82bbe2a2779c86ab3a72ff1b4176cec467#kubectl", + "last_modified": "2023-09-04T16:24:30Z", + "resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#kubectl", "source": "devbox-search", - "version": "1.27.4" + "version": "1.28.1" }, "kubernetes-controller-tools@latest": { - "last_modified": "2023-07-23T03:35:12Z", - "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#kubernetes-controller-tools", + "last_modified": "2023-09-04T16:24:30Z", + "resolved": "github:NixOS/nixpkgs/3c15feef7770eb5500a4b8792623e2d6f598c9c1#kubernetes-controller-tools", "source": "devbox-search", - "version": "0.12.1" + "version": "0.13.0" }, "kubernetes-helm@latest": { "last_modified": "2023-07-23T03:35:12Z", @@ -163,6 +163,9 @@ "source": "devbox-search", "version": "5.1.1" }, + "path:./hack/flakes/go-mod-upgrade": {}, + "path:./hack/flakes/golangci-lint": {}, + "path:./hack/flakes/setup-envtest": {}, "pre-commit@latest": { "last_modified": "2023-06-30T04:44:22Z", "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#pre-commit", diff --git a/docs/package-lock.json b/docs/package-lock.json index f40453d78..fb2f6d0d5 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -172,9 +172,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001522", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001522.tgz", - "integrity": "sha512-TKiyTVZxJGhsTszLuzb+6vUZSjVOAhClszBr2Ta2k9IwtNBT/4dzmL6aywt0HCgEZlmwJzXJd8yNiob6HgwTRg==", + "version": "1.0.30001527", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001527.tgz", + "integrity": "sha512-YkJi7RwPgWtXVSgK4lG9AHH57nSzvvOp9MesgXmw4Q7n0C3H04L0foHqfxcmSAm5AcWb8dW9AYj2tR7/5GnddQ==", "dev": true, "funding": [ { @@ -272,9 +272,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.496", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.496.tgz", - "integrity": "sha512-qeXC3Zbykq44RCrBa4kr8v/dWzYJA8rAwpyh9Qd+NKWoJfjG5vvJqy9XOJ9H4P/lqulZBCgUWAYi+FeK5AuJ8g==", + "version": "1.4.508", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.508.tgz", + "integrity": "sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==", "dev": true }, "node_modules/emoji-regex": { @@ -330,16 +330,16 @@ } }, "node_modules/fraction.js": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.1.tgz", - "integrity": "sha512-/KxoyCnPM0GwYI4NN0Iag38Tqt+od3/mLuguepLgCAKPn0ZhC544nssAW0tG2/00zXEYl9W+7hwAIpLHo6Oc7Q==", + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.6.tgz", + "integrity": "sha512-n2aZ9tNfYDwaHhvFTkhFErqOMIb8uyzSQ+vGJBjZyanAKZVbGUQ1sngfk9FdkBw7G26O7AgNjLcecLffD1c7eg==", "dev": true, "engines": { "node": "*" }, "funding": { "type": "patreon", - "url": "https://www.patreon.com/infusion" + "url": "https://github.com/sponsors/rawify" } }, "node_modules/fs-extra": { @@ -623,9 +623,9 @@ } }, "node_modules/postcss": { - "version": "8.4.28", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.28.tgz", - "integrity": "sha512-Z7V5j0cq8oEKyejIKfpD8b4eBy9cwW2JWPk0+fB1HOAMsfHbnAXLLS+PfVWlzMSLQaWttKDt607I0XHmpE67Vw==", + "version": "8.4.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", + "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", "dev": true, "funding": [ { @@ -959,9 +959,9 @@ } }, "node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", "dev": true, "engines": { "node": ">= 14" diff --git a/hack/flakes/go-mod-upgrade/flake.lock b/hack/flakes/go-mod-upgrade/flake.lock new file mode 100644 index 000000000..6a4693ca2 --- /dev/null +++ b/hack/flakes/go-mod-upgrade/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1693663421, + "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e56990880811a451abd32515698c712788be5720", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "v1.0.0", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/hack/flakes/go-mod-upgrade/flake.nix b/hack/flakes/go-mod-upgrade/flake.nix new file mode 100644 index 000000000..9aaf768c8 --- /dev/null +++ b/hack/flakes/go-mod-upgrade/flake.nix @@ -0,0 +1,64 @@ +# Copyright 2023 D2iQ, Inc. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +{ + description = "Update outdated Go dependencies interactively"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils/v1.0.0"; + }; + + outputs = + { self + , nixpkgs + , utils + , + }: + let + appReleaseVersion = "0.9.1"; + appReleaseBinaries = { + "x86_64-linux" = { + fileName = "go-mod-upgrade_${appReleaseVersion}_Linux_x86_64.tar.gz"; + sha256 = "38b7f36b275fa08bedf0e4c7fb1eaf256fa632a7489abe7c40a1d2b87a688b01"; + }; + "x86_64-darwin" = { + fileName = "go-mod-upgrade_${appReleaseVersion}_Darwin_x86_64.tar.gz"; + sha256 = "e1e0294040cfadde0f119590f37fbff73654abc482ac60c1e3ca60b867326713"; + }; + "aarch64-darwin" = { + fileName = "go-mod-upgrade_${appReleaseVersion}_Darwin_arm64.tar.gz"; + sha256 = "15027f435a85f31346fd0796977180c43c737b7fe7bbb4fc3bcc5f4b8f32804c"; + }; + }; + supportedSystems = builtins.attrNames appReleaseBinaries; + in + utils.lib.eachSystem supportedSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + appReleaseBinary = appReleaseBinaries.${system}; + in + rec { + packages.go-mod-upgrade = pkgs.stdenv.mkDerivation { + pname = "go-mod-upgrade"; + version = appReleaseVersion; + + src = pkgs.fetchurl { + url = "https://github.com/oligot/go-mod-upgrade/releases/download/v${appReleaseVersion}/${appReleaseBinary.fileName}"; + sha256 = appReleaseBinary.sha256; + }; + + sourceRoot = "."; + + installPhase = '' + install -m755 -D go-mod-upgrade $out/bin/go-mod-upgrade + ''; + }; + packages.default = packages.go-mod-upgrade; + + apps.go-mod-upgrade = utils.lib.mkApp { + drv = packages.go-mod-upgrade; + }; + apps.default = apps.go-mod-upgrade; + }); +} diff --git a/hack/flakes/golangci-lint/flake.lock b/hack/flakes/golangci-lint/flake.lock index c84edbd79..6a4693ca2 100644 --- a/hack/flakes/golangci-lint/flake.lock +++ b/hack/flakes/golangci-lint/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1693158576, - "narHash": "sha256-aRTTXkYvhXosGx535iAFUaoFboUrZSYb1Ooih/auGp0=", + "lastModified": 1693663421, + "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a999c1cc0c9eb2095729d5aa03e0d8f7ed256780", + "rev": "e56990880811a451abd32515698c712788be5720", "type": "github" }, "original": { diff --git a/hack/flakes/golangci-lint/flake.nix b/hack/flakes/golangci-lint/flake.nix index f08c3d349..ef3c28a82 100644 --- a/hack/flakes/golangci-lint/flake.nix +++ b/hack/flakes/golangci-lint/flake.nix @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 { - description = "Fast linters Runner for Go "; + description = "Fast linters Runner for Go"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -16,36 +16,36 @@ , }: let - golangciLintVersion = "1.54.2"; - golangciLintBinaries = { + appReleaseVersion = "1.54.2"; + appReleaseBinaries = { "x86_64-linux" = { - fileName = "golangci-lint-${golangciLintVersion}-linux-amd64.tar.gz"; + fileName = "golangci-lint-${appReleaseVersion}-linux-amd64.tar.gz"; sha256 = "17c9ca05253efe833d47f38caf670aad2202b5e6515879a99873fabd4c7452b3"; }; "x86_64-darwin" = { - fileName = "golangci-lint-${golangciLintVersion}-darwin-amd64.tar.gz"; + fileName = "golangci-lint-${appReleaseVersion}-darwin-amd64.tar.gz"; sha256 = "925c4097eae9e035b0b052a66d0a149f861e2ab611a4e677c7ffd2d4e05b9b89"; }; "aarch64-darwin" = { - fileName = "golangci-lint-${golangciLintVersion}-darwin-arm64.tar.gz"; + fileName = "golangci-lint-${appReleaseVersion}-darwin-arm64.tar.gz"; sha256 = "7b33fb1be2f26b7e3d1f3c10ce9b2b5ce6d13bb1d8468a4b2ba794f05b4445e1"; }; }; - supportedSystems = builtins.attrNames golangciLintBinaries; + supportedSystems = builtins.attrNames appReleaseBinaries; in utils.lib.eachSystem supportedSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; - golangciLintBinary = golangciLintBinaries.${system}; + appReleaseBinary = appReleaseBinaries.${system}; in rec { packages.golangci-lint = pkgs.stdenv.mkDerivation { pname = "golangci-lint"; - version = golangciLintVersion; + version = appReleaseVersion; src = pkgs.fetchurl { - url = "https://github.com/golangci/golangci-lint/releases/download/v${golangciLintVersion}/${golangciLintBinary.fileName}"; - sha256 = golangciLintBinary.sha256; + url = "https://github.com/golangci/golangci-lint/releases/download/v${appReleaseVersion}/${appReleaseBinary.fileName}"; + sha256 = appReleaseBinary.sha256; }; sourceRoot = "."; diff --git a/hack/flakes/setup-envtest/flake.lock b/hack/flakes/setup-envtest/flake.lock new file mode 100644 index 000000000..310beed96 --- /dev/null +++ b/hack/flakes/setup-envtest/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1693663421, + "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e56990880811a451abd32515698c712788be5720", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/hack/flakes/setup-envtest/flake.nix b/hack/flakes/setup-envtest/flake.nix new file mode 100644 index 000000000..85e3f6f6e --- /dev/null +++ b/hack/flakes/setup-envtest/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Manage binaries for envtest"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils }: + utils.lib.eachSystem [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = "0.16.1"; + in + { + packages = { + default = pkgs.buildGoModule { + pname = "setup-envtest"; + + inherit version; + + src = pkgs.fetchFromGitHub { + owner = "kubernetes-sigs"; + repo = "controller-runtime"; + rev = "v${version}"; + # When changing the version, if there is a problem with the hashes, uncomment the following line + # and re-run the install, then update with the correct hash as output in the error message.. + # hash = pkgs.lib.fakeSha256 + hash = "sha256-qwehmICfsVfrhnta1x3IrXTGfsvW/crx1bHuo1wdyJM="; + }+"/tools/setup-envtest"; + + # When changing the version, if there is a problem with the hashes, uncomment the following line + # and re-run the install, then update with the correct hash as output in the error message.. + # vendorHash = pkgs.lib.fakeSha256 + vendorHash = "sha256-ISVGxhFQh4e0eag9Sw0Zj4u1cG0tudZLhJcGdH5tDo4="; + + CGO_ENABLED = 0; + + ldflags = [ + "-s" + "-w" + ]; + }; + }; + }); +} diff --git a/make/all.mk b/make/all.mk index 0ac481bca..042bcdcc9 100644 --- a/make/all.mk +++ b/make/all.mk @@ -7,7 +7,6 @@ include $(INCLUDE_DIR)make.mk include $(INCLUDE_DIR)shell.mk include $(INCLUDE_DIR)help.mk include $(INCLUDE_DIR)repo.mk -include $(INCLUDE_DIR)tools.mk include $(INCLUDE_DIR)pre-commit.mk include $(INCLUDE_DIR)go.mk include $(INCLUDE_DIR)goreleaser.mk diff --git a/make/go.mk b/make/go.mk index 774d36327..7cfc11eb9 100644 --- a/make/go.mk +++ b/make/go.mk @@ -46,7 +46,7 @@ endif .PHONY: test.% test.%: ## Runs go tests for a specific module -test.%: install-tool.go.setup-envtest ; $(info $(M) running tests$(if $(GOTEST_RUN), matching "$(GOTEST_RUN)") for $* module) +test.%: ; $(info $(M) running tests$(if $(GOTEST_RUN), matching "$(GOTEST_RUN)") for $* module) $(if $(filter-out root,$*),cd $* && )$(call go_test) .PHONY: integration-test @@ -186,5 +186,5 @@ go-generate: ; $(info $(M) running go generate) .PHONY: go-mod-upgrade go-mod-upgrade: ## Interactive check for direct module dependency upgrades -go-mod-upgrade: install-tool.go.go-mod-upgrade; $(info $(M) checking for direct module dependency upgrades) +go-mod-upgrade: ; $(info $(M) checking for direct module dependency upgrades) go-mod-upgrade diff --git a/make/tools.mk b/make/tools.mk deleted file mode 100644 index 4e80a9ee7..000000000 --- a/make/tools.mk +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2023 D2iQ, Inc. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Override this in your own top-level Makefile if this is in a different path in your repo. -GO_TOOLS_FILE ?= $(REPO_ROOT)/.go-tools - -# Explicitly override GOBIN so it does not inherit from the environment - this allows for a truly -# self-contained build environment for the project. -override GOBIN := $(REPO_ROOT)/.local/bin -export GOBIN -export PATH := $(GOBIN):$(PATH) - -ifneq ($(wildcard $(GO_TOOLS_FILE)),) -define install_go_tool - mkdir -p $(GOBIN) - CGO_ENABLED=0 go install -v $$(grep -Eo '^.+$1[^ ]+' $(GO_TOOLS_FILE)) -endef - -.PHONY: -install-tool.go.%: ## Installs go tools -install-tool.go.%: ; $(info $(M) installing go tool $*) - $(call install_go_tool,$*) -endif - -.PHONY: install-tools -install-tools: ## Install all tools -install-tools: ; $(info $(M) installing all tools) -ifneq ($(wildcard $(GO_TOOLS_FILE)),) - cat $(GO_TOOLS_FILE) | xargs -L1 go install -v -endif - -.PHONY: upgrade-tools -upgrade-tools: ## Upgrades all tools to latest available versions -upgrade-tools:; $(info $(M) upgrading all tools to latest available versions) - devbox update - $(MAKE) upgrade-go-tools - -.PHONY: upgrade-go-tools -upgrade-go-tools: ## Upgrades all go tools to latest available versions -upgrade-go-tools: ; $(info $(M) upgrading all go tools to latest available versions) - grep -v '# FREEZE' .go-tools | \ - grep -Eo '^[^#][^@]+' | \ - xargs -I {} bash -ec ' \ - original_module_path={}; \ - module_path={}; \ - while [ "$${module_path}" != "." ]; do \ - LATEST_VERSION=$$(go list -m $${module_path}@latest 2>/dev/null || echo ""); \ - if [ -n "$${LATEST_VERSION}" ]; then \ - sed -i "s|$${original_module_path}@.\+$$|$${original_module_path}@$${LATEST_VERSION#* }|" .go-tools; \ - exit; \ - else \ - module_path=$$(dirname $${module_path}); \ - fi; \ - done; \ - echo "Failed to find latest module version for $${original_module_path}"; \ - exit 1'