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

Test actions #2

Merged
merged 30 commits into from
Jul 7, 2023
Merged

Conversation

mwaxmonsky
Copy link
Collaborator

Adding Unit Test Action for CI

Adds new Dockerfile for test container to run unit tests in.

User interface changes?: No

Fixes: None

Testing:
test removed: var_action_suite (temporarily disabled)
unit tests: all in /test
system tests: None
manual testing: None

@peverwhee peverwhee requested review from peverwhee and nusbaume June 28, 2023 18:23
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks like a great start! I did have a couple questions and a few (hopefully minor) requests, though.

.github/workflows/test.yaml Outdated Show resolved Hide resolved
.github/workflows/test.yaml Outdated Show resolved Hide resolved
on: [push]

jobs:
unit_tests:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question for @peverwhee and @mwaxmonsky. Right now this workflow will run even when people push code to their own branches on their own forks. This of course provides the benefit of testing early and often, but I know personally I sometimes get annoyed when I know I am breaking a test during development on my local fork but keep getting complaints from Github about it.

An alternative is we can have this workflow only run on commits to already open pull requests (to anywhere), and to commits that are made solely to the main NCAR/ccpp-framework repo. To do this you would need to add the following line under the unit_tests line:

if: github.event_name == 'pull_request' || github.repository == 'NCAR/ccpp-framework'

Since I suspect you two will be doing most of the development in this repo I'll leave the decision up to you.
I just wanted to bring this up as something to think about (as I have definitely run into it in other repos).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a great point and is actually something I've run into with previous organizations with similar resolutions. I'm all onboard with more judicious use of the actions especially if they can always be manually triggered if needed.

@peverwhee Any thoughts or objections?

Copy link
Owner

Choose a reason for hiding this comment

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

@nusbaume @mwaxmonsky I agree that only triggering the tests for pull requests to the main repo is ideal!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The branch has been updated but I'm having a small problem with getting jobs to run. I tried a few ways of implementing it and the current way should work but I must be missing a small detail.

Currently the manual dispatch will trigger but the job will still say skipped on my repo. Going to continue to investigate.

.github/workflows/test.yaml Outdated Show resolved Hide resolved
test/run_tests.sh Show resolved Hide resolved
Dockerfile Outdated

RUN python3 -m venv ./ccpp-env && \
source ./ccpp-env/bin/activate && \
pip3 install pytest black flake8 pylint
Copy link
Collaborator

Choose a reason for hiding this comment

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

This reminds me that it might be good to get a pylint Github Action job up and running as well, to make sure the CCPP python scripts are fully analyzed each time. I don't think we need it for this PR, but it could be good to make an issue for it. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm always on board with more testing! Especially if we're going to be adding more python as we go, would it also be a good idea to add a formatter as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have no problem with implementing a formatter, but it would probably be good to double-check with @peverwhee first as she is the other core developer for this framework.

Copy link
Owner

Choose a reason for hiding this comment

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

I think for sure pylint-ing is a good addition. Maybe no formatter (for now) as that might be too naggy...

@nusbaume
Copy link
Collaborator

I also forgot to mention that we might want to move the Dockerfile to be under the test directory, because it is currently only being used for testing the capgen (NCAR) branch, and we don't want to mistakenly imply that it can be used for the pre-build (NOAA) branch as well. Of course once we unify both branches then we can hopefully also provide a single unified container.

@mwaxmonsky mwaxmonsky requested a review from nusbaume July 3, 2023 15:11
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Everything generally looks good now. However, after reflecting on the last CCPP-framework meeting discussion I think for the moment it might be safer to just try and use the ubuntu-latest virtual machine instead of bringing in our own container.

.github/workflows/capgen_unit_tests.yaml Outdated Show resolved Hide resolved
test/Dockerfile Outdated Show resolved Hide resolved
@mwaxmonsky mwaxmonsky requested a review from nusbaume July 5, 2023 14:19
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Super-close! Just one last question.

.github/workflows/capgen_unit_tests.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks great now, thanks @mwaxmonsky!

@nusbaume
Copy link
Collaborator

nusbaume commented Jul 7, 2023

@mwaxmonsky My guess is that something is off with the if: github.event_name... line. It might be worth printing the github.event_name to stdout before the if-statement to make sure its value is what we think it should be. I believe you can do that by simply adding echo ${{ github.event_name }} to the workflow file just before the if-statement, although if that doesn't work please let me know.

@mwaxmonsky
Copy link
Collaborator Author

@nusbaume Ah ha, I think I got it working. I'm not sure why but it looks like the workflow dispatch option needs to be first in the actions list. Not sure if this is by design or a bug but I can manually trigger actions on my branch now.

@nusbaume
Copy link
Collaborator

nusbaume commented Jul 7, 2023

@mwaxmonsky Great, glad you figured it out! Yeah I have no idea why it needs to come first, but good to know for any future workflows!

Comment on lines 29 to 31
- name: Run pylint against capgen files
run: |
cd test && pylint
Copy link
Owner

Choose a reason for hiding this comment

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

@mwaxmonsky I know I said "if it's easy, go ahead and throw in a pylint test" but now I'm thinking there's more work to be done on linting all of the python files (or at least those that were updated). As written, this runs pylint on the test files, which is probably not quite sufficient.

My vote (sorry to make you undo things!) is to remove this and make an issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was hoping that since there was a .pylintrc file already, this would be a fairly quick add but it looks like that file hasn't been touched in a while and there's a few things that need to be examined so I'll remove this from here and make a separate PR. No worries!

@peverwhee peverwhee self-requested a review July 7, 2023 21:53
@mwaxmonsky mwaxmonsky merged commit 85ce0aa into peverwhee:add_const_interface Jul 7, 2023
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.

3 participants