Skip to content

Commit

Permalink
[STYLE] fix for shell lock file paths ( closes #6 + WIP on #27 )
Browse files Browse the repository at this point in the history
  • Loading branch information
reactive-firewall committed Mar 3, 2022
1 parent 0698978 commit 76eb88e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 29 deletions.
67 changes: 56 additions & 11 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
codecov:
max_report_age: off
max_report_age: off


coverage:
precision: 2
range: "80...100"
status:
project:
default:
target: auto
base: auto
branches:
- master
- stageing
- stable
if_ci_failed: error #success, failure, error, ignore
only_pulls: false
multicast:
target: 95%
threshold: 0%
Expand All @@ -17,16 +30,48 @@ coverage:
flags:
- unittests
paths:
- "tests/*"
- "tests/*.py"

flags:
unittests:
paths:
- "tests/*"
carryforward: true
joined: false
multicast:
paths:
- "multicast/*.py"
- "setup.py"

flag_management:
default_rules: # the rules that will be followed for any flag added, generally
carryforward: true
statuses:
- name_prefix: project-
type: project
target: auto
threshold: 1%
- name_prefix: patch-
type: patch
target: 90%
individual_flags: # exceptions to the default rules above, stated flag by flag
- name: multicast #fill in your own flag name
paths:
- multicast/*.py #fill in your own path. Note, accepts globs, not regexes
- setup.py
carryforward: true
statuses:
- name_prefix: new
type: project
target: 51%
- name_prefix: new
type: patch
target: 90%
- name: tests
paths:
- tests/* #fill in your own path. Note, accepts globs, not regexes
carryforward: true
- name: extras
joined: false
carryforward: true
- name: unittests
paths:
- tests/*.py #fill in your own path. Note, accepts globs, not regexes
carryforward: true
- name: macos-latest
carryforward: false
- name: linux-latest
carryforward: false
- name: windows-latest
carryforward: false
joined: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__/
*.py[cod]
*$py.class
*~
*/*~
./**/*~

# C extensions
*.so
Expand Down
29 changes: 18 additions & 11 deletions tests/check_cc_lines
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,31 @@ ulimit -t 600
PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
umask 137

LOCK_FILE="/tmp/cc_line_test_script_lock"
LOCK_FILE="${TMPDIR:-/tmp}/cc_line_test_script_lock"
EXIT_CODE=0

test -x $(command -v grep) || exit 126 ;
test -x $(command -v curl) || exit 126 ;
test -x $(command -v find) || exit 126 ;
test -x $(command -v git) || exit 126 ;

function cleanup() {
rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ;
}

if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGHUP || EXIT_CODE=3
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGTERM || EXIT_CODE=4
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGQUIT || EXIT_CODE=5
trap 'cleanup ; wait ; exit 1 ;' SIGHUP || EXIT_CODE=3
trap 'cleanup ; wait ; exit 1 ;' SIGTERM || EXIT_CODE=4
trap 'cleanup ; wait ; exit 1 ;' SIGQUIT || EXIT_CODE=5
# SC2173 - https://github.com/koalaman/shellcheck/wiki/SC2173
# trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGSTOP || EXIT_CODE=7
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGINT || EXIT_CODE=8
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit 1 ;' SIGABRT || EXIT_CODE=9
trap 'rm -f ${LOCK_FILE} 2>/dev/null || true ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
trap 'cleanup ; wait ; exit 1 ;' SIGINT || EXIT_CODE=8
trap 'cleanup ; wait ; exit 1 ;' SIGABRT || EXIT_CODE=9
trap 'cleanup ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
else
echo Test already in progress by `head ${LOCK_FILE}` ;
false ;
exit 126 ;
echo "Check for Copyright lines already in progress by "`head ${LOCK_FILE}` ;
false ;
exit 126 ;
fi

# this is how test files are found:
Expand All @@ -105,7 +112,7 @@ for _TEST_DOC in $(find ${_TEST_ROOT_DIR} \( -iname '*.py' -o -iname '*.txt' -o
EXIT_CODE=126
else
if [[ ($(grep -cF "Copyright" "${_TEST_DOC}" 2>&1 || EXIT_CODE=$? ;) -le 0) ]] ; then
echo "FAIL: ${_TEST_DOC} is missing a copyright line" ;
echo "FAIL: ${_TEST_DOC} is missing a copyright line" >&2 ;
EXIT_CODE=127
fi
if [[ ( $(grep -F "Copyright" "${_TEST_DOC}" 2>&1 | grep -coF "Copyright (c)" 2>&1) -le 0) ]] ; then
Expand Down
14 changes: 8 additions & 6 deletions tests/check_codecov
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ ulimit -t 1200
PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:${PATH}"
LANG=${LANG:-"en_US"}
LC_ALL="${LANG:1:5}.utf-8"
umask 027
umask 127

LOCK_FILE="/tmp/codecov_test_script_lock"
LOCK_FILE="${TMPDIR:-/tmp}/codecov_test_script_lock"
EXIT_CODE=0

test -x $(command -v grep) || exit 126 ;
test -x $(command -v curl) || exit 126 ;
test -x $(command -v gpgv) || exit 126 ;
test -x $(command -v shasum) || exit 126 ;

# sorry no windows support here
Expand All @@ -95,7 +96,7 @@ if [[ ( $(shlock -f ${LOCK_FILE} -p $$ ) -eq 0 ) ]] ; then
trap 'cleanup ; wait ; exit 1 ;' SIGABRT || EXIT_CODE=9
trap 'cleanup ; wait ; exit ${EXIT_CODE} ;' EXIT || EXIT_CODE=1
else
echo CodeCov already in progress by `head ${LOCK_FILE}` ;
echo "CodeCov already in progress by "`head ${LOCK_FILE}` ;
false ;
exit 126 ;
fi
Expand All @@ -113,7 +114,8 @@ else
EXIT_CODE=1
fi

# This File MUST BE GIT-IGNORED to be SAFELY USED to store Tokens and env vars (update logic as needed)
# This File MUST BE GIT-IGNORED
# to be SAFELY USED to store Tokens and env vars (update logic as needed)
if [[ ( -r ./codecov_env ) ]] ; then
source ./codecov_env 2>/dev/null || true ;
fi
Expand Down Expand Up @@ -161,14 +163,14 @@ elif [[ ( -x $(command -v coverage) ) ]] ; then
fi

if [[ ( ${EXIT_CODE} -eq 0 ) ]] ; then
./codecov -n "Custom Test Run" -X gcov -F ${CI_OS:-linux} || EXIT_CODE=5 ;
./codecov -n "Custom Test Run" -X gcov -F multicast,${CI_OS:-linux}-latest -Z || EXIT_CODE=10 ;
fi


unset _TEST_ROOT_DIR 2>/dev/null || true ;

rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ;
rm -f ./codecov 2>/dev/null > /dev/null || true ; wait ;
rm -f ${LOCK_FILE} 2>/dev/null > /dev/null || true ; wait ;

# goodbye
exit ${EXIT_CODE:-255} ;
2 changes: 1 addition & 1 deletion tests/check_spelling
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ulimit -t 600
PATH="/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
umask 137

LOCK_FILE="/tmp/spelling_test_script_lock"
LOCK_FILE="${TMPDIR:-/tmp}/spelling_test_script_lock"
EXIT_CODE=0

# exit fast if command is missing
Expand Down

0 comments on commit 76eb88e

Please sign in to comment.