Files
nvke/.github/workflows/shellcheck.yml
Alex Pelavin f41e9b693c ci: version and release every component by the bare vX.Y.Z tag (#2164)
* ci: version every artifact by the bare v* describe

Every published artifact is now versioned by
`git describe --tags --always --match 'v*' "${GITHUB_SHA}"`, with no
component prefix, so component versions follow the nvke tag rather than
moving independently. The controller image, chart, provisioned provider
image, agent binaries and packages, nvkectl and the OS image resolve
their version this way, and the version is passed to each build so the
binaries report the same version they are published under.

The release registry describes and resolves components against the
bare v* tags, so a beta qualifies the artifacts its tag published.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: build and publish every component on a bare vX.Y.Z tag

Every component build that a vX.Y.Z-beta.N tag runs now runs on a bare
vX.Y.Z tag too: the controller and provisioned provider images, the
controller chart, the agent binaries and packages, the OS image and
nvkectl. The gates that admitted only beta tags admit any bare v* tag,
and nvkectl is versioned by the bare describe for both.

Beta-only behaviour is unchanged: a beta still skips DSX, stays out of
the apt index and bakes non-FDE images only. A release does all three.
promote-dsx now runs on vX.Y.Z, so it tags DSX with the bare describe
the NVCR copy was published under.

The beta flag in tag-publish.yml is removed, so nvkectl is published to
GHCR for every tag it is built for, betas included. cli-artifact.yml
versions it by the bare describe.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* build: version every module by the bare v* describe

The Makefiles, the root cmd_version and the scripts that derive the
agent version described against component tags (agent/v*, controller/v*,
cli/v*, os-image/v*, cluster-api-provider-provisioned/v*,
management-engine/v*). They now use
`git describe --tags --always --dirty --match 'v*'`, the version the
publish workflows already stamp, so a local or CI build reports the same
version as the artifact published from that commit.

The fallbacks for an untagged checkout and a build outside git are
unchanged, as is the agent's 0.0.0- prefix for an untagged .deb. The
e2e VALIDATE_VERSION now pairs with the nvke-validate image, and the
comments and log lines that named the old describe are updated.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* docs: describe one vX.Y.Z tag releasing every component

Components are no longer tagged on their own. The release docs, the
module AGENTS.md and README files and SECURITY.md now say one signed
vX.Y.Z tag releases the repository and every component built from it,
versioned by `git describe --tags --always --match 'v*'`.

docs/artifact-publication.md lists what each workflow publishes for a
release and for a nightly beta, and that an RC publishes nothing of its
own. The prefixed tag instructions, and the go get example that relied
on them, are removed. Mentions of past component tags that remain true
as history are kept.

The qualification docs and the qualify-e2e resolution input now say a
release, an RC and a beta are all qualified with commitDescribe, which
describes the commit the version marks and so resolves every component
to it. gitTag takes the highest v* tag in the repository and is not for
qualification.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: stop publishing artifacts from component release tags

A component release tag (agent/vX.Y.Z, controller/vX.Y.Z,
cluster-api-provider-provisioned/vX.Y.Z, os-image/vX.Y.Z, cli/vX.Y.Z) no
longer starts a publisher; a release is a bare vX.Y.Z tag. Component
release candidate tags still start the same workflows as before.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: publish every GHCR release artifact on vX.Y.Z

agent-artifact.yml, chart-publish.yml and image-validate-nvcr.yml only ran
on component tags, so a release published none of them. Each now runs on a
bare vX.Y.Z tag and versions by the bare v* describe. The controller and
provider GHCR promotions and the agent .deb GHCR push also run on vX.Y.Z
(not betas), since they were gated on component tags too and the GHCR
chart waits for the controller image there.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: name every tag build by its describe version, not the tag

The publishers versioned the build by the bare v* describe but still took
version aliases, GHCR promotion tags, the agent .deb version, the nvkectl
S3 release path and the os-image version from the tag name. On a component
RC tag the two disagreed, and on a vX.Y.Z tag agent-deb's GHCR push would
have been tagged with the commit SHA. Every one now uses the describe
version, which on the tagged commit is the tag itself.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: pass the describe version to build commands through the environment

The version is git describe output, which a tag name controls. It was
interpolated with ${{ }} into the run script of six build steps, so a tag
containing shell syntax would have run in jobs that hold registry
credentials. Each step now reads it from an environment variable.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: give component RC tags no version alias

A component RC tag still starts the agent and nvkectl publishers, and
they name the build by the bare v* describe. On a commit that already
carries a release tag that is the release's version, so the RC run would
move the release's alias to a new manifest. Only a bare v* tag now adds
the version alias; a component RC tag publishes sha-<commit> only.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: resolve every publisher's version through one checked script

Every publisher resolves its version through
release/hack/describe-version.sh instead of calling git describe itself.
A bare v* tag run is published under its own tag; any other run under
the v* describe. Before anything is pushed, the script refuses:

- a describe that is not a v* release, RC or beta, its describe suffix,
  or a bare commit. The describe can name any v* tag on the commit, and
  agent/Makefile passes it to the shell inside -ldflags.
- on a v* tag run, a tag that is not a version or does not name the
  commit being built.
- on a component tag run, a commit a v* tag already names. Its describe
  is that tag, so a component RC there would republish that tag's
  .debs, images, charts and nvkectl.

Naming a tag run by its tag rather than the describe matters when the
commit carries several: git describe prefers the annotated release, and
of two lightweight betas the first by name. A beta re-run on a released
commit, or a second beta on one commit, now publishes under its own
version instead of another tag's.

release/hack/test_describe_version.py covers these cases against fixture
repositories, and runs with next-tag-test in the merge gate.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: let only a release version into the apt index and GHCR

agent-deb-publish.yml chose whether to update index.json, and whether to
push the .debs to GHCR, from the ref: anything but a beta tag did both.
An agent/v* RC tag carries no -beta., but its packages are versioned by
the describe, so on a commit past a beta it made that build installable
from apt and pushed it to GHCR.

The build job now reports whether its version is a bare vX.Y.Z, and both
follow that instead. A release enters the index and GHCR; a beta, a
component RC and anything else is uploaded under releases/<version>/ and
pushed to NVCR only.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: stamp the published version into standalone nvkectl builds

A dispatched cli-artifact, cli-artifact-nvcr or cli-s3-publish run with no
dist_artifact builds nvkectl itself. The build took its version from the
Makefile's own git describe, which on a commit with a beta and a signed
release names the release, while the run publishes under the beta it was
dispatched from. Pass the resolved version as NVKECTL_VERSION, as
tag-publish.yml already does, so the binary reports the version it is
published under.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: skip a beta dispatch of the GHCR chart publisher

A beta's controller image is never promoted to GHCR, so a chart-publish.yml
run dispatched from a beta tag waited up to 30 minutes for an image that
would not appear, then failed. Skip beta refs, as the automatic beta trigger
already does.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* test: cover the triggering-tag check and a bare RC in describe-version.sh

Every invalid tag in the existing test was also the commit's describe, so
the describe check refused it before the check on the triggering tag ran,
and disabling that check left every test passing. Tag the bad names beside a
valid signed release, which wins the describe, so only the tag check can
refuse them.

Also pin that the helper names a bare RC run by its tag: the publishers'
tag filters, not the helper, keep an RC from publishing.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

* ci: recover a vX.Y.Z agent package release by dispatch

A failed agent/vX.Y.Z publish could be recovered by dispatching Agent Deb
Publish from that tag with ref set to it. Releases are now vX.Y.Z, which the
ref check refused, and a SHA got past it only for every publish job to skip,
since their bare-tag arm requires a push.

Accept a vX.Y.Z ref when the run is dispatched from that same tag, and let
it into the apt intake, GHCR and NVCR jobs. The tag names the run's version,
so the index.json and GHCR gates still admit only a release. A beta is not
admitted, as before.

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>

---------

Signed-off-by: Alex Pelavin <apelavin@nvidia.com>
2026-11-16 10:05:29 -06:00

134 lines
6.4 KiB
YAML

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Lints the shell scripts, and tests release/hack/next-tag.sh, the one that
# versions releases.
#
# actionlint already runs shellcheck, but only over `run:` blocks inside
# workflow YAML. The 100 standalone .sh files in this tree had nothing checking
# them, and three real bugs were sitting in them -- including a dependency
# check in a runbook script that is compiled into the controller binary and
# executed on nodes, and that never detected a missing tool. All three parsed
# fine under `bash -n`; only shellcheck saw them.
#
# Runs on ubuntu-latest with the pinned shellcheck release.
#
# Deliberately NOT path-filtered, for the reason recorded in actionlint.yml: a
# filtered check does not report on a pull request that misses the filter, and
# a required check that never reports leaves that pull request waiting forever.
# See .github/workflows/README.md.
name: Shellcheck
# All pull requests, including forks and Dependabot, reach this through
# merge-gate.yml. The standalone push trigger is post-merge coverage on main;
# naming mirror or Dependabot branches here too would run it a second time.
on:
push:
branches: [main]
workflow_call:
workflow_dispatch: {}
permissions: {}
concurrency:
# The sha is part of the group on main, so every commit gets its own.
# Without it, back-to-back merges lose CI results: GitHub allows one
# running and one pending run per group, and cancels the pending one
# when a third arrives -- whatever cancel-in-progress says, because that
# setting only protects a run that has already started. Five merges in
# three minutes cancelled 18 runs across 7 workflows this way, leaving
# three consecutive commits on main with no test result at all.
#
# Pull-request branches keep sharing a group and still cancel, which is
# what you want there.
# A literal name, NOT ${{ github.workflow }}. Inside a called workflow that
# expression is the CALLER's name, so every workflow merge-gate.yml calls would
# compute the same group and cancel each other -- 8 of 9 calls died that way,
# reported to the gate as failures with no jobs and no error message.
group: Shellcheck-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
if: github.repository_id == '1323115536'
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install shellcheck
run: |
set -euo pipefail
version="$(make --no-print-directory print-SHELLCHECK_VERSION)"
sha256="$(make --no-print-directory print-SHELLCHECK_SHA256)"
archive="shellcheck-v${version}.linux.x86_64.tar.xz"
url="https://github.com/koalaman/shellcheck/releases/download/v${version}/${archive}"
tmp="$(mktemp -d)"
trap 'rm -rf "${tmp}"' EXIT
# No retry at all until now: a 504 from the release CDN failed the job
# on the first response. Same form as setup-kind and setup-crane.
curl -fsSL --retry 8 --retry-all-errors --retry-max-time 240 \
-o "${tmp}/${archive}" "${url}"
echo "${sha256} ${tmp}/${archive}" | sha256sum --check
tar -xJf "${tmp}/${archive}" -C "${tmp}"
mkdir -p "${HOME}/.local/bin"
install -m 0755 "${tmp}/shellcheck-v${version}/shellcheck" "${HOME}/.local/bin/shellcheck"
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"
# -S error, not -S warning. The tree is clean at error severity as of
# this commit, so the gate starts green and any new error-level bug fails
# the build. It is NOT clean at warning severity: 31 findings remain,
# mostly SC2155 (declare and assign separately), SC2010 (ls | grep) and
# SC2128 (array expanded without an index). Those are worth fixing, but
# folding 29 edits into the change that introduces the check would bury
# the three real bugs it was written for. The step below prints the live
# count, so this number does not have to be trusted as it drifts.
#
# Raise this to -S warning once that backlog is cleared. The runbook
# scripts under controller/internal/runbook/scripts/ are the ones to
# clear first: they ship inside the controller binary and run on nodes.
# Find scripts by extension and by shebang. `*.sh` alone missed 11 tracked
# scripts, one of which a Go test runs
# (controller/hack/capd-kindest-node/scripts/cloud-init-status-shim).
#
# Built once and read by both steps below, which previously kept identical
# `find` lines by hand.
- name: Lint shell scripts
run: make lint-shell
# release/hack/next-tag.sh decides the version every nightly beta and
# release candidate is tagged with, and describe-version.sh the version
# every publisher pushes under; a wrong one is pushed rather than
# reported. Tested here rather than in a gate member of its own: they are
# shell scripts, and this job already gates every pull request.
- name: Test release/hack/next-tag.sh and describe-version.sh
run: make next-tag-test
# Reported, not enforced, so the size of the backlog is visible without
# gating on it. Remove when the gate above moves to -S warning.
- name: Report the warning-level backlog
if: always()
shell: bash
run: |
set -uo pipefail
n=$(./hack/shell-scripts.sh | tr -dc '\\0' | wc -c | tr -d ' ')
# `|| true` is required. shellcheck exits non-zero on any finding, and
# the runner invokes this step with `bash -e -o pipefail`, so without
# it a non-empty backlog fails the step that counts the backlog.
count=$( { ./hack/shell-scripts.sh | xargs -0 shellcheck --severity=warning --format=gcc 2>/dev/null || true; } | wc -l | tr -d ' ')
{
echo "## shellcheck"
echo
echo "Gate: \`--severity=error\` over ${n} scripts."
echo
echo "Not yet enforced: **${count}** finding(s) at \`--severity=warning\`."
} >> "${GITHUB_STEP_SUMMARY}"