Enable ShellCheck CI (#478)

Motivation:

Complete enablement of all standard GitHub Actions workflows.

Modifications:

Describe the modifications you've done.

Result:

After your change, what will change.
This commit is contained in:
Peter Adams authored and GitHub committed 2024-10-30 15:22:05 +00:00
1 parent 6c86975025
commit 4bce87f3cf
9 files changed
+31 -22

No files matched your search

-2
View File
@@ -10,8 +10,6 @@ jobs:
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftNIO"
format_check_enabled: true
shell_check_enabled: false
unit-tests:
name: Unit tests
+5 -5
View File
@@ -24,7 +24,9 @@
set -eu
readonly FuzzTestingDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
# shellcheck disable=SC2001 # Too complex
FuzzTestingDir=$(dirname "$(echo "$0" | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly FuzzTestingDir
printUsage() {
NAME=$(basename "${0}")
@@ -95,13 +97,11 @@ cd "${FuzzTestingDir}"
declare -a CMD_BASE
if [ "$(uname)" == "Darwin" ]; then
CMD_BASE=(
xcrun
--toolchain swift
swift build -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
xcrun --toolchain swift swift build -Xswiftc "-sanitize=fuzzer,address" -Xswiftc -parse-as-library
)
else
CMD_BASE=(
swift build -Xswiftc -sanitize=fuzzer,address -Xswiftc -parse-as-library
swift build -Xswiftc "-sanitize=fuzzer,address" -Xswiftc -parse-as-library
)
fi
+3 -3
View File
@@ -44,9 +44,9 @@ function junit_output_replace() {
function plugin_junit_xml_test_suite_begin() {
junit_testsuite_time=0
junit_output_write "<testsuite name='$1' hostname='$(hostname)' "\
"timestamp='$(date -u +"%Y-%m-%dT%H:%M:%S")' tests='XXX-TESTS-XXX' "\
"failures='XXX-FAILURES-XXX' time='XXX-TIME-XXX' errors='0' id='$(date +%s)'"\
junit_output_write "<testsuite name='$1' hostname='$(hostname)' " \
"timestamp='$(date -u +"%Y-%m-%dT%H:%M:%S")' tests='XXX-TESTS-XXX' " \
"failures='XXX-FAILURES-XXX' time='XXX-TIME-XXX' errors='0' id='$(date +%s)'" \
" package='NIOIntegrationTests.$1'>"
}
+5
View File
@@ -20,12 +20,17 @@ set -x
set -o pipefail
test="$1"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
tmp="$2"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
root="$3"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
g_show_info="$4"
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck source=IntegrationTests/test_functions.sh
source "$here/test_functions.sh"
# shellcheck source=/dev/null
source "$test"
wait
)
+8 -6
View File
@@ -36,7 +36,9 @@ function plugins_do() {
done
}
# shellcheck source=IntegrationTests/plugin_echo.sh
source "$here/plugin_echo.sh"
# shellcheck source=/dev/null
source "$here/plugin_junit_xml.sh"
plugins="echo"
@@ -88,7 +90,7 @@ function run_test() {
if $verbose; then
"$@" 2>&1 | tee -a "$out"
# we need to return the return value of the first command
return ${PIPESTATUS[0]}
return "${PIPESTATUS[0]}"
else
"$@" >> "$out" 2>&1
fi
@@ -113,13 +115,13 @@ for f in tests_*; do
plugins_do test_begin "$t" "$f"
start=$(date +%s)
if run_test "$here/run-single-test.sh" "$here/$f/$t" "$test_tmp" "$here/.." "$show_info"; then
plugins_do test_ok "$(time_diff_to_now $start)"
plugins_do test_ok "$(time_diff_to_now "$start")"
suite_ok=$((suite_ok+1))
if $verbose; then
cat "$out"
fi
else
plugins_do test_fail "$(time_diff_to_now $start)" "$out"
plugins_do test_fail "$(time_diff_to_now "$start")" "$out"
suite_fail=$((suite_fail+1))
fi
if ! $debug; then
@@ -131,7 +133,7 @@ for f in tests_*; do
cnt_ok=$((cnt_ok + suite_ok))
cnt_fail=$((cnt_fail + suite_fail))
cd ..
plugins_do test_suite_end "$(time_diff_to_now $start_suite)" "$suite_ok" "$suite_fail"
plugins_do test_suite_end "$(time_diff_to_now "$start_suite")" "$suite_ok" "$suite_fail"
done
if ! $debug; then
@@ -142,7 +144,7 @@ fi
# report
if [[ $cnt_fail > 0 ]]; then
if [[ $cnt_fail -gt 0 ]]; then
# kill leftovers (the whole process group) # ignore-unacceptable-language
trap '' TERM
kill 0 # ignore-unacceptable-language
@@ -152,7 +154,7 @@ else
plugins_do summary_ok "$cnt_ok" "$cnt_fail"
fi
if [[ $cnt_fail > 0 ]]; then
if [[ $cnt_fail -gt 0 ]]; then
exit 1
else
exit 0
+1
View File
@@ -64,6 +64,7 @@ function assert_greater_than_or_equal() {
g_has_previously_infoed=false
function info() {
# shellcheck disable=SC2154 # Defined by an include our by being source transpiled in
if $g_show_info; then
if ! $g_has_previously_infoed; then
echo >&3 || true # echo an extra newline so it looks better
@@ -13,6 +13,7 @@
##
##===----------------------------------------------------------------------===##
# shellcheck source=IntegrationTests/tests_01_allocation_counters/defines.sh
source defines.sh
set -eu
@@ -28,7 +29,8 @@ for file in "$here/test_01_resources/"test_*.swift; do
all_tests+=( "$test_name" )
done
"$here/test_01_resources/run-nio-http2-alloc-counter-tests.sh" -t "$tmp" > "$tmp/output"
# shellcheck disable=SC2154 # Not really sure why this is flagged and not others
"$here/test_01_resources/run-nio-http2-alloc-counter-tests.sh" -t "$tmp" > "${tmp}/output"
for test in "${all_tests[@]}"; do
cat "$tmp/output" # helps debugging
@@ -59,5 +61,5 @@ for test in "${all_tests[@]}"; do
assert_less_than_or_equal "$total_allocations" "$max_allowed"
assert_greater_than "$total_allocations" "$(( max_allowed - 1000))"
fi
done < <(grep "^test_$test[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq)
done < <(grep "^test_${test}[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq)
done
+1 -1
View File
@@ -16,4 +16,4 @@
set +ex
mkdir -p .build # for the junit.xml file
./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i $@
./IntegrationTests/run-tests.sh --junit-xml .build/junit-sh-tests.xml -i "$@"
+4 -3
View File
@@ -23,10 +23,11 @@ function stop_server() {
sleep 0.5 # just to make sure all the fds could be closed
kill -0 "$1" # assert server is still running # ignore-unacceptable-language
kill "$1" # tell server to shut down gracefully # ignore-unacceptable-language
for f in $(seq 20); do
for _ in $(seq 20); do
if ! kill -0 "$1" 2> /dev/null; then # ignore-unacceptable-language
break # good, dead
fi
# shellcheck disable=SC2009 # pgrep much more awkward to use for this
ps auxw | grep "$1" || true
sleep 0.1
done
@@ -37,14 +38,14 @@ function stop_server() {
# Simple thing to do. Start the server in the background.
# Allow extra build arguments from the command line - eg tsan.
swift build $@
swift build "$@"
"$(swift build --show-bin-path)/NIOHTTP2Server" 127.0.0.1 8888 > /dev/null & disown
SERVER_PID=$!
echo "$SERVER_PID"
# Wait for the server to bind a socket.
worked=false
for f in $(seq 20); do
for _ in $(seq 20); do
port=$(server_lsof "$SERVER_PID" | grep -Eo 'TCP .*:[0-9]+ ' | grep -Eo '[0-9]{4,5} ' | tr -d ' ' || true)
if [[ -n "$port" ]]; then
worked=true