Skip to content

Add autoDIR Action #1546

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

Closed
wants to merge 52 commits into from
Closed

Add autoDIR Action #1546

wants to merge 52 commits into from

Conversation

mrvnmchm
Copy link
Member

@mrvnmchm mrvnmchm commented Nov 1, 2019

This Github action updates the DIRECTORY.md file and pushes back to GH, if it is necessary. FIles updated are from black.py and build_directory_md.py. Not sure if I need to adjust the GH auth.

add index update for permission fix
@mrvnmchm
Copy link
Member Author

mrvnmchm commented Nov 1, 2019

Added for Issue #1460

@mrvnmchm mrvnmchm requested a review from cclauss November 1, 2019 13:11
@cclauss
Copy link
Member

cclauss commented Nov 1, 2019

You need to rebase. It is much easier to review if each PR touches only one file.

@mrvnmchm
Copy link
Member Author

mrvnmchm commented Nov 1, 2019

I can do that. Should I cancel this PR and resubmit after rebase?

@cclauss
Copy link
Member

cclauss commented Nov 1, 2019

Should I cancel this PR?

If the PR touches more than one file then yes.

@@ -0,0 +1,29 @@
name: autoDIR
Copy link
Member

@cclauss cclauss Nov 1, 2019

Choose a reason for hiding this comment

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

Add a comment and change the name:

# The objective of this GitHub Action is to add a new DIRECTORY.md file to a pull request if needed.
name: directory_writer

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make this change for the upcoming PR

uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Update DIRECTORY
Copy link
Member

Choose a reason for hiding this comment

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

name: Update DIRECTORY.md

Copy link
Member Author

Choose a reason for hiding this comment

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

Will make this change in upcoming PR

- name: Update DIRECTORY
run: |
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
git config --global user.name 'autoDIR'
Copy link
Member

Choose a reason for hiding this comment

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

directory_writer

Copy link
Member Author

Choose a reason for hiding this comment

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

Will make this change in upcoming PR

git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.gh_token }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git diff-files --quiet
Copy link
Member

Choose a reason for hiding this comment

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

I believe that if this command fails then the entire PR is marked with a failing test ❌ which we do not want.

On line 28, use fixup: instead of Update: because when a merge happens git will autosquish that commit into the previous commit.

Put a \n at the end of the file so that GitHub does not put 🚫 at the end of the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct @cclauss, the git diff-files --quiet commands exit code is the same as for git diff-index (0 == no differences; 1 == differences). In this case, if failure, it will continue with the push. Would you have any suggestion for evaluating if the DIRECTORY.md file has changed?

I will make the changes to line 28, and add the newline at the end in upcoming PR

@mrvnmchm mrvnmchm closed this Nov 1, 2019
@cclauss
Copy link
Member

cclauss commented Nov 1, 2019

$ python3

>>> import hashlib
>>> def get_file_hexdigest(filepath: str="DIRECTORY.md") -> str:
...     with open(filepath, "rb") as in_file:
...         return hashlib.md5(in_file.read()).hexdigest()
...
>>> get_file_hexdigest()
'b1c7c4f112361d85016fa4d50cd681e9'

Do that once before you generate the DIRECTORY.md and then again after you generate the DIRECTORY.md file.

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.

2 participants