Skip to content

Commit 08513d6

Browse files
authored
chore(ci): configure renovate for linters (#1169)
1 parent 5bf6276 commit 08513d6

File tree

9 files changed

+86
-674
lines changed

9 files changed

+86
-674
lines changed

.github/workflows/release-pr.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ jobs:
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v4
29-
with:
30-
fetch-depth: 0
3129

32-
- name: Setup Go
33-
uses: actions/setup-go@v5
30+
- uses: jdx/mise-action@v2
3431
with:
35-
go-version-file: third_party/go.mod
32+
install: false
3633

3734
- name: Run linters
35+
env:
36+
MISE_VERBOSE: 1
37+
MISE_DEBUG: 1
3838
run: make lint
3939

4040
lint-test:
@@ -174,6 +174,10 @@ jobs:
174174
- name: setup helm
175175
uses: azure/[email protected]
176176

177+
- uses: jdx/mise-action@v2
178+
with:
179+
install: false
180+
177181
- name: build helm chart dependency
178182
run: |
179183
helm repo add bitnami https://charts.bitnami.com/bitnami

.tools_versions.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# renovate: datasource=github-releases depName=stackrox/kube-linter
2+
kube-linter: "0.7.1"
3+
# renovate: datasource=github-releases depName=jlandowner/helm-chartsnap
4+
chartsnap: "0.3.1"
5+
# renovate: datasource=github-releases depName=koalaman/shellcheck
6+
shellcheck: "0.10.0"

Makefile

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
2-
CHARTSNAP_VERSION ?= v0.3.1
2+
TOOLS_VERSIONS_FILE = .tools_versions.yaml
33

4-
.PHONY: _download_tool
5-
_download_tool:
6-
(cd third_party && go mod tidy && \
7-
GOBIN=$(PROJECT_DIR)/bin go generate -tags=third_party ./$(TOOL).go )
4+
MISE := $(shell which mise)
5+
.PHONY: mise
6+
mise:
7+
@mise -V >/dev/null || (echo "mise - https://github.com/jdx/mise - not found. Please install it." && exit 1)
88

9-
.PHONY: tools
10-
tools: kube-linter chartsnap
9+
export MISE_DATA_DIR = $(PROJECT_DIR)/bin/
10+
11+
# NOTE: mise targets use -q to silence the output.
12+
# Users can use MISE_VERBOSE=1 MISE_DEBUG=1 to get more verbose output.
13+
14+
.PHONY: mise-plugin-install
15+
mise-plugin-install: mise
16+
@$(MISE) plugin install --yes -q $(DEP) $(URL)
17+
18+
.PHONY: mise-install
19+
mise-install: mise
20+
@$(MISE) install -q $(DEP_VER)
1121

12-
KUBE_LINTER = $(PROJECT_DIR)/bin/kube-linter
22+
KUBE_LINTER_VERSION = $(shell yq -ojson -r '.kube-linter' < $(TOOLS_VERSIONS_FILE))
23+
KUBE_LINTER = $(PROJECT_DIR)/bin/installs/kube-linter/v$(KUBE_LINTER_VERSION)/bin/kube-linter
1324
.PHONY: kube-linter
14-
kube-linter:
15-
@$(MAKE) _download_tool TOOL=kube-linter
25+
kube-linter: mise
26+
@$(MAKE) mise-plugin-install DEP=kube-linter
27+
@$(MAKE) mise-install DEP_VER=kube-linter@v$(KUBE_LINTER_VERSION)
1628

29+
CHARTSNAP_VERSION = $(shell yq -ojson -r '.chartsnap' < $(TOOLS_VERSIONS_FILE))
1730
.PHONY: chartsnap
1831
chartsnap:
19-
./scripts/install-chartsnap.sh
32+
CHARTSNAP_VERSION=${CHARTSNAP_VERSION} ./scripts/install-chartsnap.sh
33+
34+
SHELLCHECK_VERSION = $(shell yq -ojson -r '.shellcheck' < $(TOOLS_VERSIONS_FILE))
35+
SHELLCHECK = $(PROJECT_DIR)/bin/installs/shellcheck/$(SHELLCHECK_VERSION)/bin/shellcheck
36+
.PHONY: shellcheck
37+
shellcheck: mise
38+
@$(MAKE) mise-plugin-install DEP=shellcheck
39+
@$(MAKE) mise-install DEP_VER=shellcheck@$(SHELLCHECK_VERSION)
40+
41+
.PHONY: tools
42+
tools: kube-linter chartsnap shellcheck
2043

2144
.PHONY: lint
2245
lint: tools lint.charts.kong lint.shellcheck
@@ -25,8 +48,10 @@ lint: tools lint.charts.kong lint.shellcheck
2548
lint.charts.kong:
2649
$(KUBE_LINTER) lint charts/kong
2750

28-
lint.shellcheck:
29-
shellcheck ./scripts/*
51+
.PHONY: lint.shellcheck
52+
lint.shellcheck: shellcheck
53+
$(SHELLCHECK) ./scripts/*
54+
$(SHELLCHECK) ./charts/gateway-operator/scripts/*
3055

3156
.PHONY: test.golden
3257
test.golden:

charts/gateway-operator/scripts/update-rbac-resources.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ KGO_REPO_PATH="${1}"
1919
KGOEE_REPO_PATH="${2}"
2020
CHARTS_REPO_PATH="${3}"
2121

22-
SED=sed
22+
SED="sed"
2323
if [[ $(uname -s) == "Darwin" ]]; then
24-
if gsed --version 2>&1 >/dev/null ; then
25-
SED=gsed
24+
if gsed --version >/dev/null 2>&1 ; then
25+
SED="gsed"
2626
else
2727
echo "GNU sed is required on macOS. You can install it via Homebrew with 'brew install gnu-sed'."
2828
exit 1
@@ -44,12 +44,13 @@ function require_var_dir() {
4444
}
4545

4646
function update_rbac_resources {
47-
local TMPFILE=$(mktemp).yaml
47+
local TMPFILE
48+
TMPFILE=$(mktemp).yaml
4849

4950
# build the kustomize resources
50-
kustomize build $KGOEE_REPO_PATH/config/rbac > "${TMPFILE}"
51+
kustomize build "${KGOEE_REPO_PATH}/config/rbac" > "${TMPFILE}"
5152
echo "---" >> "${TMPFILE}"
52-
kustomize build $KGO_REPO_PATH/config/rbac/base >> "${TMPFILE}"
53+
kustomize build "${KGO_REPO_PATH}/config/rbac/base" >> "${TMPFILE}"
5354

5455
# copy the contents of the file except for the Service Account resource
5556
yq --inplace e ". | select(.kind != \"ServiceAccount\")" "${TMPFILE}"
@@ -70,7 +71,7 @@ function update_rbac_resources {
7071
${SED} -i '/name: {{\|name: https/!s/name: /name: {{ template "kong.fullname" . }}-/g' "${TMPFILE}"
7172

7273
# move the new file to the charts directory
73-
mv "${TMPFILE}" $CHARTS_REPO_PATH/charts/gateway-operator/templates/rbac-resources.yaml
74+
mv "${TMPFILE}" "${CHARTS_REPO_PATH}/charts/gateway-operator/templates/rbac-resources.yaml"
7475
}
7576

7677
require_var_dir KGOEE_REPO_PATH

renovate.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,26 @@
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
44
"config:recommended"
5+
],
6+
"enabledManagers": [
7+
"custom.regex"
8+
],
9+
"automerge": false,
10+
"separateMinorPatch": true,
11+
"labels": [
12+
"dependencies"
13+
],
14+
"schedule": "before 5am every weekday",
15+
"customManagers": [
16+
{
17+
"description": "Match dependencies in .tools_verisons.yaml that are properly annotated with `# renovate: datasource={} depName={}.`",
18+
"customType": "regex",
19+
"fileMatch": [
20+
"\\.tools_versions\\.yaml$"
21+
],
22+
"matchStrings": [
23+
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)\\n.+\"(?<currentValue>.*?)\""
24+
]
25+
}
526
]
627
}

scripts/install-chartsnap.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22

3-
CHARTSNAP_VERSION="0.3.1"
3+
if [ -z "${CHARTSNAP_VERSION}" ]; then
4+
echo "ERROR: CHARTSNAP_VERSION is not set"
5+
exit 1
6+
fi
47

58
# Only install the plugin if it is not already installed or if the version is different.
69
if [[ $(helm plugin list | grep chartsnap | grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}') == "${CHARTSNAP_VERSION}" ]]; then

third_party/go.mod

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)