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 support for YAML config files #46

Merged
merged 4 commits into from
Apr 5, 2021
Merged

Add support for YAML config files #46

merged 4 commits into from
Apr 5, 2021

Conversation

austintraver
Copy link
Contributor

  • Increase the clarity of the usage documentation
  • Add the requirements.txt dependency file
  • Include the PyYAML package

* Increase the clarity of the usage documentation
* Add the `requirements.txt` dependency file
* Include the PyYAML package
Copy link
Owner

@saadmk11 saadmk11 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 for your contribution here 💯

I have not tested this locally, but the changes look good 💯, I have left some comments regarding minor changes to the documentation. :)

It would be great if you could include a sample YAML config in the documentation :) https://github.com/saadmk11/changelog-ci#example-config-file

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
scripts/changelog-ci.py Outdated Show resolved Hide resolved
scripts/changelog-ci.py Outdated Show resolved Hide resolved
try:
with open(config_file, 'r') as config_json:
config = json.load(config_json)
file = open(filepath)
Copy link
Owner

Choose a reason for hiding this comment

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

Don't we need to close the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't we need to close the file?

TL;DR No.

Explanation:

Once the reference count of file reaches zero, which happens at the end of this try block, CPython will call the __del__() method of the underlying path-like object, which makes the call to close() therein.

An argument can be made that how Python manages memory depends on which Python you're using. Most people use CPython, which uses this reference count system, so we have the guarantee that the file will receive the necessary call to close().

Since this is a GitHub Action which is run within a Docker container, we know we're using CPython, so I don't think it's worth changing this line of code to preserve niche cross-Python compatibility concerns, like maintaining support for Jython. 🎤💧

Good question though!

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, the garbage collector will eventually close the file, but Isn't it good practice to always explicitly close the file without relying on the garbage collector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it is good practice to do so, but my response was answering your first question:

Don't we need to close the file?

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, Alright 👍 The PR is almost ready to get merged 💯, I think we should close the opened file here 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go for it! You have write access to this branch

Copy link
Owner

Choose a reason for hiding this comment

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

Sure, I'm merging this to another branch before merging to master as I need to test the YAML config as well, thanks for your great work on this :)

scripts/changelog-ci.py Outdated Show resolved Hide resolved
austintraver and others added 2 commits March 26, 2021 09:27
Wow you have eagle eyes! Good catch!

🐛✋🏻🦅

Co-authored-by: Maksudul Haque <saad.mk112@gmail.com>
* Resolve PEP 8 "Package and Module Names"
* Resolve PEP 8 (E131) "Hanging indentation"
* Add preliminary support for Docker Compose
@saadmk11
Copy link
Owner

saadmk11 commented Apr 5, 2021

I don't think we need docker-compose for this action as it only runs one container

@saadmk11 saadmk11 changed the base branch from master to test-yaml-config April 5, 2021 15:20
Copy link
Owner

@saadmk11 saadmk11 left a comment

Choose a reason for hiding this comment

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

🎉🎉

@saadmk11 saadmk11 merged commit 0379af0 into saadmk11:test-yaml-config Apr 5, 2021
@austintraver
Copy link
Contributor Author

I don't think we need docker-compose for this action as it only runs one container

Good point. Compose is truly, as you said, better suited for multi-container applications.

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.

None yet

2 participants