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

Add Pylint to Workflow #373

Merged
merged 5 commits into from
Dec 4, 2023
Merged

Add Pylint to Workflow #373

merged 5 commits into from
Dec 4, 2023

Conversation

freemansw1
Copy link
Member

This is testing a theory, and is entirely copied from #278 . Per the GitHub documentation (https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token), the Pylint runner will never work on Julia's fork (and in #278) as the maximum access for PRs from public forked repos is read. In theory, this, which copies over the changes from #278 to a branch within our repo, should work.

  • Have you followed our guidelines in CONTRIBUTING.md?
  • Have you self-reviewed your code and corrected any misspellings?
  • Have you written documentation that is easy to understand?
  • Have you written descriptive commit messages?
  • Have you added NumPy docstrings for newly added functions?
  • Have you formatted your code using black?
  • If you have introduced a new functionality, have you added adequate unit tests?
  • Have all tests passed in your local clone?
  • If you have introduced a new functionality, have you added an example notebook?
  • Have you kept your pull request small and limited so that it is easy to review?
  • Have the newest changes from this branch been merged?

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f1d3a4e) 56.91% compared to head (fe1bad8) 59.80%.
Report is 5 commits behind head on RC_v1.5.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           RC_v1.5.x     #373      +/-   ##
=============================================
+ Coverage      56.91%   59.80%   +2.88%     
=============================================
  Files             20       20              
  Lines           3440     3769     +329     
=============================================
+ Hits            1958     2254     +296     
- Misses          1482     1515      +33     
Flag Coverage Δ
unittests 59.80% <ø> (+2.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@freemansw1 freemansw1 mentioned this pull request Nov 29, 2023
11 tasks
Copy link

github-actions bot commented Nov 29, 2023

Linting results by Pylint:

Your code has been rated at 8.72/10 (previous run: 8.72/10, +0.00)
The linting score is an indicator that reflects how well your code version follows Pylint’s coding standards and quality metrics with respect to the RC_v1.5.x branch.
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.

@freemansw1 freemansw1 added this to the Version 1.5.2 milestone Nov 29, 2023
@freemansw1 freemansw1 added the enhancement Addition of new features, or improved functionality of existing features label Nov 29, 2023
@freemansw1
Copy link
Member Author

OK Theory confirmed. @fziegner you should have write access to this branch, so feel free to edit/etc. probably good for you to get a commit in there to make sure your contributions are in the record.

@freemansw1
Copy link
Member Author

Probably better for this action to pull the merging branch, rather than main. We tend to do a lot of work in the RC branches.

Copy link
Member

@w-k-jones w-k-jones left a comment

Choose a reason for hiding this comment

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

Looks good, my only specific comments are regarding how we install tobac

Comment on lines 33 to 34
pip install .
pip install --upgrade pylint
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to use conda/mamba to create the environment, consistent with other actions, rather than pip?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I had some trouble getting pylint to work with the conda environment but I'll take another look.

Copy link
Member

Choose a reason for hiding this comment

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

Ah fair, if it causes more work then it's probably not worth changing it. Seems to work fine for me via conda locally as long as it isn't using python 3.12

Also good to check that we can install tobac with pip!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, it's working now. I just forgot to specify the shell in which pylint is supposed to run.

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'
Copy link
Member

Choose a reason for hiding this comment

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

Is there a need to use python 3.9? pylint doesn't seem to yet work with 3.12, but 3.11 works fine

Copy link
Member

Choose a reason for hiding this comment

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

I think we can change it to 3.11

Copy link

Linting results by Pylint:

Your code has been rated at 8.71/10 (previous run: 8.71/10, +0.00)
The linting score is an indicator that reflects how well your code version follows Pylint’s coding standards and quality metrics with respect to the RC_v1.5.x branch.
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.

Copy link
Member

@JuliaKukulies JuliaKukulies left a comment

Choose a reason for hiding this comment

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

Excellent, thanks for your help with this @freemansw1!

Copy link

Linting results by Pylint:

Your code has been rated at 8.72/10 (previous run: 8.72/10, +0.00)
The linting score is an indicator that reflects how well your code version follows Pylint’s coding standards and quality metrics with respect to the RC_v1.5.x branch.
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.

Copy link
Collaborator

@fziegner fziegner left a comment

Choose a reason for hiding this comment

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

Thank you @freemansw1 for looking into the permission issue. Should be good to go now.

echo "SHA=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_OUTPUT
id: git

- name: Get RC branch name
Copy link
Member Author

Choose a reason for hiding this comment

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

It would probably be better to grab the merging PR branch name. Let me look into that and see if that's possible

Copy link

github-actions bot commented Dec 1, 2023

Linting results by Pylint:

Your code has been rated at 8.72/10 (previous run: 8.72/10, +0.00)
The linting score is an indicator that reflects how well your code version follows Pylint’s coding standards and quality metrics with respect to the branch.
A decrease usually indicates your new code does not fully meet style guidelines or has potential errors.

@freemansw1
Copy link
Member Author

Ok, I think that figures it out. @fziegner @fsenf @w-k-jones @JuliaKukulies let me know if you're still happy to merge.

@w-k-jones
Copy link
Member

w-k-jones commented Dec 1, 2023

Is it possible to change the commenting action to make it update the origin comment (in the same manner as the coverage action) rather than post a new comment for each change? If it's not a quick change then we should go ahead and merge

@freemansw1
Copy link
Member Author

Is it possible to change the commenting action to make it update the origin comment (in the same manner as the coverage action) rather than post a new comment for each change? If it's not a quick change then we should go ahead and merge

That's an excellent point; this could get really annoying on frequently updated PRs

@w-k-jones w-k-jones linked an issue Dec 2, 2023 that may be closed by this pull request
@freemansw1
Copy link
Member Author

Is it possible to change the commenting action to make it update the origin comment (in the same manner as the coverage action) rather than post a new comment for each change? If it's not a quick change then we should go ahead and merge

I'm going to suggest that this is a blocking issue given the (high) potential for several comments given the way we use PRs. Given the (potential) complexity there, I'm inclined to push this PR back to 1.5.3 (or between releases, as we have done before for repo enhancements). @fsenf @fziegner thoughts? Other than #376 (which is done in my eyes) this is the last thing to resolve before release.

@freemansw1
Copy link
Member Author

Amazing, proven wrong within a minute of commenting. Well done, @fziegner!

@fziegner
Copy link
Collaborator

fziegner commented Dec 4, 2023

Wow, that was incredible timing. The first comment by the linter in this PR should be edited now.

@w-k-jones
Copy link
Member

Very nice work @fziegner , the first linter comment is showing as being edited 1 minute ago for me

@freemansw1
Copy link
Member Author

I can't approve my own PR, so this is me approving post edits. @fziegner fantastic work. Are you happy for us to merge?

@freemansw1 freemansw1 changed the title Test PR for internal pylint branch Add Pylint to Workflow Dec 4, 2023
@fziegner
Copy link
Collaborator

fziegner commented Dec 4, 2023

Yes @freemansw1, go ahead.

@freemansw1 freemansw1 merged commit 7ded724 into RC_v1.5.x Dec 4, 2023
38 checks passed
@w-k-jones
Copy link
Member

Annoyingly the pylint workflow is still failing due to permissions when creating a PR from a forked repo. Looking at the documentation here it seems we need to use pull_request_target rather than pull_request to enable write permissions. I've made this change in #378 , but I think that for this trigger to work it needs to be part of the branch being merged into (i.e. in the main repository) rather than the merging branch

@JuliaKukulies
Copy link
Member

Excellent work @fziegner!

Annoyingly the pylint workflow is still failing due to permissions when creating a PR from a forked repo. Looking at the documentation here it seems we need to use pull_request_target rather than pull_request to enable write permissions. I've made this change in #378 , but I think that for this trigger to work it needs to be part of the branch being merged into (i.e. in the main repository) rather than the merging branch

So that would just mean that we update pylint.yml one more time and change to/add pull_request_target in the RC branch which will then be merged to main with the release or what do you think?

@w-k-jones
Copy link
Member

So that would just mean that we update pylint.yml one more time and change to/add pull_request_target in the RC branch which will then be merged to main with the release or what do you think?

I've committed the change directly to the RC_v1.5.x branch and it's now working correctly

@JuliaKukulies
Copy link
Member

So that would just mean that we update pylint.yml one more time and change to/add pull_request_target in the RC branch which will then be merged to main with the release or what do you think?

I've committed the change directly to the RC_v1.5.x branch and it's now working correctly

Perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Addition of new features, or improved functionality of existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time to add pull request linting?
4 participants