-
Notifications
You must be signed in to change notification settings - Fork 38
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
Added code coverage tracking to github action #378
base: devel
Are you sure you want to change the base?
Added code coverage tracking to github action #378
Conversation
Job CentOS 8 on ce3d555 : invalidated by @GabrielSoto-INL |
Job CentOS 8 on ce3d555 : invalidated by @GabrielSoto-INL problem with cloning, trying again? |
Just a general comment for clarification: seems there are two ways of accessing the coverage, correct?
Also, an additional note that after this PR is merged, @caleb-sitton-inl it may be good to summarize this in a Discussion for developers in this repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@caleb-sitton-inl and I have iterated on this previously, have left a couple more clarification comments and a suggestion for code clean-up.
@@ -33,4 +46,4 @@ jobs: | |||
- run: $Env:RAVEN_LIBS_NAME = "raven_libraries_"+(Get-Location).Path.Split("\")[-4]; bash ../raven/scripts/establish_conda_env.sh --install --conda-defs $HOME/Miniconda3/etc/profile.d/conda.sh | |||
- run: cd ../raven; bash ./build_raven | |||
- run: bash ../raven/run_tests --library-report | |||
- run: bash ../raven/run_tests -j4 --plugins --re=HERON | |||
- run: bash ../raven/run_tests -j4 --plugins --re=HERON/tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to confirm -- this doesn't change any functionality, it just cleans up the reporting? since there are no tests run outside of the HERON/tests
directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, because of some strange paths in the github runner, with the previous version all plugin tests for HERON, TEAL, and the ExamplePlugin were being run. This limits it to only the HERON tests.
.github/workflows/github-actions.yml
Outdated
# Reducing the frequency of coverage checks may be preferable if this increases. | ||
# report_py_coverage is being called twice, once within check_py_coverage to print to the terminal and once here to get data for the annotation | ||
- run: > | ||
bash coverage_scripts/check_py_coverage.sh -j4 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so all of these commands have to be within the same run
command because they rely on having the same environment variable definitions, I presume. all of the &&
s get a little confusing, at least for me, so I think setting some variables at the top of this .yml might help clean up the code? That way you can refer to things like DATA_FILE
without having to define it all within this run
job. See the env
section defined above the jobs
section here: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#defining-environment-variables-for-a-single-workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put them all in the same run
mostly because they're related, so I just assumed that the same run
would be best for stylistic reasons and just to avoid any potential errors from splitting them up that I might not spot. I agree that it makes more sense to split it though if possible. I can definitely move the DATA_FILE
and COV_RCFILE
definitions to somewhere more out of the way using the env
section. I think I can separate the check_py_coverage
line out into its own run
job as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, since DATA_FILE
and COV_RCFILE
definitions both use pwd
, I think I do actually need to define them in the same run
step as they're used. The check_py_coverage
can still be moved to a different run
step though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I would assume that pwd would give about the same value each time (if not, other things would fail I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that, to be accessible where they're used, the environment variables need to either be defined over an entire section with env
or defined within the same run
, and in env
, I don't believe you can run bash commands, including pwd
.
Yes, you can view the list of artifacts (which currently just contains the coverage results) in either of these ways. As for the Discussion, sounds good; I'll go ahead and create that once it's merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks reasonable.
SRC_DIR=`(cd src && pwd)` | ||
|
||
# get display var | ||
DISPLAY_VAR=`(echo $DISPLAY)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not just DISPLAY_VAR=$DISPLAY
. or possibly DISPLAY_VAR=${DISPLAY:-default}
if you need a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually have a great understanding of the importance of the DISPLAY
manipulation. This was a carryover from the check_py_coverage
script in RAVEN on which this script is based. After studying it some, I don't think it's necessary, and it does not have an effect on the functionality of the script, at least locally, so I'll plan to go ahead and remove lines 12-15 and 26-27.
.github/workflows/github-actions.yml
Outdated
# Reducing the frequency of coverage checks may be preferable if this increases. | ||
# report_py_coverage is being called twice, once within check_py_coverage to print to the terminal and once here to get data for the annotation | ||
- run: > | ||
bash coverage_scripts/check_py_coverage.sh -j4 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I would assume that pwd would give about the same value each time (if not, other things would fail I think).
This looks like it's coming along great. Have we documented how to view the coverage reports, and placed that documentation somewhere new developers can get familiar with it? |
@PaulTalbot-INL Not yet; the current plan is to create a github Discussion with that information once the PR has been merged. Also, when the github action is run, it will create an annotation that should be relatively obvious and will contain both the overall number for coverage as well as a very brief description of how to access the full report. |
Pull Request Description
What issue does this change request address?
#376
What are the significant changes in functionality due to this change request?
This request replaces the call to
run_tests
in the part of the github action running on linux with a call tocheck_py_coverage.sh
. This does not impact the functionality of the tests being run in any way. It provides a brief message with an easily visible percentage for code coverage when the action is complete. This message also directs users to a thorough html report on coverage available under the 'Artifacts' section.The disadvantage of this addition is the overhead run time whenever the github action is activated. Running locally, checking coverage adds about 19% overhead relative to plain
run_tests
. Since coverage is only being run for one of the two calls torun_tests
in this github action, the impact of the overhead is halved to 9-10% (considering only time spent executing tests, not time for setup and other activities the github action executes). While it does save time, only checking coverage for a single OS would not capture deviations in coverage caused by different scripts being run per the OS. An example of this is the selection of a pyomo solver, which can depend on the OS platform running the script.For Change Control Board: Change Request Review
The following review must be completed by an authorized member of the Change Control Board.