Skip to content

Commit

Permalink
run pytests from top directory and generate code coverage report to s…
Browse files Browse the repository at this point in the history
…end to SonarQube server
  • Loading branch information
georgemccabe committed Jun 14, 2024
1 parent 59e1dee commit 7303519
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
relative_files = True
29 changes: 29 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,35 @@ jobs:
# Disable shallow clones for better analysis
fetch-depth: 0

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Retrieve METcalcpy repository develop branch
run: |
/usr/bin/git clone https://github.com/dtcenter/METcalcpy
cd METcalcpy
/usr/bin/git checkout develop
python -m pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install pytest-cov
- name: Run Pytests
run: coverage run -m pytest

- name: Output coverage report
run: coverage report -m
if: always()

- name: Generate XML coverage report
run: coverage xml
if: always()

- name: Get branch name
id: get_branch_name
run: echo branch_name=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT
Expand Down
37 changes: 1 addition & 36 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,8 @@ jobs:
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# id: extract_branch


- name: Test with pytest
run: |
cd test
cd bar
pytest test_bar.py
cd ../box
pytest test_box.py
cd ../contour
pytest test_contour.py
cd ../eclv
pytest test_eclv.py
cd ../ens_ss
pytest test_ens_ss.py
cd ../equivalence_testing_bounds
pytest test_equivalence_testing_bounds.py
cd ../line
pytest test_line_groups_plot.py
pytest test_line_plot.py
cd ../mpr_plot
pytest test_mpr_plot.py
cd ../performance_diagram
pytest test_performance_diagram.py
cd ../reliability_diagram
pytest test_reliability_diagram.py
cd ../roc_diagram
pytest test_roc_diagram.py
cd ../taylor_diagram
pytest test_taylor_diagram.py
cd ../wind_rose
pytest test_wind_rose.py
cd ../histogram
pytest test_prob_hist.py
pytest test_rank_hist.py
pytest test_rel_hist.py
cd ../tcmpr_plots
pytest --capture=fd test_tcmpr_plots.py
run: pytest



1 change: 1 addition & 0 deletions internal/scripts/sonarqube/sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sonar.projectVersion=SONAR_PROJECT_VERSION
sonar.branch.name=SONAR_BRANCH_NAME
sonar.sources=metplotpy,test
sonar.coverage.exclusions=test/**
sonar.python.coverage.reportPaths=coverage.xml
sonar.sourceEncoding=UTF-8

# SonarQube server
Expand Down

0 comments on commit 7303519

Please sign in to comment.