Files
podman/hack/ci/pr-should-include-tests
Kir Kolyshkin 6e597af6dc Migrate validate-source from Cirrus to GitHub Actions
Move the Cirrus validate-source_task to a GitHub Actions workflow
(.github/workflows/ci.yml) running as a single job on the CNCF-hosted
runner. The job runs the same stages: make validate-source,
tests-included, and the conditional renovate config check.

golangci-lint for FreeBSD and macOS now runs cross-compiled (GOOS) on
the native Linux runner instead of on dedicated Cirrus VMs/workers, so
the lint steps are dropped from osx_alt_build and freebsd_alt_build.

The PR helper scripts are de-Cirrus'd: they read CI-neutral env vars
(PR_HEAD, PR_NUMBER, PR_BODY) and the "No New Tests" label override is
now handled natively in the workflow instead of via a GraphQL query.

The shared clone/setup/main YAML anchors are relocated into build_task,
and the dead _run_validate-source runner.sh function is removed.

The tests-of-tests (.t files) are fixed for new setup (mostly removing
test cases which are now obsoleted, like [CI:DOCS] and [NO NEW TESTS]
markers. NOTE we still don't run tests in CI (although we could), but
I ran them locally and fixed all the issues.

Finally, test-jira-links-included is removed as it is RHEL-branch
specific and have no place in the new repo.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-06-01 13:01:33 +02:00

69 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
#
# Intended for use in CI: check git commits, barf if no tests added.
#
ME=$(basename $0)
# Github label which allows overriding this check
OVERRIDE_LABEL="No New Tests"
# PR head commit; defaults to HEAD when not running in CI.
head=${PR_HEAD:-HEAD}
# Base of this PR.
base=$(git merge-base ${DEST_BRANCH:-main} $head)
# This gives us a list of files touched in all commits, e.g.
# A foo.c
# M bar.c
# We look for Added or Modified (not Deleted!) files under 'test'.
# --no-renames ensures that renamed tests (#9420) show up as 'A'dded.
if git diff --name-status --no-renames $base $head | grep -E -q '^[AM]\s+(test/|.*_test\.go)'; then
exit 0
fi
# Nothing changed under test subdirectory.
#
# This is OK if the only files being touched are "safe" ones.
filtered_changes=$(git diff --name-only $base $head |
grep -F -vx .cirrus.yml |
grep -F -vx .pre-commit-config.yaml |
grep -F -vx .gitignore |
grep -F -vx go.mod |
grep -F -vx go.sum |
grep -F -vx podman.spec.rpkg |
grep -F -vx .golangci.yml |
grep -F -vx winmake.ps1 |
grep -E -v '/*Makefile$' |
grep -E -v '^[^/]+\.md$' |
grep -E -v '^.github' |
grep -E -v '^contrib/' |
grep -E -v '^docs/' |
grep -E -v '^hack/' |
grep -E -v '^nix/' |
grep -E -v '^vendor/' |
grep -E -v '^version/')
if [[ -z "$filtered_changes" ]]; then
exit 0
fi
# This PR touches non-test files but adds no tests. Fail loudly.
# The '$OVERRIDE_LABEL' label can be used to override this check; that is
# handled by the CI workflow, not here.
cat <<EOF
$ME: PR does not include changes in the 'tests' directory
Please write a regression test for what you're fixing. Even if it
seems trivial or obvious, try to add a test that will prevent
regressions.
If your change is minor, feel free to piggyback on already-written
tests, possibly just adding a small step to a similar existing test.
Every second counts in CI.
If your commit really, truly does not need tests, you can proceed
by asking a repo maintainer to set the '$OVERRIDE_LABEL' github label.
This will only be done when there's no reasonable alternative.
EOF
exit 1