diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8e9a485b0..fc24a1b01 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -152,57 +152,74 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Install devbox uses: jetpack-io/devbox-install-action@v0.5.0 with: enable-cache: true - - if: github.ref != 'refs/heads/main' - name: Fetch main if necessary - run: git fetch origin main:main - - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(devbox run -- ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + changed="$(devbox run -- \ + ct list-changed --config charts/ct-config.yaml \ + )" if [[ -n "$changed" ]]; then echo "changed=true" >> "$GITHUB_OUTPUT" fi - if: steps.list-changed.outputs.changed == 'true' name: Run chart-testing (lint) - run: devbox run -- ct lint --config charts/ct-config.yaml + run: | + devbox run -- \ + ct lint --config charts/ct-config.yaml - if: steps.list-changed.outputs.changed == 'true' name: Create kind cluster run: | - devbox run -- kind create cluster \ - --image=ghcr.io/mesosphere/kind-node:"$(kubectl version --output=json --client | gojq --raw-output .clientVersion.gitVersion)" \ - --name=chart-testing + devbox run -- \ + kind create cluster \ + --image=ghcr.io/mesosphere/kind-node:"$(devbox run -- kubectl version --output=json --client | devbox run -- gojq --raw-output .clientVersion.gitVersion)" \ + --name=chart-testing env: KUBECONFIG: ct-kind-kubeconfig - if: steps.list-changed.outputs.changed == 'true' name: Build Docker images - run: devbox run -- make release-snapshot + run: | + devbox run -- \ + make release-snapshot - if: steps.list-changed.outputs.changed == 'true' name: Sideload docker image - run: devbox run -- kind load docker-image --name chart-testing "$(jq -r '.[] | select(.type == "Docker Image" and .goos == "linux" and .goarch == "amd64").name' dist/artifacts.json)" + run: | + devbox run -- \ + kind load docker-image \ + --name chart-testing \ + "$(devbox run -- gojq -r '.[] | select(.type == "Docker Image" and .goos == "linux" and .goarch == "amd64").name' dist/artifacts.json)" - if: steps.list-changed.outputs.changed == 'true' name: Setup Cluster API and cert-manager - run: devbox run -- make clusterctl.init + run: | + devbox run -- \ + make clusterctl.init env: KIND_KUBECONFIG: ct-kind-kubeconfig - if: steps.list-changed.outputs.changed == 'true' name: Run chart-testing (install) - run: devbox run -- ct install --config charts/ct-config.yaml --helm-extra-set-args "--set=image.tag=$(jq -r .version dist/metadata.json)" + run: | + devbox run -- \ + ct install \ + --config charts/ct-config.yaml \ + --helm-extra-set-args "--set=image.tag=$(devbox run -- jq -r .version dist/metadata.json)" env: KUBECONFIG: ct-kind-kubeconfig - if: steps.list-changed.outputs.changed == 'true' && always() name: - run: devbox run -- kind delete cluster --name chart-testing || true + run: | + devbox run -- \ + kind delete cluster --name chart-testing || true diff --git a/devbox.json b/devbox.json index 9b3b9cc1e..cf675c6e7 100644 --- a/devbox.json +++ b/devbox.json @@ -1,41 +1,36 @@ { "packages": [ + "actionlint@latest", + "chart-testing@3.8.0", "clusterctl@latest", + "crane@latest", + "envsubst@latest", + "findutils@latest", "fluxcd@latest", "ginkgo@latest", + "git@latest", "github-cli@latest", - "gojq@latest", + "gnumake@latest", + "gnused@latest", "go@latest", + "gojq@latest", "golangci-lint@latest", + "golines@latest", + "google-cloud-sdk@latest", "goreleaser@latest", - "kubernetes-helm@latest", + "gotestsum@latest", + "hadolint@latest", "helm-docs@latest", "kind@latest", "kubebuilder@latest", "kubectl@latest", + "kubernetes-controller-tools@latest", + "kubernetes-helm@latest", "kustomize@latest", "pre-commit@latest", "shfmt@latest", "upx@latest", - "yamllint@latest", - "chart-testing@latest", - "google-cloud-sdk@latest", - "crane@latest", - "gotestsum@latest", - "golines@latest", - "envsubst@latest", - "kubernetes-controller-tools@latest", - "actionlint@latest", - "hadolint@latest" - ], - "shell": { - "init_hook": [ - "echo 'Welcome to devbox!' > /dev/null" - ], - "scripts": { - "test": [ - "echo \"Error: no test specified\" && exit 1" - ] - } - } + "yamale@latest", + "yamllint@latest" + ] } diff --git a/devbox.lock b/devbox.lock index e764f137e..d9076901d 100644 --- a/devbox.lock +++ b/devbox.lock @@ -7,11 +7,11 @@ "source": "devbox-search", "version": "1.6.25" }, - "chart-testing@latest": { - "last_modified": "2023-07-23T03:35:12Z", - "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#chart-testing", + "chart-testing@3.8.0": { + "last_modified": "2023-06-30T04:44:22Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#chart-testing", "source": "devbox-search", - "version": "3.9.0" + "version": "3.8.0" }, "clusterctl@latest": { "last_modified": "2023-07-23T03:35:12Z", @@ -31,6 +31,12 @@ "source": "devbox-search", "version": "1.4.2" }, + "findutils@latest": { + "last_modified": "2023-07-23T03:35:12Z", + "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#findutils", + "source": "devbox-search", + "version": "4.9.0" + }, "fluxcd@latest": { "last_modified": "2023-07-23T03:35:12Z", "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#fluxcd", @@ -43,12 +49,30 @@ "source": "devbox-search", "version": "2.11.0" }, + "git@latest": { + "last_modified": "2023-07-23T03:35:12Z", + "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#git", + "source": "devbox-search", + "version": "2.41.0" + }, "github-cli@latest": { "last_modified": "2023-05-14T19:13:12Z", "resolved": "github:NixOS/nixpkgs/3007746b3f5bfcb49e102b517bca891822a41b31#github-cli", "source": "devbox-search", "version": "2.29.0" }, + "gnumake@latest": { + "last_modified": "2023-07-23T03:35:12Z", + "resolved": "github:NixOS/nixpkgs/af8cd5ded7735ca1df1a1174864daab75feeb64a#gnumake", + "source": "devbox-search", + "version": "4.4.1" + }, + "gnused@latest": { + "last_modified": "2023-06-30T04:44:22Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#gnused", + "source": "devbox-search", + "version": "4.9" + }, "go@latest": { "last_modified": "2023-07-30T12:29:02Z", "resolved": "github:NixOS/nixpkgs/3acb5c4264c490e7714d503c7166a3fde0c51324#go", @@ -157,6 +181,12 @@ "source": "devbox-search", "version": "4.0.2" }, + "yamale@latest": { + "last_modified": "2023-06-30T04:44:22Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#yamale", + "source": "devbox-search", + "version": "4.0.4" + }, "yamllint@latest": { "last_modified": "2023-06-30T04:44:22Z", "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#yamllint", diff --git a/go.mod b/go.mod index baffcd48c..6dd6a884d 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( k8s.io/component-base v0.27.4 k8s.io/klog/v2 v2.100.1 sigs.k8s.io/cluster-api v1.5.0 - sigs.k8s.io/controller-runtime v0.15.0 + sigs.k8s.io/controller-runtime v0.15.1 ) require ( diff --git a/go.sum b/go.sum index 6252f7b6d..e98de1bee 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPB k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/cluster-api v1.5.0 h1:pwXvzScbAwnrB7EWHTApzW+VQfrj2OSrWAQDC9+bcbU= sigs.k8s.io/cluster-api v1.5.0/go.mod h1:ZSEP01t8oT6104gB4ljsOwwp5uJcI8SWy8IFp2HUvrc= -sigs.k8s.io/controller-runtime v0.15.0 h1:ML+5Adt3qZnMSYxZ7gAverBLNPSMQEibtzAgp0UPojU= -sigs.k8s.io/controller-runtime v0.15.0/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= +sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= +sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/make/go.mk b/make/go.mk index 539477ab9..8afa13815 100644 --- a/make/go.mk +++ b/make/go.mk @@ -126,7 +126,6 @@ endif .PHONY: lint.% lint.%: ## Runs golangci-lint for a specific module lint.%: ; $(info $(M) linting $* module) - $(if $(filter-out root,$*),cd $* && )go fix ./... $(if $(filter-out root,$*),cd $* && )golines -w $$(go list ./... | sed "s|^$$(go list -m)|.|") $(if $(filter-out root,$*),cd $* && )golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE) $(if $(filter-out root,$*),cd $* && )golines -w $$(go list ./... | sed "s|^$$(go list -m)|.|") @@ -160,6 +159,20 @@ go-clean.%: ## Cleans go build, test and modules caches for a specific module go-clean.%: ; $(info $(M) running go clean for $* module) $(if $(filter-out root,$*),cd $* && )go clean -r -i -cache -testcache -modcache +.PHONY: go-fix +go-fix: ## Runs go fix for all modules in repository +ifneq ($(wildcard $(REPO_ROOT)/go.mod),) +go-fix: go-fix.root +endif +ifneq ($(words $(GO_SUBMODULES_NO_TOOLS)),0) +go-fix: $(addprefix go-fix.,$(GO_SUBMODULES_NO_TOOLS:/go.mod=)) +endif + +.PHONY: go-fix.% +go-fix.%: ## Runs golangci-lint for a specific module +go-fix.%: ; $(info $(M) linting $* module) + $(if $(filter-out root,$*),cd $* && )go fix ./... + .PHONY: go-generate go-generate: ## Runs go generate go-generate: ; $(info $(M) running go generate) @@ -168,6 +181,7 @@ go-generate: ; $(info $(M) running go generate) output:crd:artifacts:config=charts/capi-runtime-extensions/crds \ output:rbac:artifacts:config=charts/capi-runtime-extensions/templates controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." + $(MAKE) go-fix .PHONY: go-mod-upgrade go-mod-upgrade: ## Interactive check for direct module dependency upgrades