mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
* build: give every tool pin a single owner in make/tool-versions.mk make/tool-versions.mk already owned most of the repository's pins, but nine tools still declared their own where they were used, and two of those were declared twice: controller-tools v0.20.1 in both cluster-api-provider-provisioned/ and management-engine/, and the TPM plugin 1.9.0 in both the spire-agent package and the CAPD bundle script. The second pair was held in step by a comment reading 'move them together'. Moved in: addlicense, buf, controller-tools, ginkgo, gofail, gofumpt, goimports, setup-envtest, the envtest Kubernetes version, and the SPIRE and TPM-plugin releases the node .deb wraps. golangci-lint stays in make/golangci.mk, beside the bootstrap logic that consumes it, and is the one recorded exception. prepare-capd-bundles.sh cannot include a makefile, so it now reads the two pins out of make/tool-versions.mk instead of restating them. hack/tool-version-check.sh makes this hold: for every name the owner declares, a literal re-declaration anywhere else in the tree fails with the tool, both values, and both locations. A derivation -- any right-hand side that reads the value from somewhere -- is the wanted shape and passes. Wired into 'make gate' and go-build.yml. The envtest cache key in gofail-e2e.yml now hashes make/tool-versions.mk too, since that is where ENVTEST_K8S_VERSION moved. Signed-off-by: Terry Howe <thowe@nvidia.com> * build: close the tool-pin gaps review found build-image.sh still defaulted SPIRE_AGENT_VERSION and TPM_ATTESTOR_VERSION to literal 1.14.1 / 1.9.0 -- the same two pins this branch centralised, in the sibling of the script it fixed. The checker could not see them: the names differ from the owned ones, and `: "${X:=v}"` is not the `X=` shape it greps. Both readers now share hack/read-tool-version.sh rather than each carrying a copy of the sed. Env overrides still win; the pin is only the default, and an unknown name is a hard error so a rename fails loudly instead of downloading an empty version. The comment this branch deleted from the spire-agent Makefile was the only in-tree pointer to the places nothing can check -- controller/Tiltfile, hack/mirror-bootstrap-images.sh and create-forge-nico-cluster.sh embed the version inside an image tag or an apt package spec. That list now sits above the pin it constrains, split into what the check enforces and what a human still has to move. Also from review: - The checker now reads YAML `NAME: value`, which is how a workflow or a composite action declares a pin. Every current occurrence is a `${{ }}` derivation and still passes; a literal one now fails. - EXEMPT_FILES described golangci.mk as "the one recorded exception", but GOLANGCI_LINT_VERSION is not declared in the owner file, so the check never looks for it. Reworded to what it is: room for the pin to move here later. - Quote the pin count instead of relying on word splitting (SC2086). - Drop the double blank lines the moved declarations left behind. Signed-off-by: Terry Howe <thowe@nvidia.com> * build: route every addlicense pin through ADDLICENSE_VERSION, catch `+=` Review found `controller/Makefile` still invoking `addlicense@v1.1.1` while `agent/Makefile` used the variable. It was five sites, not one: the root `Makefile`, `cli/`, `controller/`, `controller/nico-sim/` and `os-image/` all restated the literal, so moving ADDLICENSE_VERSION into the owner file had converted exactly one of six consumers. `controller/nico-sim/` and `os-image/` did not include the owner file at all, so the variable was empty there -- substituting it without the include would have produced `addlicense@` and a broken target rather than a wrong version. Both now include it. It is assignments only, so neither module's default goal moves. The check could not have caught any of these: a version inside a `go run` module path is not an assignment, the same reason the Tiltfile image tags are listed as unreachable in make/tool-versions.mk. Separately, the check now reads `+=`. Appending to a pin the owner already set yields a two-word value no consumer can use, and it is a second declaration by any reading. Kept `[[:space:]]*` rather than the suggested `[[:space:]]`: the latter requires a space before the operator and would have stopped matching `GINKGO_VERSION?=v1.0.0`, which is the form the check most needs to catch. Signed-off-by: Terry Howe <thowe@nvidia.com> --------- Signed-off-by: Terry Howe <thowe@nvidia.com>
32 lines
1.3 KiB
Bash
Executable File
32 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Read a pin out of make/tool-versions.mk, for the callers that cannot include
|
|
# it. A shell script that restates a pin is a second declaration, and
|
|
# hack/tool-version-check.sh rejects it; this is how such a script gets the
|
|
# value instead.
|
|
#
|
|
# Source it and call read_tool_version:
|
|
#
|
|
# . "$(git rev-parse --show-toplevel)/hack/read-tool-version.sh"
|
|
# SPIRE_AGENT_VERSION="$(read_tool_version SPIRE_VERSION)"
|
|
#
|
|
# An unknown name is a hard error rather than an empty string, so a pin that is
|
|
# renamed in the owner file fails here instead of downloading ""-tagged bytes.
|
|
|
|
# Resolved from this file's own location, so a caller at any depth works and no
|
|
# caller has to count "..". Not readonly: sourcing twice in one shell is a
|
|
# caller's business, not an error.
|
|
TOOL_VERSIONS_MK="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/make/tool-versions.mk"
|
|
|
|
read_tool_version() {
|
|
local name="${1:?usage: read_tool_version NAME}" value
|
|
value="$(sed -nE "s/^${name}[[:space:]]*\\??=[[:space:]]*([^[:space:]#]+).*/\\1/p" "${TOOL_VERSIONS_MK}" | tail -1)"
|
|
if [[ -z "${value}" ]]; then
|
|
printf '%s is not declared in %s\n' "${name}" "${TOOL_VERSIONS_MK}" >&2
|
|
return 1
|
|
fi
|
|
printf '%s' "${value}"
|
|
}
|