From 67ed723dd9bf3972af05a1954b917769b1bae6cf Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:57:40 -0600 Subject: [PATCH 01/26] run pytest from GHA environment instead of through Use Case Test action and try to run coveralls to generate coverage report --- .github/actions/run_tests/entrypoint.sh | 31 ----------------------- .github/jobs/get_use_cases_to_run.sh | 17 ------------- .github/jobs/set_job_controls.sh | 3 ++- .github/workflows/testing.yml | 33 ++++++++++++++++++++----- internal/tests/pytests/.coveragerc | 2 ++ internal/tests/pytests/requirements.txt | 19 ++++++++++++++ 6 files changed, 50 insertions(+), 55 deletions(-) create mode 100644 internal/tests/pytests/.coveragerc create mode 100644 internal/tests/pytests/requirements.txt diff --git a/.github/actions/run_tests/entrypoint.sh b/.github/actions/run_tests/entrypoint.sh index 78ce25e08..732be6499 100644 --- a/.github/actions/run_tests/entrypoint.sh +++ b/.github/actions/run_tests/entrypoint.sh @@ -30,37 +30,6 @@ if [ $? != 0 ]; then ${GITHUB_WORKSPACE}/${CI_JOBS_DIR}/docker_setup.sh fi -# running unit tests (pytests) -if [[ "$INPUT_CATEGORIES" == pytests* ]]; then - export METPLUS_ENV_TAG="test.v5.1" - export METPLUS_IMG_TAG=${branch_name} - echo METPLUS_ENV_TAG=${METPLUS_ENV_TAG} - echo METPLUS_IMG_TAG=${METPLUS_IMG_TAG} - - export RUN_TAG=metplus-run-env - - # use BuildKit to build image - export DOCKER_BUILDKIT=1 - - start_seconds=$SECONDS - - # build an image with the pytest conda env and the METplus branch image - # Note: adding --build-arg without any value tells docker to - # use value from local environment (export METPLUS_IMG_TAG) - time_command docker build -t $RUN_TAG \ - --build-arg METPLUS_IMG_TAG \ - --build-arg METPLUS_ENV_TAG \ - -f .github/actions/run_tests/Dockerfile.run \ - . - - echo Running Pytests - command="export METPLUS_TEST_OUTPUT_BASE=/data/output;" - command+="/usr/local/conda/envs/${METPLUS_ENV_TAG}/bin/pytest internal/tests/pytests -vv --cov=metplus --cov-append --cov-report=term-missing;" - command+="if [ \$? != 0 ]; then echo ERROR: Some pytests failed. Search for FAILED to review; false; fi" - time_command docker run -v $WS_PATH:$GITHUB_WORKSPACE --workdir $GITHUB_WORKSPACE $RUN_TAG bash -c "$command" - exit $? -fi - # running use case tests # split apart use case category and subset list from input diff --git a/.github/jobs/get_use_cases_to_run.sh b/.github/jobs/get_use_cases_to_run.sh index 0d06a85df..d937f1f7a 100755 --- a/.github/jobs/get_use_cases_to_run.sh +++ b/.github/jobs/get_use_cases_to_run.sh @@ -7,11 +7,9 @@ matrix="[]" run_use_cases=$1 run_all_use_cases=$2 -run_unit_tests=$3 echo Run use cases: $run_use_cases echo Run all use cases: $run_all_use_cases -echo Run unit tests: $run_unit_tests # if running use cases, generate JQ filter to use if [ "$run_use_cases" == "true" ]; then @@ -28,21 +26,6 @@ if [ "$run_use_cases" == "true" ]; then fi -# if unit tests will be run, add "pytests" to beginning of matrix list -if [ "$run_unit_tests" == "true" ]; then - echo Adding unit tests to list to run - - pytests="\"pytests\"," - - # if matrix is empty, set to an array that only includes pytests - if [ "$matrix" == "[]" ]; then - matrix="[${pytests:0: -1}]" - # otherwise prepend item to list - else - matrix="[${pytests}${matrix:1}" - fi -fi - echo Array of groups to run is: $matrix # if matrix is still empty, exit 1 to fail step and skip rest of workflow if [ "$matrix" == "[]" ]; then diff --git a/.github/jobs/set_job_controls.sh b/.github/jobs/set_job_controls.sh index f03c4809a..032197ff4 100755 --- a/.github/jobs/set_job_controls.sh +++ b/.github/jobs/set_job_controls.sh @@ -87,6 +87,7 @@ fi echo "run_get_image=$run_get_image" >> $GITHUB_OUTPUT echo "run_get_input_data=$run_get_input_data" >> $GITHUB_OUTPUT echo "run_diff=$run_diff" >> $GITHUB_OUTPUT +echo "run_unit_tests=$run_unit_tests" >> $GITHUB_OUTPUT echo "run_save_truth_data=$run_save_truth_data" >> $GITHUB_OUTPUT echo "external_trigger=$external_trigger" >> $GITHUB_OUTPUT @@ -96,7 +97,7 @@ branch_name=`${GITHUB_WORKSPACE}/.github/jobs/print_branch_name.py` echo "branch_name=$branch_name" >> $GITHUB_OUTPUT # get use cases to run -.github/jobs/get_use_cases_to_run.sh $run_use_cases $run_all_use_cases $run_unit_tests +.github/jobs/get_use_cases_to_run.sh $run_use_cases $run_all_use_cases # echo output variables to review in logs echo branch_name: $branch_name diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index aff2d9a49..0f2cc13e9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -79,6 +79,7 @@ jobs: run_get_image: ${{ steps.job_status.outputs.run_get_image }} run_get_input_data: ${{ steps.job_status.outputs.run_get_input_data }} run_diff: ${{ steps.job_status.outputs.run_diff }} + run_unit_tests: ${{ steps.job_status.outputs.run_unit_tests }} run_save_truth_data: ${{ steps.job_status.outputs.run_save_truth_data }} external_trigger: ${{ steps.job_status.outputs.external_trigger }} branch_name: ${{ steps.job_status.outputs.branch_name }} @@ -87,7 +88,7 @@ jobs: name: Docker Setup - Get METplus Image runs-on: ubuntu-latest needs: job_control - if: ${{ needs.job_control.outputs.run_get_image == 'true' }} + if: ${{ needs.job_control.outputs.run_get_image == 'true' && needs.job_control.outputs.run_some_tests == 'true' }} steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -105,7 +106,7 @@ jobs: name: Docker Setup - Update Data Volumes runs-on: ubuntu-latest needs: job_control - if: ${{ needs.job_control.outputs.run_get_input_data == 'true' }} + if: ${{ needs.job_control.outputs.run_get_input_data == 'true' && needs.job_control.outputs.run_some_tests == 'true' }} continue-on-error: true steps: - uses: dtcenter/metplus-action-data-update@v2 @@ -121,6 +122,26 @@ jobs: use_feature_data: true tag_max_pages: 15 + unit_tests: + name: Unit Tests + runs-on: ubuntu-latest + needs: [job_control] + if: ${{ needs.job_control.outputs.run_unit_tests == 'true' }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' + - name: Install Python Test Dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r internal/tests/pytests/requirements.txt + - name: Run Pytests + run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing + - name: Run Coveralls + uses: AndreMiras/coveralls-python-action@v20201129 + use_case_tests: name: Use Case Tests runs-on: ubuntu-latest @@ -158,24 +179,24 @@ jobs: # copy logs with errors to error_logs directory to save as artifact - name: Save error logs id: save-errors - if: ${{ always() && steps.run_tests.conclusion == 'failure' && !startsWith(matrix.categories,'pytests') }} + if: ${{ always() && steps.run_tests.conclusion == 'failure' }} run: .github/jobs/save_error_logs.sh # run difference testing - name: Run difference tests id: run-diff - if: ${{ needs.job_control.outputs.run_diff == 'true' && steps.run_tests.conclusion == 'success' && !startsWith(matrix.categories,'pytests') }} + if: ${{ needs.job_control.outputs.run_diff == 'true' && steps.run_tests.conclusion == 'success' }} run: .github/jobs/run_difference_tests.sh ${{ matrix.categories }} ${{ steps.get-artifact-name.outputs.artifact_name }} # copy output data to save as artifact - name: Save output data id: save-output - if: ${{ always() && steps.run_tests.conclusion != 'skipped' && !startsWith(matrix.categories,'pytests') }} + if: ${{ always() && steps.run_tests.conclusion != 'skipped' }} run: .github/jobs/copy_output_to_artifact.sh ${{ steps.get-artifact-name.outputs.artifact_name }} - name: Upload output data artifact uses: actions/upload-artifact@v3 - if: ${{ always() && steps.run_tests.conclusion != 'skipped' && !startsWith(matrix.categories,'pytests') }} + if: ${{ always() && steps.run_tests.conclusion != 'skipped' }} with: name: ${{ steps.get-artifact-name.outputs.artifact_name }} path: artifact/${{ steps.get-artifact-name.outputs.artifact_name }} diff --git a/internal/tests/pytests/.coveragerc b/internal/tests/pytests/.coveragerc new file mode 100644 index 000000000..4edd7b1a2 --- /dev/null +++ b/internal/tests/pytests/.coveragerc @@ -0,0 +1,2 @@ +[run] +relative_files = True diff --git a/internal/tests/pytests/requirements.txt b/internal/tests/pytests/requirements.txt new file mode 100644 index 000000000..0a4449537 --- /dev/null +++ b/internal/tests/pytests/requirements.txt @@ -0,0 +1,19 @@ +certifi==2023.7.22 +cftime==1.6.2 +coverage==7.2.7 +exceptiongroup==1.1.2 +iniconfig==2.0.0 +netCDF4==1.6.4 +numpy==1.25.2 +packaging==23.1 +pandas==2.0.3 +pdf2image==1.16.3 +Pillow==10.0.0 +pluggy==1.2.0 +pytest==7.4.0 +pytest-cov==4.1.0 +python-dateutil==2.8.2 +pytz==2023.3 +six==1.16.0 +tomli==2.0.1 +tzdata==2023.3 From 51588cb9ee941fcae19d2bca604db3bb01cc71b1 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:52:00 -0600 Subject: [PATCH 02/26] set env var needed to run pytests --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0f2cc13e9..97fe391cd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -139,6 +139,8 @@ jobs: python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing + env: + METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls uses: AndreMiras/coveralls-python-action@v20201129 From 952dc15b407cbe172c6f673f3c8a5de0e1beb1c2 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:03:32 -0600 Subject: [PATCH 03/26] add lcov report --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 97fe391cd..05029c4fe 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing + run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-report lcov env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From 57c45f9e96a1c7a126964e2e38f5af6d4c53965d Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:09:54 -0600 Subject: [PATCH 04/26] pass coverage config file to pytest command --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 05029c4fe..b7d457430 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-report lcov + run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From 4bda6d908c3bebcb1f0a76b53f1dc5503f6b6525 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:46:14 -0600 Subject: [PATCH 05/26] pass github token --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b7d457430..84f5f8ba9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -143,6 +143,8 @@ jobs: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls uses: AndreMiras/coveralls-python-action@v20201129 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} use_case_tests: name: Use Case Tests From 18d0fe267594971733ee2ac16e3bfdd36efd7a1b Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:20:07 -0600 Subject: [PATCH 06/26] call coverage to run pytests --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 84f5f8ba9..9cca5adc3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc + run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From 3a4211ff7d81f050e8dfe93434b2efaf23741e90 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:25:41 -0600 Subject: [PATCH 07/26] try running with lcov output --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9cca5adc3..228a8e0c1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc + run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc --cov-report lcov env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From d4a2c560868ea6f0d219c96263d067c1f5838467 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:25:54 -0600 Subject: [PATCH 08/26] moved file back to top level --- internal/tests/pytests/.coveragerc => .coveragerc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename internal/tests/pytests/.coveragerc => .coveragerc (100%) diff --git a/internal/tests/pytests/.coveragerc b/.coveragerc similarity index 100% rename from internal/tests/pytests/.coveragerc rename to .coveragerc From cc1e6402737ce4d9bea6d058b7a69ae01ff731be Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:40:27 -0600 Subject: [PATCH 09/26] use better shell syntax --- .github/actions/run_tests/entrypoint.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/actions/run_tests/entrypoint.sh b/.github/actions/run_tests/entrypoint.sh index 732be6499..eecb719a2 100644 --- a/.github/actions/run_tests/entrypoint.sh +++ b/.github/actions/run_tests/entrypoint.sh @@ -12,7 +12,7 @@ source ${GITHUB_WORKSPACE}/${CI_JOBS_DIR}/bash_functions.sh # get branch name for push or pull request events # add -pull_request if pull request event to keep separated -branch_name=`${GITHUB_WORKSPACE}/${CI_JOBS_DIR}/print_branch_name.py` +branch_name=$(${GITHUB_WORKSPACE}/${CI_JOBS_DIR}/print_branch_name.py) if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then branch_name=${branch_name}-pull_request fi @@ -23,8 +23,7 @@ time_command docker pull $DOCKERHUBTAG # if unsuccessful (i.e. pull request from a fork) # then build image locally -docker inspect --type=image $DOCKERHUBTAG > /dev/null -if [ $? != 0 ]; then +if ! docker inspect --type=image $DOCKERHUBTAG > /dev/null; then # if docker pull fails, build locally echo docker pull failed. Building Docker image locally... ${GITHUB_WORKSPACE}/${CI_JOBS_DIR}/docker_setup.sh @@ -33,8 +32,8 @@ fi # running use case tests # split apart use case category and subset list from input -CATEGORIES=`echo $INPUT_CATEGORIES | awk -F: '{print $1}'` -SUBSETLIST=`echo $INPUT_CATEGORIES | awk -F: '{print $2}'` +CATEGORIES=$(echo $INPUT_CATEGORIES | awk -F: '{print $1}') +SUBSETLIST=$(echo $INPUT_CATEGORIES | awk -F: '{print $2}') # run all cases if no subset list specified if [ -z "${SUBSETLIST}" ]; then @@ -42,7 +41,7 @@ if [ -z "${SUBSETLIST}" ]; then fi # get METviewer if used in any use cases -all_requirements=`./${CI_JOBS_DIR}/get_requirements.py ${CATEGORIES} ${SUBSETLIST}` +all_requirements=$(./${CI_JOBS_DIR}/get_requirements.py ${CATEGORIES} ${SUBSETLIST}) echo All requirements: $all_requirements NETWORK_ARG="" if [[ "$all_requirements" =~ .*"metviewer".* ]]; then From 4e505bead101748611a454c437d4d0c9e59e4e27 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:40:38 -0600 Subject: [PATCH 10/26] try again --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 228a8e0c1..8973c4305 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-config=.coveragerc --cov-report lcov + run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From af996997ac0eb585c4f9241a0916eb1b4d909a9c Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:45:33 -0600 Subject: [PATCH 11/26] run debug --- .github/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8973c4305..59c19827d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -145,6 +145,7 @@ jobs: uses: AndreMiras/coveralls-python-action@v20201129 with: github-token: ${{ secrets.GITHUB_TOKEN }} + debug: true use_case_tests: name: Use Case Tests From a2ba6b74560b224dd23c3231d9228fd5b9797d57 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:49:20 -0600 Subject: [PATCH 12/26] remove token and test if git is available --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 59c19827d..a95228a3e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -141,10 +141,10 @@ jobs: run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output + - run: git config - name: Run Coveralls uses: AndreMiras/coveralls-python-action@v20201129 with: - github-token: ${{ secrets.GITHUB_TOKEN }} debug: true use_case_tests: From bdd14557b787eab9a621cf1c61f66c72b4c4e4b6 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:52:50 -0600 Subject: [PATCH 13/26] remove git test --- .github/workflows/testing.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a95228a3e..ef1bc59fc 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -141,7 +141,6 @@ jobs: run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - - run: git config - name: Run Coveralls uses: AndreMiras/coveralls-python-action@v20201129 with: From 060e08cd607c24517073a6e160b41c0a2ba06990 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:55:32 -0600 Subject: [PATCH 14/26] try develop versiong --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ef1bc59fc..eaf71fad6 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -142,7 +142,7 @@ jobs: env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls - uses: AndreMiras/coveralls-python-action@v20201129 + uses: AndreMiras/coveralls-python-action@develop with: debug: true From e258e271b454f670a8db086e482459c2bcc763b3 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:01:04 -0600 Subject: [PATCH 15/26] add token using dev --- .github/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index eaf71fad6..4c6d32e20 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -144,6 +144,7 @@ jobs: - name: Run Coveralls uses: AndreMiras/coveralls-python-action@develop with: + github-token: ${{ secrets.GITHUB_TOKEN }} debug: true use_case_tests: From feb6b88313bf8f5ccd4df0c01c419c39cfae0c5b Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:06:11 -0600 Subject: [PATCH 16/26] try with lcov --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 4c6d32e20..2b6a17900 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,7 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing + run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-report lcov env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From c4f3caff749e7e48cd4e30b272269b180f1d10f7 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:14:03 -0600 Subject: [PATCH 17/26] set source in coverage config --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 4edd7b1a2..d561722b1 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,3 @@ [run] relative_files = True +source = metplus From 4597024accb8f1e326008f65c3418bd640b86456 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:23:54 -0600 Subject: [PATCH 18/26] run coverage then generate report --- .github/workflows/testing.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2b6a17900..f2f116cfd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,7 +138,9 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: coverage run -m pytest internal/tests/pytests --cov=metplus --cov-report=term-missing --cov-report lcov + run: | + coverage run -m pytest internal/tests/pytests + coverage report -m env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Run Coveralls From 2977a3b2ed039354b8d905bc27a013f822c11315 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:29:14 -0600 Subject: [PATCH 19/26] split pytest run and coverage report into separate steps to catch failure if any tests fail --- .github/workflows/testing.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f2f116cfd..df6d4f59f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -138,16 +138,15 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r internal/tests/pytests/requirements.txt - name: Run Pytests - run: | - coverage run -m pytest internal/tests/pytests - coverage report -m + run: coverage run -m pytest internal/tests/pytests env: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output + - name: Generate coverage report + run: coverage report -m - name: Run Coveralls uses: AndreMiras/coveralls-python-action@develop with: github-token: ${{ secrets.GITHUB_TOKEN }} - debug: true use_case_tests: name: Use Case Tests From c83575f5264653980530966200f52402defd3540 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:30:10 -0600 Subject: [PATCH 20/26] force tests to fall to ensure that failure is properly captured --- .../tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py b/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py index 80dfe6117..db29500a0 100644 --- a/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py +++ b/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py @@ -89,7 +89,7 @@ def set_minimum_config_settings(config): ) @pytest.mark.wrapper_b def test_grid_stat_is_prob(metplus_config, config_overrides, expected_values): - + assert False config = metplus_config set_minimum_config_settings(config) From 0d354c06de4474351797ace02808c73f3226d080 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:38:58 -0600 Subject: [PATCH 21/26] generate coverage report even if a test fails --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index df6d4f59f..ba6fd4b45 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -143,8 +143,10 @@ jobs: METPLUS_TEST_OUTPUT_BASE: ${{ runner.workspace }}/pytest_output - name: Generate coverage report run: coverage report -m + if: always() - name: Run Coveralls uses: AndreMiras/coveralls-python-action@develop + if: always() with: github-token: ${{ secrets.GITHUB_TOKEN }} From 09a1317d9dc89a91e997264f8f9ef3ebc03de654 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:49:48 -0600 Subject: [PATCH 22/26] require unit tests to pass to run use case tests --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ba6fd4b45..148d3de5b 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -153,7 +153,7 @@ jobs: use_case_tests: name: Use Case Tests runs-on: ubuntu-latest - needs: [get_image, update_data_volumes, job_control] + needs: [get_image, update_data_volumes, job_control, unit_tests] if: ${{ needs.job_control.outputs.run_some_tests == 'true' }} strategy: fail-fast: false From 6f6924947247eef9cd75b09b4367f74e4a88cb2e Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:49:58 -0600 Subject: [PATCH 23/26] turn on use case group to test --- .github/parm/use_case_groups.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/parm/use_case_groups.json b/.github/parm/use_case_groups.json index e8cc31f58..9ba895754 100644 --- a/.github/parm/use_case_groups.json +++ b/.github/parm/use_case_groups.json @@ -122,7 +122,7 @@ { "category": "pbl", "index_list": "0", - "run": false + "run": true }, { "category": "precipitation", From 3aa3c6e1f851ee7fb304f9d1ed90e0564b7eb9ec Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:53:11 -0600 Subject: [PATCH 24/26] remove force failure of unit test to test that use case will run --- .../tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py b/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py index db29500a0..c971c44ff 100644 --- a/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py +++ b/internal/tests/pytests/wrappers/grid_stat/test_grid_stat_wrapper.py @@ -89,7 +89,6 @@ def set_minimum_config_settings(config): ) @pytest.mark.wrapper_b def test_grid_stat_is_prob(metplus_config, config_overrides, expected_values): - assert False config = metplus_config set_minimum_config_settings(config) From ca2eb5f688e4ea32441aad5910efe915d57944e3 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:06:01 -0600 Subject: [PATCH 25/26] turn off use case after test --- .github/parm/use_case_groups.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/parm/use_case_groups.json b/.github/parm/use_case_groups.json index 9ba895754..e8cc31f58 100644 --- a/.github/parm/use_case_groups.json +++ b/.github/parm/use_case_groups.json @@ -122,7 +122,7 @@ { "category": "pbl", "index_list": "0", - "run": true + "run": false }, { "category": "precipitation", From 109316a0326c0ea895ea8539e83402a17f0e073f Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:03:25 -0600 Subject: [PATCH 26/26] move helper script that is only used internally to internals directory --- docs/Contributors_Guide/basic_components.rst | 6 +++--- .../scripts/dev_tools/add_met_config_helper.py | 9 ++++++--- metplus/util/__init__.py | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) rename metplus/util/doc_util.py => internal/scripts/dev_tools/add_met_config_helper.py (97%) diff --git a/docs/Contributors_Guide/basic_components.rst b/docs/Contributors_Guide/basic_components.rst index c386c03f7..441bb9320 100644 --- a/docs/Contributors_Guide/basic_components.rst +++ b/docs/Contributors_Guide/basic_components.rst @@ -252,13 +252,13 @@ used to easily add support for overriding MET configuration variables that were not previously supported in METplus configuration files. There is a utility that can be used to easily see what changes are needed to -add support for a new variable. The doc_util.py script can be run from the +add support for a new variable. The add_met_config_helper.py script can be run from the command line to output a list of instructions to add new support. It can be run from the top level of the METplus repository. The script can be called to add a single MET configuration variable by supplying the MET tool name and the variable name:: - ./metplus/util/doc_util.py point_stat sid_exc + ./internal/scripts/dev_tools/add_met_config_helper.py point_stat sid_exc This command will provide guidance for adding support for the sid_exc variable found in the PointStatConfig file. @@ -266,7 +266,7 @@ found in the PointStatConfig file. The script can also be called with the name of a dictionary and the names of each dictionary variable:: - ./metplus/util/doc_util.py grid_stat distance_map baddeley_p baddeley_max_dist fom_alpha zhu_weight beta_value_n + ./internal/scripts/dev_tools/add_met_config_helper.py grid_stat distance_map baddeley_p baddeley_max_dist fom_alpha zhu_weight beta_value_n This command will provide guidance for adding support for the distance_map dictionary found in the GridStatConfig file. The list of variables found inside diff --git a/metplus/util/doc_util.py b/internal/scripts/dev_tools/add_met_config_helper.py similarity index 97% rename from metplus/util/doc_util.py rename to internal/scripts/dev_tools/add_met_config_helper.py index 05b826949..6cd8faaef 100755 --- a/metplus/util/doc_util.py +++ b/internal/scripts/dev_tools/add_met_config_helper.py @@ -11,10 +11,13 @@ import os try: - from .string_manip import get_wrapper_name + from metplus.util.string_manip import get_wrapper_name except ImportError: - sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) - from string_manip import get_wrapper_name + # if metplus package is not installed, find util relative to this script + metplus_home = os.path.join(os.path.dirname(__file__), + os.pardir, os.pardir, os.pardir) + sys.path.insert(0, os.path.abspath(metplus_home)) + from metplus.util.string_manip import get_wrapper_name SCRIPT_INFO_TEXT = ( 'This script is intended to help developers add support for setting ' diff --git a/metplus/util/__init__.py b/metplus/util/__init__.py index 752469810..b5e7eeb8a 100644 --- a/metplus/util/__init__.py +++ b/metplus/util/__init__.py @@ -7,7 +7,6 @@ from .config_util import * from .config_metplus import * from .config_validate import * -from .doc_util import * from .run_util import * from .met_config import * from .time_looping import *