Skip to content

Commit

Permalink
per #685, run pytests with markers to subset tests into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe committed Jul 7, 2022
1 parent 46104ba commit b509fee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/actions/run_tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi
#
# running unit tests (pytests)
#
if [ "$INPUT_CATEGORIES" == "pytests" ]; then
if [ "$INPUT_CATEGORIES" == pytests* ]; then
export METPLUS_ENV_TAG="pytest"
export METPLUS_IMG_TAG=${branch_name}
echo METPLUS_ENV_TAG=${METPLUS_ENV_TAG}
Expand All @@ -55,8 +55,9 @@ if [ "$INPUT_CATEGORIES" == "pytests" ]; then
-f .github/actions/run_tests/Dockerfile.run \
.

echo Running Pytests
command="export METPLUS_PYTEST_HOST=docker; cd internal_tests/pytests; /usr/local/envs/pytest/bin/pytest -vv --cov=../../metplus"
marker=`echo $INPUT_CATEGORIES | awk -F_ '{print $2}'`
echo Running Pytests marker=$marker
command="export METPLUS_PYTEST_HOST=docker; cd internal_tests/pytests; /usr/local/envs/pytest/bin/pytest -vv --cov=../../metplus -m $marker"
time_command docker run -v $WS_PATH:$GITHUB_WORKSPACE --workdir $GITHUB_WORKSPACE $RUN_TAG bash -c "$command"
exit $?
fi
Expand Down
10 changes: 8 additions & 2 deletions .github/jobs/get_use_cases_to_run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/bash

use_case_groups_filepath=.github/parm/use_case_groups.json
pytests_groups_filepath=.github/parm/pytest_groups.txt
# set matrix to string of an empty array in case no use cases will be run
matrix="[]"

Expand Down Expand Up @@ -31,12 +32,17 @@ fi
if [ "$run_unit_tests" == "true" ]; then
echo Adding unit tests to list to run

pytests=""
for x in `cat $pytests_groups_filepath`; do
pytests=$pytests"\"pytests_$x\","
done

# if matrix is empty, set to an array that only includes pytests
if [ "$matrix" == "[]" ]; then
matrix="[\"pytests\"]"
matrix="[${pytests:0: -1}]"
# otherwise prepend item to list
else
matrix="[\"pytests\", ${matrix:1}"
matrix="[${pytests}${matrix:1}"
fi
fi

Expand Down
2 changes: 2 additions & 0 deletions .github/parm/pytest_groups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wrapper
util
4 changes: 2 additions & 2 deletions internal_tests/pytests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
markers =
util
wrapper
util: custom marker for testing metplus/util logic
wrapper: custom marker for testing metplus/wrapper logic

0 comments on commit b509fee

Please sign in to comment.