Skip to content

Commit 6414ca9

Browse files
committed
enable chart version checks
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
1 parent f61f4ec commit 6414ca9

4 files changed

Lines changed: 95 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ For every Pull Request submitted, ensure the following steps have been done:
8888
- `X` (major) is incremented for breaking changes,
8989
- `Y` (minor) is incremented when new features are added without breaking existing functionality,
9090
- `Z` (patch) is incremented for bug fixes, minor improvements, or non-breaking changes.
91+
92+
If you modify the chart, please bump the chart version. You can run
93+
`make bump-chart-version-patch` to automatically increment the patch
94+
version. After updating the chart, run `make lint` to validate your changes.
9195
5. Run pre-commit hooks to ensure code quality and schema validation: `make pre-commit-run`
92-
6. Lint tests have been run for the Chart using the [Chart Testing](https://github.com/helm/chart-testing) tool and the `ct lint` command.
96+
6. Lint tests have been run for the Chart using the [Chart Testing](https://github.com/helm/chart-testing) tool and the `make lint` command.
9397
<!-- TODO after the helm-docs supported: 7. Make sure that [helm-docs](https://github.com/norwoodj/helm-docs) has been run to generate/update the `README.md` documentation. To preview the content, use `helm-docs --dry-run`. -->
9498

9599
## FAQ and Troubleshooting

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pre-helm: tools ## Set up Helm dependency repositories
1616

1717
.PHONY: lint
1818
lint: pre-helm ## Run lint checks using helm-lint
19-
ct lint --check-version-increment=false --validate-maintainers=false --charts charts/llm-d-modelservice $(if $(TARGET_BRANCH),--target-branch $(TARGET_BRANCH))
19+
ct lint --config ct.yaml $(if $(TARGET_BRANCH),--target-branch $(TARGET_BRANCH))
2020

2121
# Paths that need verification during 'make verify'
2222
PATHS_TO_VERIFY := examples/
@@ -32,6 +32,13 @@ verify: generate ## Verify that generated files match current state
3232
generate: tools ## Generate example output files from Helm chart templates
3333
hack/generate-example-output.sh
3434

35+
.PHONY: bump-chart-version-%
36+
bump-chart-version-%: ## Bump chart version by type (patch, major, minor), e.g., make bump-chart-version-patch
37+
@printf "\033[33;1m==== Running bump chart version ====\033[0m\n"
38+
hack/increment-chart-version.sh $*
39+
## Regenerate example output after version bump
40+
hack/generate-example-output.sh
41+
3542
##@ Tools
3643

3744
.PHONY: tools

ct.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
chart-dirs:
2+
- charts
3+
validate-maintainers: false
4+
remote: origin
5+
helm-extra-args: --timeout 500s
6+
lint-conf: lintconf.yaml
7+
chart-yaml-schema: chart_schema.yaml

hack/increment-chart-version.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
usage() {
4+
cat <<EOF
5+
Usage: $(basename "$0") <bump_type>
6+
7+
Bumps the Helm chart version in Chart.yaml by the specified type.
8+
9+
Required argument:
10+
bump_type The type of version bump. Must be one of:
11+
- major
12+
- minor
13+
- patch
14+
15+
Examples:
16+
$(basename "$0") patch # 1.2.3 -> 1.2.4
17+
$(basename "$0") minor # 1.2.3 -> 1.3.0
18+
$(basename "$0") major # 1.2.3 -> 2.0.0
19+
20+
EOF
21+
exit 1
22+
}
23+
24+
BUMP_TYPE="$1"
25+
26+
if [[ -z "${BUMP_TYPE}" ]]; then
27+
echo -e "Error: no \$bump_type passed as \$1.\n"
28+
usage
29+
elif [[ "${BUMP_TYPE}" != "major" ]] && [[ "${BUMP_TYPE}" != "minor" ]] && [[ "${BUMP_TYPE}" != "patch" ]]; then
30+
echo -e "Error: \$bump_type \"${BUMP_TYPE}\" not recognized.\n"
31+
usage
32+
fi
33+
34+
# requires git, yq
35+
36+
REPO_ROOT=$(git rev-parse --show-toplevel)
37+
38+
# Path to your Chart.yaml
39+
CHART_FILE="${REPO_ROOT}/charts/llm-d-modelservice/Chart.yaml"
40+
41+
FEATURE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
42+
43+
STASH_RESULT=$(git stash)
44+
45+
git fetch origin
46+
git checkout main
47+
git merge --ff-only origin/main
48+
49+
git switch ${FEATURE_BRANCH}
50+
if [[ "${STASH_RESULT}" != "No local changes to save" ]]; then
51+
git stash pop
52+
fi;
53+
54+
git checkout main -- ${CHART_FILE}
55+
56+
current_version=$(yq e '.version' "$CHART_FILE")
57+
58+
IFS='.' read -r major minor patch <<< "$current_version"
59+
60+
if [[ "${BUMP_TYPE}" == "patch" ]]; then
61+
patch=$((patch + 1))
62+
elif [[ "${BUMP_TYPE}" == "minor" ]]; then
63+
minor=$((minor + 1))
64+
patch=0
65+
elif [[ "${BUMP_TYPE}" == "major" ]]; then
66+
major=$((major + 1))
67+
minor=0
68+
patch=0
69+
fi
70+
71+
new_version="$major.$minor.$patch"
72+
73+
yq e -i ".version = \"$new_version\"" "$CHART_FILE"
74+
75+
echo "Version updated: $current_version$new_version"

0 commit comments

Comments
 (0)