mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-22 09:49:35 +00:00
ci: static-checks: Auto-detect repo by default
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 <abombo@microsoft.com>
This commit is contained in:
parent
d077ed4c1e
commit
9585e608e5
2
Makefile
2
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
|
||||
|
@ -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 <<EOF
|
||||
|
||||
Usage: $script_name help
|
||||
$script_name [options] repo-name [true]
|
||||
$script_name [options] [repo-name] [true]
|
||||
|
||||
Options:
|
||||
|
||||
@ -175,7 +173,7 @@ Examples:
|
||||
|
||||
- Auto-detect repository and run golang tests for current repository:
|
||||
|
||||
$ KATA_DEV_MODE=true $script_name --golang
|
||||
$ $script_name --golang
|
||||
|
||||
- Run all tests on the kata-containers repository, forcing the tests to
|
||||
consider all files, not just those changed by a PR branch:
|
||||
@ -1231,10 +1229,7 @@ has_hadolint_or_install()
|
||||
local linter_dest="${GOPATH}/bin/hadolint"
|
||||
|
||||
local has_linter=$(command -v "$linter_cmd")
|
||||
if [[ -z "$has_linter" && "$KATA_DEV_MODE" == "yes" ]]; then
|
||||
# Do not install if it is in development mode.
|
||||
die "$linter_cmd command not found. You must have the version $linter_version installed to run this check."
|
||||
elif [ -n "$has_linter" ]; then
|
||||
if [ -n "$has_linter" ]; then
|
||||
# Check if the expected linter version
|
||||
if $linter_cmd --version | grep -v "$linter_version" &>/dev/null; then
|
||||
warn "$linter_cmd command found but not the required version $linter_version"
|
||||
@ -1559,23 +1554,18 @@ main()
|
||||
[ "$specific_branch" = "false" ] && specific_branch="$2"
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
test_path="${test_path:-"${repo}/tests"}"
|
||||
test_dir="${GOPATH}/src/${test_path}"
|
||||
|
||||
repo_path=$GOPATH/src/$repo
|
||||
|
||||
announce
|
||||
|
Loading…
Reference in New Issue
Block a user