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

feat: basic structure based on cookiecutter #3

Closed
wants to merge 2 commits into from

Conversation

psankhe28
Copy link
Collaborator

@psankhe28 psankhe28 commented Jul 2, 2024

#4

Summary by Sourcery

This pull request sets up the basic project structure using Cookiecutter, including Makefile, Sphinx documentation, GitHub Actions for CI/CD, a Code of Conduct, and initial test placeholders.

  • New Features:
    • Introduced a Makefile with various targets for environment management, code quality, testing, and documentation generation.
    • Added Sphinx configuration for generating project documentation.
    • Implemented a GitHub Action for setting up Python and Poetry environments.
    • Created multiple GitHub workflows for code quality checks, testing, PR validation, documentation checks, and vulnerability scans.
    • Added a Code of Conduct document.
    • Included a PULL_REQUEST_TEMPLATE.md for standardizing pull request descriptions.
    • Added a .pre-commit-config.yaml for pre-commit hooks.
    • Introduced a main entry point for the tus_storagehandler module.
  • Enhancements:
    • Configured Read the Docs with a .readthedocs.yaml file for building documentation.
    • Added a .yamllint.yaml file for YAML linting configuration.
  • CI:
    • Set up GitHub Actions for code quality, testing, PR validation, documentation checks, and vulnerability scans.
  • Documentation:
    • Added initial Sphinx documentation structure and configuration.
    • Included a Makefile and make.bat for building documentation.
  • Tests:
    • Added placeholder test files for unit and integration tests to avoid errors during test runs.
  • Chores:
    • Removed the README.md file.

Copy link
Contributor

sourcery-ai bot commented Jul 2, 2024

Reviewer's Guide by Sourcery

This pull request sets up the basic project structure using Cookiecutter. It includes the addition of Makefile, Sphinx documentation configuration, GitHub Actions workflows for CI/CD, community guidelines, configuration files for safety checks and pre-commit hooks, placeholder test files, and the main entry point for the tus_storagehandler package.

File-Level Changes

Files Changes
Makefile
docs/source/conf.py
docs/Makefile
docs/make.bat
.readthedocs.yaml
Added basic project structure including Makefile and Sphinx documentation configuration.
.github/actions/setup/poetry/action.yaml
.github/workflows/code_quality.yaml
.github/workflows/code_test.yaml
.github/workflows/pr_validation.yaml
.github/workflows/update.yaml
.github/workflows/vulnerability.yaml
.github/workflows/docs.yaml
.github/workflows/release.yaml
Added GitHub Actions workflows for CI/CD, including code quality checks, testing, PR validation, project updates, vulnerability checks, documentation checks, and release process.
CODE_OF_CONDUCT.md
PULL_REQUEST_TEMPLATE.md
.github/ISSUE_TEMPLATE/general-purpose.md
Added community guidelines including Code of Conduct, pull request template, and issue template.
.safety-policy.yml
.pre-commit-config.yaml
.yamllint.yaml
Added configuration files for safety checks, pre-commit hooks, and YAML linting.
tests/test_integration/test_dummy.py
tests/test_unit/test_dummy.py
tests/__init__.py
tests/test_integration/__init__.py
tests/test_unit/__init__.py
Added placeholder test files and init files for test packages.
tus_storagehandler/main.py
tus_storagehandler/__init__.py
Added main entry point and init file for the tus_storagehandler package.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@psankhe28 psankhe28 requested a review from JaeAeich July 2, 2024 10:58
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psankhe28 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 6 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 2 issues found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

run: |
SEP="${{ !startsWith(runner.os, 'windows') && '/' || '\\' }}"
PIPX_CACHE="${{ github.workspace }}${SEP}pipx_cache"
echo "pipx-cache-path=${PIPX_CACHE}" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Use consistent quoting style

Consider using consistent quoting style for variables and strings. Mixing single and double quotes can lead to readability issues and potential bugs.

- name: Set up environment
uses: ./.github/actions/setup/poetry
with:
os: ${{ job.os }}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove unnecessary input

The os input is not used in the setup/poetry action. Consider removing it to avoid confusion.

Suggested change
os: ${{ job.os }}
python-version: '3.11'
poetry-install-options: "--only=lint --no-root"

poetry run pytest \
--cov-report term \
--cov-report xml:test_integration.xml \
--cov=tests/test_integration
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Use consistent coverage directory

Consider using a consistent directory for coverage reports across different test jobs. This will make it easier to manage and compare coverage results.

Suggested change
--cov=tests/test_integration
--cov=coverage/tests/test_integration

run: |
poetry lock --no-update
poetry install
pre-commit run --all-files
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Add specific pre-commit stage

Consider specifying the pre-commit stage (e.g., commit, push) to ensure that the appropriate hooks are run. This can help avoid running unnecessary hooks.

Suggested change
pre-commit run --all-files
pre-commit run --all-files --hook-stage commit

- name: Compare docs with main branch
id: check_docs_diff
run: |
shasum /tmp/docs/* > /tmp/docs.sha
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Handle empty directories

Ensure that the shasum command handles empty directories gracefully. Consider adding a check to avoid errors when no files are present.


def main():
"""Main entry point for tus_storagehandler."""
print("Hello from tus_storagehandler!")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Avoid using print statements

Consider using a logging framework instead of print statements for better control over log levels and output destinations.

Suggested change
print("Hello from tus_storagehandler!")
import logging
def main():
"""Main entry point for tus_storagehandler."""
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info("Hello from tus_storagehandler!")

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 this is a good comment, please add logging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for your feedback, @uniqueg. I'll go ahead and update the code to use the logging framework as suggested. This will provide better control over log levels and output destinations. I'll push the changes shortly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes agreed, but I think @psankhe28 should have selected "n" for add_script option while templating this proj, then this file wouldn't have been generated and nor will the console script would have been added, I don;t think we need a console script for this proj do we?

But if we do, then maybe do this in another PR(leave this to be templating only 🤷‍♂️ ), or I should add this in the cookiecutter itself.

PS: This is just an opinion tho :).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for your input, @JaeAeich. You raise a valid point about the necessity of the console script for this project. If the console script is not required, it might indeed be more efficient to exclude it during the templating process with Cookiecutter.

However, since the file has already been generated and included in this PR, I suggest we proceed with the logging update for now to maintain consistency and ensure proper logging practices. We can then evaluate the need for the console script in a separate discussion or PR. If we decide it's unnecessary, we can remove it and update the Cookiecutter template accordingly.

Does that sound like a reasonable approach to everyone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JaeAeich I had used the default value for add_script.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for clarifying, @psankhe28. Given that the default value for add_script was used, it makes sense why this file was generated.

To move forward, I suggest we implement the logging update in this PR to ensure we follow best practices. After merging this PR, we can have a separate discussion to determine whether the console script is necessary for the project. If we conclude that it isn't, we can update the Cookiecutter template to exclude it and remove the file in a subsequent PR.

Does that sound like a good plan to everyone?

Copy link
Member

@uniqueg uniqueg left a comment

Choose a reason for hiding this comment

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

A few minor changes. Let's get this merged soon so that the actual coding can begin 🚀

.cruft.json Outdated
"cookiecutter": {
"author_name": "Elixir Cloud AAI",
"author_email": "[email protected]",
"development_status": "Beta",
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 this should rather be "Alpha"

Copy link
Collaborator

@JaeAeich JaeAeich Jul 3, 2024

Choose a reason for hiding this comment

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

@psankhe28 This has been changed to a list (sorry 😶‍🌫️ ), so this should now be something like

{
...
  "commit": "43f9bd92eaf21557e87d3932524fe5ffb6fd7ef4",
  "checkout": null,
  "context": {
    "cookiecutter": {
      "author_name": "ELIXIR Cloud AAI",
      "author_email": "[email protected]",
      "development_status": "1 - Planning", <- or 3 - Alpha
      "short_description": "A short description of the project.",
      "project_name": "python-cookiecutter",
      "project_slug": "python_cookiecutter",
....
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the development_status, "development_status": "Alpha", is this right?

Copy link
Member

Choose a reason for hiding this comment

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

No, I think you should use "1 - Planning", including the number. As you progress, you can change this to "2 - Pre-Alpha" and "3 - Alpha" as we see fit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Understood, thanks!


def main():
"""Main entry point for tus_storagehandler."""
print("Hello from tus_storagehandler!")
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 this is a good comment, please add logging.

@uniqueg
Copy link
Member

uniqueg commented Jul 2, 2024

Oh, and please make sure all of the tests pass 🙏

pyproject.toml Outdated
tus_storagehandler = "tus_storagehandler.main:main"

[tool.ruff]
indent-width = 2
Copy link
Collaborator

@JaeAeich JaeAeich Jul 3, 2024

Choose a reason for hiding this comment

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

change it to 4 and run,

make v
source .venv/bin/activate
make fl
make pc
git add .
git commit -m "style: change indent"

PS: The above command are meant to tell you what to do if they fail (like you use windows) then change the commads accordingly, you'll find the commands in Makefile.

Copy link
Collaborator Author

@psankhe28 psankhe28 Jul 3, 2024

Choose a reason for hiding this comment

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

In readme, according to the make fl command, following changes should be done:

error: mke should be make
--> .\README.md:95:1
|
95 | mke = 'mke'
| ^^^
|
error: mke should be make
--> .\README.md:95:8
|
95 | mke = 'mke'
| ^^^

Should I do this?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

@uniqueg please review this workflow, before merge or either we should remove it from the cookiecutter too, this hasn't been tested.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me. Let's run it and see if it gives any errors. If so, we can update it until it works, then also change it in the cookiecutter.

@JaeAeich
Copy link
Collaborator

JaeAeich commented Jul 3, 2024

@uniqueg test ci is failing because this repo doesn't have the token setup.
Please check the comment on api ci.

@uniqueg
Copy link
Member

uniqueg commented Jul 3, 2024

@uniqueg test ci is failing because this repo doesn't have the token setup.
Please check the comment on api ci.

Okay, I'll check that later.

@uniqueg
Copy link
Member

uniqueg commented Jul 3, 2024

@uniqueg test ci is failing because this repo doesn't have the token setup. Please check the comment on api ci.

I have added the PyPI and Codecov tokens. For the GH token, please specify exactly what permissions are needed, @JaeAeich (in the Cookiecutter repo) - I will add it afterwards.

Signed-off-by: Prati28 <[email protected]>
@JaeAeich
Copy link
Collaborator

JaeAeich commented Jul 3, 2024

I have added the PyPI and Codecov tokens.

Hey checkout test CI logs, it still shows that codecov token are missing.

@JaeAeich
Copy link
Collaborator

JaeAeich commented Jul 3, 2024

@uniqueg seems like I don't have permission to this repo, can you please add required permissions.

❯ git push origin fix
remote: Permission to elixir-cloud-aai/tus-storagehandler.git denied to JaeAeich.
fatal: unable to access 'https://github.com/elixir-cloud-aai/tus-storagehandler.git/': The requested URL returned error: 403

@psankhe28 psankhe28 requested a review from uniqueg July 18, 2024 18:06
@uniqueg
Copy link
Member

uniqueg commented Jul 25, 2024

@uniqueg seems like I don't have permission to this repo, can you please add required permissions.

❯ git push origin fix
remote: Permission to elixir-cloud-aai/tus-storagehandler.git denied to JaeAeich.
fatal: unable to access 'https://github.com/elixir-cloud-aai/tus-storagehandler.git/': The requested URL returned error: 403

Done, @JaeAeich

@uniqueg uniqueg requested review from JaeAeich and removed request for uniqueg July 25, 2024 12:00
@uniqueg
Copy link
Member

uniqueg commented Jul 25, 2024

@JaeAeich: I think it makes much more sense if you review this PR as long as the Cookiecutter PR is still not merged, as it might require another round of back and forth with that one (which I'm already reviewing). Also, you are more familiar with the code and potential pitfalls.

Is that okay? Let's ideally get this done this week (both the Cookiecutter PR and then also this one), so that @psankhe28 gets unblocked.

@uniqueg
Copy link
Member

uniqueg commented Jul 25, 2024

Upon reviewing #1 and #9, I suppose they will also become redundant with the Cookiecutter template in place and with this PR updated, right, @JaeAeich and @psankhe28? That is, #9 becomes fully redundant (or alternatively this one in favor of #9) and from #1 only the non boilerplate code should be salvaged (but probably in a fresh PR that already has the boilerplate merged).

It would be good to get to a point where we have only one of these PRs (appropriately named, perhaps chose: initialize project or similar), tests pass and it's okay on your end, @psankhe28 and @JaeAeich. I can then give it a final view before merging.

@uniqueg uniqueg self-requested a review July 25, 2024 12:07
This was referenced Jul 25, 2024
@uniqueg
Copy link
Member

uniqueg commented Aug 6, 2024

Closed in favor of #10

@uniqueg uniqueg closed this Aug 6, 2024
@psankhe28 psankhe28 deleted the basic-structure branch September 5, 2024 08:00
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