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: gh actions #17

Merged
merged 2 commits into from
Aug 7, 2024
Merged

Add: gh actions #17

merged 2 commits into from
Aug 7, 2024

Conversation

singjc
Copy link
Collaborator

@singjc singjc commented Aug 7, 2024

User description

  • updated readme
  • added github actions to automate release updating on request and automating pypi publishing on release

PR Type

Enhancement, Documentation


Description

  • Added a script to automate the creation of new patch releases on GitHub.
  • Added a script to update the version in __init__.py, supporting major, minor, and patch updates.
  • Introduced a GitHub Actions workflow for publishing the Python package to PyPI upon release creation.
  • Introduced a GitHub Actions workflow for creating new patch releases, including version updates and commits.
  • Updated the README with a new project description, features, installation instructions, and references.

Changes walkthrough 📝

Relevant files
Enhancement
release.py
Add script for automating GitHub patch releases                   

.github/workflows/scripts/release.py

  • Added script to create a new patch release on GitHub.
  • Implemented functions to get the last version and bump the patch
    number.
  • Handles cases where no previous release exists.
  • +48/-0   
    update_init_version.py
    Add script to update version in `__init__.py`                       

    .github/workflows/scripts/update_init_version.py

  • Added script to update the version in __init__.py.
  • Supports major, minor, and patch version updates.
  • Uses regular expressions to find and replace the version.
  • +53/-0   
    python-publish.yml
    Add GitHub Actions workflow for PyPI publishing                   

    .github/workflows/python-publish.yml

  • Added GitHub Actions workflow for publishing Python package to PyPI.
  • Triggers on release creation.
  • Includes steps for setting up Python, installing dependencies,
    building, and publishing the package.
  • +39/-0   
    release.yml
    Add GitHub Actions workflow for creating patch releases   

    .github/workflows/release.yml

  • Added GitHub Actions workflow for creating a new patch release.
  • Includes steps for updating version, committing changes, and creating
    a new release.
  • +26/-0   
    Documentation
    README.md
    Update README with project details and installation instructions

    README.md

  • Updated README with new project description and features.
  • Added installation instructions using pip and Anaconda.
  • Included references to relevant publications.
  • +38/-28 

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @qodo-merge-pro qodo-merge-pro bot added documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 3 labels Aug 7, 2024
    Copy link
    Contributor

    qodo-merge-pro bot commented Aug 7, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Error Handling
    The script lacks comprehensive error handling for subprocess calls, which might lead to unhandled exceptions if the commands fail for reasons other than a 404 HTTP error.

    Version Validation
    The script does not validate the extracted version string before attempting to modify it, which could lead to unexpected errors if the version format is not as expected.

    @singjc singjc merged commit 2529388 into OpenMS:main Aug 7, 2024
    Copy link
    Contributor

    qodo-merge-pro bot commented Aug 7, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add error handling for JSON parsing to prevent crashes

    To handle potential JSON parsing errors when decoding the output from the
    subprocess, wrap the json.loads call in a try-except block. This will prevent the
    script from crashing and allow for more graceful error handling if the JSON is
    malformed or unexpected.

    .github/workflows/scripts/release.py [19]

    -return json.loads(json_string)["tagName"]
    +try:
    +    return json.loads(json_string)["tagName"]
    +except json.JSONDecodeError:
    +    print("Failed to decode JSON from release data.")
    +    raise
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Adding error handling for JSON parsing is crucial for preventing the script from crashing due to malformed or unexpected JSON data. This improves the robustness and reliability of the script.

    9
    Add error handling for unexpected version string formats

    To improve the robustness of the version update logic, add error handling for the
    case where the version string does not match the expected format. This can prevent
    the script from crashing due to unexpected input.

    .github/workflows/scripts/update_init_version.py [17]

    -version_parts = list(map(int, current_version.split('.')))
    +try:
    +    version_parts = list(map(int, current_version.split('.')))
    +except ValueError:
    +    print("Error: Invalid version format.")
    +    return
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Adding error handling for unexpected version string formats is important for preventing the script from crashing due to invalid input. This enhances the robustness and user-friendliness of the script.

    9
    Possible issue
    Verify subprocess execution success before parsing output

    Consider checking the return value of subprocess.run before proceeding to decode the
    output. This ensures that the command was successful before attempting to parse its
    output, which can prevent errors if the command fails.

    .github/workflows/scripts/release.py [41-44]

    -subprocess.run(
    +result = subprocess.run(
         ["gh", "release", "create", "--generate-notes", new_version_number],
         check=True,
    +    stdout=subprocess.PIPE,
    +    stderr=subprocess.PIPE
     )
    +if result.returncode != 0:
    +    print(f"Failed to create release: {result.stderr.decode('utf8')}")
    +    raise Exception("Release creation failed")
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Verifying the success of the subprocess execution before parsing its output is a good practice. It ensures that the script handles errors gracefully and provides informative error messages.

    8

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    documentation Improvements or additions to documentation enhancement New feature or request Review effort [1-5]: 3
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant