Skip to content

Commit

Permalink
ci: Try to fix ct lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Aug 7, 2023
1 parent f0046da commit 3b8ccd6
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 38 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 18 additions & 23 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
{
"packages": [
"actionlint@latest",
"chart-testing@latest",
"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"
]
}
30 changes: 30 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 15 additions & 1 deletion make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)|.|")
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 3b8ccd6

Please sign in to comment.