mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-23 10:12:10 +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.
|
# Some static checks rely on generated source files of components.
|
||||||
static-checks: static-checks-build
|
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:
|
docs-url-alive-check:
|
||||||
bash ci/docs-url-alive-check.sh
|
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
|
# set GO111MODULE to "auto" to enable module-aware mode only when
|
||||||
# a go.mod file is present in the current directory.
|
# a go.mod file is present in the current directory.
|
||||||
export GO111MODULE="auto"
|
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
|
# List of files to delete on exit
|
||||||
files_to_remove=()
|
files_to_remove=()
|
||||||
@ -125,7 +123,7 @@ usage()
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
Usage: $script_name help
|
Usage: $script_name help
|
||||||
$script_name [options] repo-name [true]
|
$script_name [options] [repo-name] [true]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
@ -175,7 +173,7 @@ Examples:
|
|||||||
|
|
||||||
- Auto-detect repository and run golang tests for current repository:
|
- 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
|
- Run all tests on the kata-containers repository, forcing the tests to
|
||||||
consider all files, not just those changed by a PR branch:
|
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 linter_dest="${GOPATH}/bin/hadolint"
|
||||||
|
|
||||||
local has_linter=$(command -v "$linter_cmd")
|
local has_linter=$(command -v "$linter_cmd")
|
||||||
if [[ -z "$has_linter" && "$KATA_DEV_MODE" == "yes" ]]; then
|
if [ -n "$has_linter" ]; 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
|
|
||||||
# Check if the expected linter version
|
# Check if the expected linter version
|
||||||
if $linter_cmd --version | grep -v "$linter_version" &>/dev/null; then
|
if $linter_cmd --version | grep -v "$linter_version" &>/dev/null; then
|
||||||
warn "$linter_cmd command found but not the required version $linter_version"
|
warn "$linter_cmd command found but not the required version $linter_version"
|
||||||
@ -1559,23 +1554,18 @@ main()
|
|||||||
[ "$specific_branch" = "false" ] && specific_branch="$2"
|
[ "$specific_branch" = "false" ] && specific_branch="$2"
|
||||||
|
|
||||||
if [ -z "$repo" ]
|
if [ -z "$repo" ]
|
||||||
then
|
|
||||||
if [ -n "$KATA_DEV_MODE" ]
|
|
||||||
then
|
then
|
||||||
# No repo param provided so assume it's the current
|
# No repo param provided so assume it's the current
|
||||||
# one to avoid developers having to specify one now
|
# one to avoid developers having to specify one now
|
||||||
# (backwards compatability).
|
# (backwards compatability).
|
||||||
repo=$(git config --get remote.origin.url |\
|
repo=$(git config --get remote.origin.url |\
|
||||||
sed 's!https://!!g' || true)
|
sed 's!https://!!g' || true)
|
||||||
|
|
||||||
info "Auto-detected repo as $repo"
|
info "Auto-detected repo as $repo"
|
||||||
else
|
|
||||||
if [ "$list_only" != "true" ]; then
|
|
||||||
echo >&2 "ERROR: need repo" && usage && exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test_path="${test_path:-"${repo}/tests"}"
|
||||||
|
test_dir="${GOPATH}/src/${test_path}"
|
||||||
|
|
||||||
repo_path=$GOPATH/src/$repo
|
repo_path=$GOPATH/src/$repo
|
||||||
|
|
||||||
announce
|
announce
|
||||||
|
Loading…
Reference in New Issue
Block a user