Skip to content

Commit

Permalink
Merge pull request #314 from EpistasisLab/unit_test_runner_refactor
Browse files Browse the repository at this point in the history
Unit test runner refactor, Github Actions update
  • Loading branch information
hjwilli authored Feb 19, 2021
2 parents 352f8b8 + b2c1627 commit 4b237de
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 75 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/pennai_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
# Runs a set of commands using the runners shell
- name: Run Integration Tests
run: |
docker-compose -f ./docker-compose-int-test.yml run tester bash -c "sh /root/wait_pennai.sh && npm test"
docker-compose -f ./docker-compose-int-test.yml run tester bash -c "sh /root/wait_pennai.sh && npm test"
docker-compose -f ./docker-compose-int-test.yml down
# This workflow contains a single job called "build"
build_web_app:
name: Unit Tests for Webapp
Expand All @@ -44,29 +45,17 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: '3.7'



# Runs a single command using the runners shell
- name: Build Docker Images
run: |
pip install coveralls
docker-compose -f ./docker-compose-unit-test.yml build -m 8g
# Runs a set of commands using the runners shell
- name: Run Unit Tests
run: |
git lfs fetch --all
docker run -v $(pwd):/appsrc -w /appsrc pennai_unit_tester mocha machine/test/test.js
docker run -v $(pwd):/appsrc -v /appsrc/lab/webapp/node_modules -w /appsrc/lab/webapp/ pennai_unit_tester npm run test
docker run -v $(pwd):/appsrc -w /appsrc pennai_unit_tester \
coverage run -m nose -s -v \
machine/test/learn_tests.py \
lab/pyutils/tests/*.py \
ai/tests/test_a*.py \
ai/tests/lab_*.py \
ai/tests/test_re*.py \
ai/tests/test_k*utils.py
coverage combine
docker-compose -f ./docker-compose-unit-test.yml up --abort-on-container-exit -V
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
Expand Down Expand Up @@ -112,6 +101,7 @@ jobs:
parallel-finished: true

deploy_pypkg:
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
name: Deploy python package
needs: build_pypkg
# The type of runner that the job will run on
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/js_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# unit test runner for jest javascript tests

export JEST_JUNIT_OUTPUT_DIR="${REPORT_PATH}"

echo "starting '/lab' jest reports"
cd "/appsrc/lab/"
npm run test


echo "starting '/lab/webapp' jest reports"
cd "/appsrc/lab/webapp/"
npm run test
49 changes: 49 additions & 0 deletions tests/unit/py_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# unit test runner for python tests
REPORT_PATH="/appsrc/target/test-reports"
COVERAGE_PATH="/appsrc/target/test-reports/cobertura"
NOSE_LOG_PATH="/appsrc/target/test-reports/nose.log"


NOSE_TESTS="/appsrc/ai/tests/test_recommender.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/tests/test_ai.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/tests/test_ai_and_api_utils.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/tests/test_api_utils.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/tests/test_knowledgebase_utils.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/metalearning/tests/test_dataset_describe.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/ai/metalearning/tests/test_get_metafeatures.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/machine/test/learn_tests.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/lab/pyutils/tests/test_loadInitialDatasets.py"
NOSE_TESTS="${NOSE_TESTS} /appsrc/lab/pyutils/tests/test_validateDataset.py"
##NOSE_TESTS="${NOSE_TESTS} ai/tests/test_knowledgebase_utils_profile.py"

MOCHA_TESTS="/appsrc/machine/test/test.js"


rm -f "${REPORT_PATH}/nose_xunit.xml"
rm -f "${REPORT_PATH}/mocha_xunit.xml"
rm -drf "${COVERAGE_PATH}"

mkdir -p "${REPORT_PATH}/cobertura/html"
mkdir -p "${REPORT_PATH}/html"

echo "starting nosetest"
echo $NOSE_TESTS

coverage run -m nose -s \
--with-xunit --xunit-file="${REPORT_PATH}/nose_xunit.xml" \
--with-html --html-file="${REPORT_PATH}/html/nose.html" \
-v $NOSE_TESTS \
#--verbosity=4
#--verbosity=4 > $NOSE_LOG_PATH 2>&1

coverage combine
coverage html -d "${COVERAGE_PATH}/html"
coverage xml -o "${COVERAGE_PATH}/nose_cover.xml"

#echo "coverage erase"
#coverage erase

echo "starting mocha tests"
mocha --reporter xunit --reporter-options output="${REPORT_PATH}/mocha_xunit.xml" $MOCHA_TESTS
64 changes: 4 additions & 60 deletions tests/unit/unit_test_runner.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
#!/bin/bash

REPORT_PATH="/appsrc/target/test-reports"
COVERAGE_PATH="/appsrc/target/test-reports/cobertura"
NOSE_LOG_PATH="/appsrc/target/test-reports/nose.log"
dos2unix /appsrc/tests/unit/py_tests.sh
dos2unix /appsrc/tests/unit/js_tests.sh


NOSE_TESTS="ai/tests/test_recommender.py"
NOSE_TESTS="${NOSE_TESTS} ai/tests/test_ai.py"
NOSE_TESTS="${NOSE_TESTS} ai/tests/test_ai_and_api_utils.py"
NOSE_TESTS="${NOSE_TESTS} ai/tests/test_api_utils.py"
NOSE_TESTS="${NOSE_TESTS} ai/tests/test_knowledgebase_utils.py"
NOSE_TESTS="${NOSE_TESTS} ai/metalearning/tests/test_dataset_describe.py"
NOSE_TESTS="${NOSE_TESTS} ai/metalearning/tests/test_get_metafeatures.py"
NOSE_TESTS="${NOSE_TESTS} machine/test/learn_tests.py"
NOSE_TESTS="${NOSE_TESTS} lab/pyutils/tests/test_loadInitialDatasets.py"
NOSE_TESTS="${NOSE_TESTS} lab/pyutils/tests/test_validateDataset.py"
##NOSE_TESTS="${NOSE_TESTS} ai/tests/test_knowledgebase_utils_profile.py"

MOCHA_TESTS="machine/test/test.js"

rm -f "${REPORT_PATH}/nose_xunit.xml"
rm -f "${REPORT_PATH}/mocha_xunit.xml"
rm -drf "${COVERAGE_PATH}"

mkdir -p target/test-reports/cobertura/html
mkdir -p target/test-reports/html

echo "starting nosetest"
echo $NOSE_TESTS

coverage run -m nose -s \
--with-xunit --xunit-file="${REPORT_PATH}/nose_xunit.xml" \
--with-html --html-file="${REPORT_PATH}/html/nose.html" \
-v $NOSE_TESTS \
#--verbosity=4
#--verbosity=4 > $NOSE_LOG_PATH 2>&1

coverage combine
coverage html -d "${COVERAGE_PATH}/html"
coverage xml -o "${COVERAGE_PATH}/nose_cover.xml"

echo "coverage erase"
coverage erase

echo "starting mocha tests"
mocha --reporter xunit --reporter-options output="${REPORT_PATH}/mocha_xunit.xml" $MOCHA_TESTS


# jest tests
export JEST_JUNIT_OUTPUT_DIR="${REPORT_PATH}"

echo "starting lab jest reports"
cd "/appsrc/lab/"
npm run test


echo "starting webapp jest reports"
cd "/appsrc/lab/webapp/"
npm run test

# todo: check for generated files and potentially remove
# jest - snapshots, potentially use or disable
. /appsrc/tests/unit/py_tests.sh
. /appsrc/tests/unit/js_tests.sh

0 comments on commit 4b237de

Please sign in to comment.