From 9585e608e52911884929f9f090228fc68f4536bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Thu, 31 Jul 2025 13:52:56 -0500 Subject: [PATCH] ci: static-checks: Auto-detect repo by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This auto-detects the repo by default (instead of having to specify KATA_DEV_MODE=true) so that forked repos can leverage the static-checks.yaml CI check without modification. An alternative would have been to pass the repo in static-checks.yaml. However, because of the matrix, this would've changed the check name, which is a pain to handle in either the gatekeeper/GH UI. Example fork failure: https://github.com/microsoft/kata-containers/actions/runs/16656407213/job/47142421739#step:8:75 I've tested this change to work in a fork. Signed-off-by: Aurélien Bombo --- Makefile | 2 +- tests/static-checks.sh | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 411e1f78fa..16180e8e74 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ generate-protocols: # Some static checks rely on generated source files of components. static-checks: static-checks-build - bash tests/static-checks.sh github.com/kata-containers/kata-containers + bash tests/static-checks.sh docs-url-alive-check: bash ci/docs-url-alive-check.sh diff --git a/tests/static-checks.sh b/tests/static-checks.sh index 88e1d61e95..f4bb4077fa 100755 --- a/tests/static-checks.sh +++ b/tests/static-checks.sh @@ -20,8 +20,6 @@ source "${cidir}/common.bash" # set GO111MODULE to "auto" to enable module-aware mode only when # a go.mod file is present in the current directory. export GO111MODULE="auto" -export test_path="${test_path:-github.com/kata-containers/kata-containers/tests}" -export test_dir="${GOPATH}/src/${test_path}" # List of files to delete on exit files_to_remove=() @@ -125,7 +123,7 @@ usage() cat </dev/null; then warn "$linter_cmd command found but not the required version $linter_version" @@ -1560,22 +1555,17 @@ main() if [ -z "$repo" ] then - if [ -n "$KATA_DEV_MODE" ] - then - # No repo param provided so assume it's the current - # one to avoid developers having to specify one now - # (backwards compatability). - repo=$(git config --get remote.origin.url |\ - sed 's!https://!!g' || true) - - info "Auto-detected repo as $repo" - else - if [ "$list_only" != "true" ]; then - echo >&2 "ERROR: need repo" && usage && exit 1 - fi - fi + # No repo param provided so assume it's the current + # one to avoid developers having to specify one now + # (backwards compatability). + repo=$(git config --get remote.origin.url |\ + sed 's!https://!!g' || true) + info "Auto-detected repo as $repo" fi + test_path="${test_path:-"${repo}/tests"}" + test_dir="${GOPATH}/src/${test_path}" + repo_path=$GOPATH/src/$repo announce