Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change codecov from master to main #585

Merged
merged 27 commits into from
Nov 21, 2023
Merged

Change codecov from master to main #585

merged 27 commits into from
Nov 21, 2023

Conversation

GernotMaier
Copy link
Contributor

@GernotMaier GernotMaier commented Aug 31, 2023

Code coverage was shown incorrectly and pointed to the 'old' master branch. Changed it to main and the coverage seems to be correct.

For review, please open the readme of the branch and looked at the badge: https://github.com/gammasim/simtools/tree/code-coverage-badge#readme

Code coverage was shown incorrectly and pointed to the 'old' master branch. Changed it to main and the coverage seems to be correct.
@GernotMaier GernotMaier requested a review from orelgueta August 31, 2023 12:17
@GernotMaier GernotMaier self-assigned this Aug 31, 2023
@GernotMaier GernotMaier linked an issue Aug 31, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bf0e8c7) 99.31% compared to head (9d060dc) 69.28%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #585       +/-   ##
===========================================
- Coverage   99.31%   69.28%   -30.03%     
===========================================
  Files          39       62       +23     
  Lines        3485     7244     +3759     
===========================================
+ Hits         3461     5019     +1558     
- Misses         24     2225     +2201     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@orelgueta
Copy link
Contributor

The change itself seems fine but our coverage is not really 99%, it is 87% now (see printout below from pytest). Should we look into it or merge this and figure it out later?

---------- coverage: platform linux, python 3.10.7-final-0 -----------
Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
simtools/__init__.py                                                  5      0   100%
simtools/_version.py                                                  2      0   100%
simtools/camera_efficiency.py                                       180     79    56%
simtools/configuration/__init__.py                                    0      0   100%
simtools/configuration/commandline_parser.py                        112     11    90%
simtools/configuration/configurator.py                              145     42    71%
simtools/corsika/__init__.py                                          0      0   100%
simtools/corsika/corsika_config.py                                  215      4    98%
simtools/corsika/corsika_histograms.py                              475     11    98%
simtools/corsika/corsika_histograms_visualize.py                    114      6    95%
simtools/corsika/corsika_runner.py                                  165     18    89%
simtools/corsika_simtel/__init__.py                                   0      0   100%
simtools/corsika_simtel/corsika_simtel_runner.py                     51      0   100%
simtools/data_model/__init__.py                                       0      0   100%
simtools/data_model/metadata_collector.py                           119      7    94%
simtools/data_model/metadata_model.py                                52      0   100%
simtools/data_model/model_data_writer.py                             48      2    96%
simtools/data_model/validate_data.py                                198     34    83%
simtools/data_model/validate_schema.py                               92      3    97%
simtools/db_handler.py                                              412    109    74%
simtools/io_handler.py                                               52      3    94%
simtools/job_execution/__init__.py                                    0      0   100%
simtools/job_execution/job_manager.py                                88     41    53%
simtools/layout/__init__.py                                           0      0   100%
simtools/layout/layout_array.py                                     343     57    83%
simtools/layout/telescope_position.py                               150     24    84%
simtools/model/__init__.py                                            0      0   100%
simtools/model/array_model.py                                       142     18    87%
simtools/model/camera.py                                            268    159    41%
simtools/model/mirrors.py                                            77     28    64%
simtools/model/model_utils.py                                        50     24    52%
simtools/model/telescope_model.py                                   304     57    81%
simtools/psf_analysis.py                                            167     72    57%
simtools/ray_tracing.py                                             180    122    32%
simtools/simtel/__init__.py                                           0      0   100%
simtools/simtel/simtel_config_writer.py                              78     11    86%
simtools/simtel/simtel_events.py                                    110     11    90%
simtools/simtel/simtel_histograms.py                                100     13    87%
simtools/simtel/simtel_runner.py                                     96     30    69%
simtools/simtel/simtel_runner_array.py                               97     15    85%
simtools/simtel/simtel_runner_camera_efficiency.py                   79      4    95%
simtools/simtel/simtel_runner_ray_tracing.py                         99     16    84%
simtools/simulator.py                                               273     17    94%
simtools/utils/__init__.py                                            0      0   100%
simtools/utils/general.py                                           345      0   100%
simtools/utils/names.py                                             162     27    83%
simtools/version.py                                                  11      5    55%
simtools/visualization/__init__.py                                    0      0   100%
simtools/visualization/legend_handlers.py                           111     37    67%
simtools/visualization/visualize.py                                 224     66    71%
tests/conftest.py                                                   109      3    97%
tests/unit_tests/__init__.py                                          2      0   100%
tests/unit_tests/configuration/test_commandline_parser.py            56      3    95%
tests/unit_tests/configuration/test_configurator.py                 137      0   100%
tests/unit_tests/corsika/test_corsika_config.py                     116      5    96%
tests/unit_tests/corsika/test_corsika_histograms.py                 363      5    99%
tests/unit_tests/corsika/test_corsika_histograms_visualize.py        66      4    94%
tests/unit_tests/corsika/test_corsika_runner.py                      84      0   100%
tests/unit_tests/corsika_simtel/test_corsika_simtel_runner.py        96      0   100%
tests/unit_tests/data_model/test_metadata_collector.py              118      0   100%
tests/unit_tests/data_model/test_metadata_model.py                   30      0   100%
tests/unit_tests/data_model/test_model_data_writer.py                32      0   100%
tests/unit_tests/data_model/test_validate_data.py                   194      0   100%
tests/unit_tests/data_model/test_validate_schema.py                 131      1    99%
tests/unit_tests/job_execution/test_job_manager.py                   13      0   100%
tests/unit_tests/layout/test_layout_array.py                        228      0   100%
tests/unit_tests/layout/test_telescope_position.py                  188      0   100%
tests/unit_tests/model/test_array_model.py                           18      0   100%
tests/unit_tests/model/test_camera_model.py                          13      0   100%
tests/unit_tests/model/test_mirrors.py                               15      0   100%
tests/unit_tests/model/test_telescope_model.py                      137      0   100%
tests/unit_tests/simtel/test_simtel_config_writer.py                 23      0   100%
tests/unit_tests/simtel/test_simtel_events.py                        36      0   100%
tests/unit_tests/simtel/test_simtel_histograms.py                    12      0   100%
tests/unit_tests/simtel/test_simtel_runner.py                        15      0   100%
tests/unit_tests/simtel/test_simtel_runner_array.py                  50      0   100%
tests/unit_tests/simtel/test_simtel_runner_camera_efficiency.py      32      0   100%
tests/unit_tests/simtel/test_simtel_runner_ray_tracing.py            38      0   100%
tests/unit_tests/test_camera_efficiency.py                           56      2    96%
tests/unit_tests/test_db_handler.py                                 146      7    95%
tests/unit_tests/test_io_handler.py                                  28      0   100%
tests/unit_tests/test_psf_analysis.py                                11      0   100%
tests/unit_tests/test_ray_tracing.py                                 24      0   100%
tests/unit_tests/test_simulator.py                                  189      0   100%
tests/unit_tests/utils/test_general.py                              374     10    97%
tests/unit_tests/utils/test_names.py                                 42      0   100%
tests/unit_tests/visualization/test_legend_handlers.py               19      0   100%
tests/unit_tests/visualization/test_visualize.py                     78      2    97%
-------------------------------------------------------------------------------------
TOTAL                                                              9310   1225    87%

@orelgueta
Copy link
Contributor

By the way, our actual coverage, calculated using pytest and including the integration tests in the calculation is 92%, which is really good. This is after a few additions which will be included in a small PR soon, but they are not that significant.

pytest -vv -n auto tests/unit_tests/ tests/integration_tests/ --cov

---------- coverage: platform linux, python 3.10.7-final-0 -----------
Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
/etc/python3.10/sitecustomize.py                                      5      1    80%
simtools/__init__.py                                                  5      0   100%
simtools/_version.py                                                  2      0   100%
simtools/applications/__init__.py                                     0      0   100%
simtools/applications/add_file_to_db.py                              49     10    80%
simtools/applications/compare_cumulative_psf.py                      67      4    94%
simtools/applications/derive_mirror_rnda.py                         107     10    91%
simtools/applications/generate_corsika_histograms.py                 93     11    88%
simtools/applications/get_file_from_db.py                            28      4    86%
simtools/applications/get_parameter.py                               23      2    91%
simtools/applications/make_regular_arrays.py                         48      1    98%
simtools/applications/plot_layout_array.py                           64      3    95%
simtools/applications/plot_simtel_histograms.py                      48     34    29%
simtools/applications/print_array_elements.py                        27      1    96%
simtools/applications/produce_array_config.py                        17      1    94%
simtools/applications/production.py                                  77      5    94%
simtools/applications/sim_showers_for_trigger_rates.py               45      2    96%
simtools/applications/submit_data_from_external.py                   24      1    96%
simtools/applications/tune_psf.py                                   107      2    98%
simtools/applications/validate_camera_efficiency.py                  40      1    98%
simtools/applications/validate_camera_fov.py                         43      6    86%
simtools/applications/validate_optics.py                             54     12    78%
simtools/applications/validate_schema_files.py                       41     10    76%
simtools/camera_efficiency.py                                       180     13    93%
simtools/configuration/__init__.py                                    0      0   100%
simtools/configuration/commandline_parser.py                        112      4    96%
simtools/configuration/configurator.py                              144     11    92%
simtools/corsika/__init__.py                                          0      0   100%
simtools/corsika/corsika_config.py                                  215      3    99%
simtools/corsika/corsika_histograms.py                              508     12    98%
simtools/corsika/corsika_histograms_visualize.py                    114      5    96%
simtools/corsika/corsika_runner.py                                  165     18    89%
simtools/corsika_simtel/__init__.py                                   0      0   100%
simtools/corsika_simtel/corsika_simtel_runner.py                     51      0   100%
simtools/data_model/__init__.py                                       0      0   100%
simtools/data_model/metadata_collector.py                           119      7    94%
simtools/data_model/metadata_model.py                                52      0   100%
simtools/data_model/model_data_writer.py                             48      0   100%
simtools/data_model/validate_data.py                                198     20    90%
simtools/data_model/validate_schema.py                               92      3    97%
simtools/db_handler.py                                              412    108    74%
simtools/io_handler.py                                               52      3    94%
simtools/job_execution/__init__.py                                    0      0   100%
simtools/job_execution/job_manager.py                                88     39    56%
simtools/layout/__init__.py                                           0      0   100%
simtools/layout/layout_array.py                                     343     40    88%
simtools/layout/telescope_position.py                               150     11    93%
simtools/model/__init__.py                                            0      0   100%
simtools/model/array_model.py                                       142     18    87%
simtools/model/camera.py                                            268     39    85%
simtools/model/mirrors.py                                            77     10    87%
simtools/model/model_utils.py                                        50      9    82%
simtools/model/telescope_model.py                                   304     35    88%
simtools/psf_analysis.py                                            172     40    77%
simtools/ray_tracing.py                                             191     26    86%
simtools/simtel/__init__.py                                           0      0   100%
simtools/simtel/simtel_config_writer.py                              78      0   100%
simtools/simtel/simtel_events.py                                    110     11    90%
simtools/simtel/simtel_histograms.py                                100     13    87%
simtools/simtel/simtel_runner.py                                     96     18    81%
simtools/simtel/simtel_runner_array.py                               97     15    85%
simtools/simtel/simtel_runner_camera_efficiency.py                   79      2    97%
simtools/simtel/simtel_runner_ray_tracing.py                         99      0   100%
simtools/simulator.py                                               273     17    94%
simtools/utils/__init__.py                                            0      0   100%
simtools/utils/general.py                                           345      0   100%
simtools/utils/names.py                                             172     23    87%
simtools/version.py                                                  11      5    55%
simtools/visualization/__init__.py                                    0      0   100%
simtools/visualization/legend_handlers.py                           111     29    74%
simtools/visualization/visualize.py                                 224     21    91%
tests/conftest.py                                                   113      3    97%
tests/integration_tests/test_applications.py                         46      3    93%
tests/integration_tests/test_ray_tracing.py                          88      0   100%
tests/unit_tests/__init__.py                                          2      0   100%
tests/unit_tests/configuration/test_commandline_parser.py            56      3    95%
tests/unit_tests/configuration/test_configurator.py                 137      0   100%
tests/unit_tests/corsika/test_corsika_config.py                     116      5    96%
tests/unit_tests/corsika/test_corsika_histograms.py                 369      5    99%
tests/unit_tests/corsika/test_corsika_histograms_visualize.py        66      4    94%
tests/unit_tests/corsika/test_corsika_runner.py                      84      0   100%
tests/unit_tests/corsika_simtel/test_corsika_simtel_runner.py        96      0   100%
tests/unit_tests/data_model/test_metadata_collector.py              118      0   100%
tests/unit_tests/data_model/test_metadata_model.py                   30      0   100%
tests/unit_tests/data_model/test_model_data_writer.py                32      0   100%
tests/unit_tests/data_model/test_validate_data.py                   194      0   100%
tests/unit_tests/data_model/test_validate_schema.py                 131      1    99%
tests/unit_tests/job_execution/test_job_manager.py                   13      0   100%
tests/unit_tests/layout/test_layout_array.py                        228      0   100%
tests/unit_tests/layout/test_telescope_position.py                  188      0   100%
tests/unit_tests/model/test_array_model.py                           18      0   100%
tests/unit_tests/model/test_camera_model.py                          13      0   100%
tests/unit_tests/model/test_mirrors.py                               15      0   100%
tests/unit_tests/model/test_telescope_model.py                      137      0   100%
tests/unit_tests/simtel/test_simtel_config_writer.py                 23      0   100%
tests/unit_tests/simtel/test_simtel_events.py                        36      0   100%
tests/unit_tests/simtel/test_simtel_histograms.py                    12      0   100%
tests/unit_tests/simtel/test_simtel_runner.py                        15      0   100%
tests/unit_tests/simtel/test_simtel_runner_array.py                  50      0   100%
tests/unit_tests/simtel/test_simtel_runner_camera_efficiency.py      32      0   100%
tests/unit_tests/simtel/test_simtel_runner_ray_tracing.py            38      0   100%
tests/unit_tests/test_camera_efficiency.py                           56      2    96%
tests/unit_tests/test_db_handler.py                                 146      7    95%
tests/unit_tests/test_io_handler.py                                  28      0   100%
tests/unit_tests/test_psf_analysis.py                                11      0   100%
tests/unit_tests/test_ray_tracing.py                                 52      1    98%
tests/unit_tests/test_simulator.py                                  189      0   100%
tests/unit_tests/utils/test_general.py                              374     10    97%
tests/unit_tests/utils/test_names.py                                 47      0   100%
tests/unit_tests/visualization/test_legend_handlers.py               19      0   100%
tests/unit_tests/visualization/test_visualize.py                     78      2    97%
-------------------------------------------------------------------------------------
TOTAL                                                             10552    795    92%

@orelgueta
Copy link
Contributor

Where do we stand with this? Do we get the right coverage numbers with it now? (I am not sure where to check.)

@GernotMaier
Copy link
Contributor Author

I have to admit the discussion around this PR leaves and the different coverage results leaves me a bit confused. No idea what to do and which numbers are reliable.

The changes in this PR all make sense, but I have no idea what the coverage number means.

@orelgueta
Copy link
Contributor

I agree the changes themselves look fine, but our actual coverage is 92% and not 99% that the badge in this branch gives. It seems that the problem is that codecov is measuring the coverage of the tests directory rather than the actual project (see - https://app.codecov.io/gh/gammasim/simtools/tree/main?displayType=tree). Not sure how to fix it. Will see if I find a moment of boredom to dig around at some point, but I suggest we keep this open so we don't forget.

@GernotMaier
Copy link
Contributor Author

I officially give up on this and think we should simply remove that badge and run coverage locally.

@orelgueta
Copy link
Contributor

I agree to removing the badge. Better to have no badge than a wrong one. Hopefully we can fix this in the future and return it.

@GernotMaier
Copy link
Contributor Author

I removed the codecov badge and also the upload from the unit test. Not really satisfactory, but let's do not waste more time on it. It works locally.

@VictorBarbosaMartins
Copy link
Contributor

Should we close this PR, since we are not using it anymore?

@orelgueta
Copy link
Contributor

I am not really ready to give up on codecov to be honest. Perhaps it should be revisited in the next maintenance period.

Copy link
Contributor

@orelgueta orelgueta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am "requesting changes" just so that I am notified when it is ready for review again (since I see it is being looked at again).

@GernotMaier
Copy link
Contributor Author

Some progress, but still stuck.

Issue: coverage is zero and this is very puzzling.

Running the following command locally gives me reasonable values (average of 70%; but this value is distorted as the application directory is not excluded):

pytest --durations=10 --color=yes --cov=simtools --cov-report=xml --cov-report=term tests/unit_test

The exact same command in github actions results in zero coverage, see e.g., https://github.com/gammasim/simtools/actions/runs/6815126998/job/18533564276 (this doesn't use codeov, but simply prints the coverage to the terminal).

I've done several cross checks, including installing the newest python 3.11 and cross checking the version of pytest and all plugins.

@GernotMaier
Copy link
Contributor Author

GernotMaier commented Nov 9, 2023

Progress and this looks much more reasonable.

Screenshot 2023-11-09 at 21 38 01

The final trick was that the github action did a pip install . and not a pip install -e .. This is changed now for the matrix element used for the coverage.

@GernotMaier
Copy link
Contributor Author

@orelgueta - this is now ready to review again. Was a bit tricky, but ideal thing to do while listening to talks...

The only thing I couldn't figure out is to exclude simtools/applications from the coverage testing.

And obviously codecov complaints that we have -29% coverage.

Copy link
Contributor

@orelgueta orelgueta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The badge doesn't have the correct value when looking at the README, even after selecting this branch. However, on the codecov website it seems better. So I am approving on faith that once we merge it will actually work. Then we should still look at excluding the applications directory cause right now we are failing the basic quality requirement for no real reason.

@orelgueta
Copy link
Contributor

I don't have admin access to edit the config yaml, could you maybe try this for ignoring the application path?

https://docs.codecov.com/docs/ignoring-paths

@GernotMaier GernotMaier merged commit 8f3000b into main Nov 21, 2023
8 of 9 checks passed
@GernotMaier GernotMaier deleted the code-coverage-badge branch November 21, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codecov issues?
3 participants