-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split test scripts in two: - `demo` module installation - stubs generation/check - Generate `.patch` artifacts on failed CI jobs
- Loading branch information
Showing
4 changed files
with
88 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,3 +209,4 @@ cython_debug/ | |
|
||
|
||
tmp | ||
*.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
function parse_args() { | ||
|
||
CLEAR='\033[0m' | ||
RED='\033[0;31m' | ||
|
||
function usage() { | ||
if [ -n "$1" ]; then | ||
echo -e "${RED}👉 $1${CLEAR}\n"; | ||
fi | ||
echo "Usage: $0 --stubs-sub-dir STUBS_SUB_DIR" | ||
echo " --stubs-sub-dir stubs output dir relative to this script directory" | ||
exit 1 | ||
} | ||
|
||
# parse params | ||
while [[ "$#" > 0 ]]; do case $1 in | ||
--stubs-sub-dir) STUBS_SUB_DIR="$2";shift;shift;; | ||
*) usage "Unknown parameter passed: $1"; shift; shift;; | ||
esac; done | ||
|
||
# verify params | ||
if [ -z "$STUBS_SUB_DIR" ]; then usage "STUBS_SUB_DIR is not set"; fi; | ||
|
||
TESTS_ROOT="$(readlink -m "$(dirname "$0")")" | ||
STUBS_DIR=$(readlink -m "${TESTS_ROOT}/${STUBS_SUB_DIR}") | ||
} | ||
|
||
remove_stubs() { | ||
rm -rf "${STUBS_DIR}/*" ; | ||
} | ||
|
||
run_stubgen() { | ||
pybind11-stubgen \ | ||
demo \ | ||
--output-dir=${STUBS_DIR} \ | ||
--numpy-array-wrap-with-annotated-fixed-size \ | ||
--ignore-invalid-expressions="\(anonymous namespace\)::(Enum|Unbound)" \ | ||
--ignore-unresolved-names="typing\.Annotated" \ | ||
--exit-code | ||
} | ||
|
||
format_stubs() { | ||
( | ||
cd "${STUBS_DIR}" ; | ||
black . ; | ||
isort --profile=black . ; | ||
) | ||
} | ||
|
||
check_stubs() { | ||
git add --all "${STUBS_DIR}" ; | ||
( | ||
set -o pipefail ; | ||
git diff --exit-code HEAD -- "${STUBS_DIR}" | tee "${STUBS_DIR}.patch" ; | ||
) | ||
} | ||
|
||
main () { | ||
parse_args "$@" | ||
remove_stubs | ||
run_stubgen | ||
format_stubs | ||
check_stubs | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters