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

GitHub Action: Fix authorized-changes-detection #1543

Merged
merged 33 commits into from
Feb 17, 2024

Conversation

duplixx
Copy link
Member

@duplixx duplixx commented Feb 5, 2024

What kind of change does this PR introduce?

Issue Number:

Fixes #1526

Did you add tests for your changes?

Snapshots/Videos:

image

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

Other information

Have you read the contributing guide?

@duplixx duplixx requested a review from palisadoes as a code owner February 5, 2024 08:42
Copy link

github-actions bot commented Feb 5, 2024

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

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
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.

Test the following with this PR to make sure this and all other tests run:

  1. A commit with changes to more than 20 files not in the list
  2. A commit with a test file added to the .github directory

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

You haven't done the tests I requested using this PR

@duplixx
Copy link
Member Author

duplixx commented Feb 5, 2024

You haven't done the tests I requested using this PR

@palisadoes I apologize for any confusion. I am currently running tests, and I have noticed an issue related to the changed files. When printing the changed files, it shows an empty array. I believe this might be the reason why the sensitive file function is not running in this condition. Is there any change i should do to make it work

image
image

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (440387b) 96.74% compared to head (9a0a6b7) 96.74%.

❗ Current head 9a0a6b7 differs from pull request most recent head 3db0207. Consider uploading reports for the commit 3db0207 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1543      +/-   ##
===========================================
- Coverage    96.74%   96.74%   -0.01%     
===========================================
  Files          138      138              
  Lines         3688     3687       -1     
  Branches      1125     1125              
===========================================
- Hits          3568     3567       -1     
  Misses         114      114              
  Partials         6        6              

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

@duplixx
Copy link
Member Author

duplixx commented Feb 6, 2024

@palisadoes i changed the fetch-depth to 1 so it can clone the file name but that also deosn't seems to be working

@duplixx
Copy link
Member Author

duplixx commented Feb 16, 2024

@palisadoes here's the working demo of unauthorized changes workflow integrared in pull_request.yml

Screen.Recording.2024-02-16.at.11.00.57.PM.mov

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/check_files.py Outdated Show resolved Hide resolved
.github/workflows/check_files.py Outdated Show resolved Hide resolved
.github/workflows/check_files.py Outdated Show resolved Hide resolved
.github/workflows/check_files.py Outdated Show resolved Hide resolved
.github/workflows/check_files.py Outdated Show resolved Hide resolved
.github/workflows/check_files.py Outdated Show resolved Hide resolved
if unauthorized_changes:
print("Error: Unauthorized changes detected. Please review the list of modified files:")
for file in unauthorized_changes:
print(f" - {file}")
Copy link
Contributor

Choose a reason for hiding this comment

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

You are printing the named tuple, not the files it contained. I've recommended another approach

.github/workflows/check_files.py Outdated Show resolved Hide resolved
@palisadoes
Copy link
Contributor

We recently updated .github/workflows/authorized-changes-detection.yml

@duplixx
Copy link
Member Author

duplixx commented Feb 17, 2024

We recently updated .github/workflows/authorized-changes-detection.yml

it will be deleted afterwards right??

We recently updated .github/workflows/authorized-changes-detection.yml

added mentioned changes

@palisadoes
Copy link
Contributor

Yes, .github/workflows/authorized-changes-detection.yml should be deleted

@duplixx
Copy link
Member Author

duplixx commented Feb 17, 2024

All changes are done from my side sir @palisadoes

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.

Make sure the script:

  1. is python black, pylint, pycodestyle, flake8 and pydocstyle compliant.
  2. Has a maximum line width of 80 for better readability.
    1. https://stackoverflow.com/questions/59183863/in-python-how-to-tweak-black-formatter-if-possible


changed_files = [file.strip() for file in output.split(' ') if file.strip()]
file_count = len(changed_files)
return ScriptResult(file_count=file_count, unauthorized_changes=changed_files)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, a named tuple isn't needed here. You are only using the file count later.


# Count changed files and check for unauthorized changes
changed_files = _count_changed_files(base_branch, pr_branch)
print(f"Number of changed files: {changed_files.file_count}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Only print if the verbose flag is set

palisadoes
palisadoes previously approved these changes Feb 17, 2024
@palisadoes
Copy link
Contributor

Please fix the conflicting file, so that this can be merged

@duplixx
Copy link
Member Author

duplixx commented Feb 17, 2024

Sir, @palisadoes, I have deleted this file. How should I fix the conflicts? I guess after merging the changes, the conflicts will not show up.

@palisadoes
Copy link
Contributor

Try merging with the latest upstream and updating with a commit

@palisadoes
Copy link
Contributor

NOTE Read very carefully

  1. We just merged this PR which upgraded the prettier package.
    1. Upgraded prettier from 2.3.2 to 3.2.5 #1599
  2. It reformatted over 150 files.

This will put your PR at risk of extensive merge conflicts. Do the following IN THIS ORDER:

  1. upgrade your prettier in your local branch to the same version
  2. run prettier on your local branch
  3. update your local branch with the latest upstream

This will help to reduce the number of existing and future merge conflicts for your PR.

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