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

feature: new github action which limit the file changes in single PR to 20 #1316

Merged
merged 9 commits into from
Jan 6, 2024

Conversation

Tarunmeena0901
Copy link
Contributor

What kind of change does this PR introduce?
Feature

Issue Number:

Fixes #1276

Did you add tests for your changes?

Snapshots/Videos:
Screenshot 2023-12-29 014258

Screenshot 2023-12-29 014152

If relevant, did you update the documentation?

Summary

  • new contributors were creating PRs from branch whose source was not our develop branch which was causing PRs with hundreds of submitted files.

  • To solve this issue I added a new github action which count the number of file-changes made in a single PR and if the number of changed file exceeds 20 it give user error message "Contributor may be merging into an incorrect branch"

Does this PR introduce a breaking change?

  • new contributors who are not very much aware of working of github will have a hint to fix this problem everytime they make a wrong PR
  • This change encourages contributors to align with project practices, reducing the likelihood of unintentional merges into incorrect branches.

Changes Made:

  • I added a python script check-changed-files.py and modified the pull-request.yml file to add the required action
  • The Check-Changed-File job is dependent on Code-Quality-Check job so it will only run if Code-Quality-Check is successfull.
  • python black and pydocstyle linting and formatting rules are applied on every PR

Have you read the contributing guide?
YESSSSS

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

For the python script:

  1. Follow the Google Python style guide especially in the DocString area. https://google.github.io/styleguide/pyguide.html
  2. Make sure that the script is python black, pydocstring, pylint, flake8 and pycodestyle compliant
  3. Use the countline.py script in the workflow directory as a guide

image

@Tarunmeena0901
Copy link
Contributor Author

Thanks for noticing , I made the python script black, pydocstring, pylint, flake8 and pycodestyle compliant
also changed the name of script to a more descriptive name

Copy link

codecov bot commented Dec 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a7e4663) 96.30% compared to head (7a7d7aa) 97.22%.
Report is 20 commits behind head on develop.

❗ Current head 7a7d7aa differs from pull request most recent head fd0cf0b. Consider uploading reports for the commit fd0cf0b to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1316      +/-   ##
===========================================
+ Coverage    96.30%   97.22%   +0.92%     
===========================================
  Files          137      137              
  Lines         3387     3429      +42     
  Branches       949      964      +15     
===========================================
+ Hits          3262     3334      +72     
+ Misses         119       90      -29     
+ Partials         6        5       -1     

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

@palisadoes
Copy link
Contributor

Please work with @noman2002 on this. He'll be taking over the review of this PR

@Tarunmeena0901
Copy link
Contributor Author

Tarunmeena0901 commented Dec 29, 2023

Oh ok thanks for your time , but i dont think i can change the reviewers on my own right or can I ? @palisadoes

@Tarunmeena0901 Tarunmeena0901 changed the title feature: new github action which limit the file changes in single PR to 20 feature: new github action which limit the file changes in single PR to 20 fix #1276 Dec 30, 2023
@Tarunmeena0901 Tarunmeena0901 changed the title feature: new github action which limit the file changes in single PR to 20 fix #1276 feature: new github action which limit the file changes in single PR to 20 Dec 30, 2023
noman2002
noman2002 previously approved these changes Dec 31, 2023
Copy link
Member

@noman2002 noman2002 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 to me. But let someone else also review it.

@Tarunmeena0901
Copy link
Contributor Author

Yeah sure , no hurry 🤞🏻 I'll be glad to hear some suggestions

@palisadoes
Copy link
Contributor

  1. Please fix the failing test.
  2. It's failing when only two files were updated

@Tarunmeena0901
Copy link
Contributor Author

my bad there was a small typo in .yml file i fixed it

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

  1. See comments
  2. Remove references to python black. It is causing the workflow to fail

.github/workflows/pull-requests.yml Outdated Show resolved Hide resolved
.github/workflows/pull-requests.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comments

.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
@Tarunmeena0901
Copy link
Contributor Author

thanks for giving me info about argparser and subprocess.communicate I did not knew about these . i made the suggested changes and tested them as well.

  1. only one statement per try block for better troubleshooting
  2. used argparse for passing arguments
  3. added some print statement regarding on and from which branch one is creating a pull request
  4. removed the black reference from .yml file

Screenshot 2024-01-02 161301

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comments

.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Show resolved Hide resolved
.github/workflows/pull-requests.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comments

.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
@Tarunmeena0901
Copy link
Contributor Author

thanks for pointing out my mistakes and suggesting changes I made following changes in my most recent commit :

  • removed unnecessary try blocks

  • in parser.arguments remove not mandatory arguments liketype = str

  • changed the name of variable which represent contributors PR branch to more self describable
    current_commit ==> PR_branch

  • add the parameters to make it obvious what's happening
    python .github/workflows/count_changed_files.py --base_branch "${{ github.base_ref }}" --PR_branch "${{ github.head_ref }}"

  • removed unnecessary library imports like os

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comments

.github/workflows/count_changed_files.py Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
@Tarunmeena0901
Copy link
Contributor Author

I made the changes sir , thanks for your constant feedback

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

See comments. This should will be ready to merge very soon.

.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Show resolved Hide resolved
.github/workflows/count_changed_files.py Outdated Show resolved Hide resolved
.github/workflows/count_changed_files.py Show resolved Hide resolved
.github/workflows/count_changed_files.py Show resolved Hide resolved
@Tarunmeena0901
Copy link
Contributor Author

See comments. This should will be ready to merge very soon.

that sounds so good 🤩 , thank you for your constant guidance through out the issue

  • I made the changes you suggested and tested it locally on my own repo and its working perfectly
  • please suggest if you notice any more valid changes need to be done

@Tarunmeena0901
Copy link
Contributor Author

I just saw a PR #1317 where number of file changes my 23 these type of PR wont pass from git checks if merge the git hub action from this PR . should we increase the default value of number of file changes allowed to 30 currently its 20 ?

@palisadoes
Copy link
Contributor

I just saw a PR #1317 where number of file changes my 23 these type of PR wont pass from git checks if merge the git hub action from this PR . should we increase the default value of number of file changes allowed to 30 currently its 20 ?

This is meant to be a guide for reviewers

@palisadoes
Copy link
Contributor

We can adjust the number afterwards

@palisadoes palisadoes merged commit 0367652 into PalisadoesFoundation:develop Jan 6, 2024
7 of 8 checks passed
@Tarunmeena0901 Tarunmeena0901 deleted the issue_#1276 branch January 6, 2024 17:12
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