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

chore: release automations #33

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Conversation

mikejgray
Copy link
Collaborator

@mikejgray mikejgray commented Oct 20, 2024

Closes #20

Summary by CodeRabbit

  • New Features

    • Introduced new workflows for publishing major, minor, and stable releases to PyPI.
    • Added a script to increment version numbers for alpha, build, major, and minor versions.
  • Bug Fixes

    • Removed outdated workflows that were no longer needed, streamlining the CI/CD process.
  • Chores

    • Consolidated steps in the publish workflow to enhance efficiency and clarity.
    • Added pytest and pytest-cov to the development requirements for improved testing capabilities.

Copy link

coderabbitai bot commented Oct 20, 2024

Walkthrough

The changes in this pull request involve the removal of several GitHub Actions workflows related to translation, release management, and pull request validation, as well as the introduction of new workflows for building and publishing Python packages. The new workflows streamline the process of versioning and publishing to PyPI, incorporating scripts to manage version increments for major, minor, and build versions. Additionally, scripts for removing alpha designations and for bumping version numbers have been added to enhance version management.

Changes

File Path Change Summary
.github/workflows/auto_translate.yml Workflow removed: Auto translate.
.github/workflows/publish_alpha.yml Workflow updated: Changed to define steps directly for publishing to PyPI on dev branch.
.github/workflows/publish_build.yml New workflow added: Publish Build Release for building and publishing packages to PyPI.
.github/workflows/publish_major.yml New workflow added: Publish Major Release X.0.0 for major release automation.
.github/workflows/publish_minor.yml New workflow added: Publish Minor Release .X.0 for minor release automation.
.github/workflows/publish_release.yml Workflow removed: publish_release.
.github/workflows/pull-request-lint.yml Workflow removed: pull-request-lint.
.github/workflows/test_resources.yml Workflow removed: Test Resources.
scripts/bump_alpha.py New script added to increment the alpha version in version.py.
scripts/bump_build.py New script added to increment the build version in version.py.
scripts/bump_major.py New script added to increment the major version in version.py.
scripts/bump_minor.py New script added to increment the minor version in version.py.
scripts/remove_alpha.py New script added to reset the alpha version to zero in version.py.
requirements-dev.txt Dependencies added: pytest and pytest-cov.
setup.py Parameter added: extras_require={"test": get_requirements("requirements-dev.txt")} in setup().
test/test_skill.py Method removed: test_stop from TestLaughSkill.

Poem

In the meadow where we play,
New scripts hop and dance today.
Workflows change, the old ones fade,
A bright new path, our plans are laid.
With every bump, we rise and cheer,
To versioning joy, we hold so dear! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 24

🧹 Outside diff range and nitpick comments (13)
scripts/remove_alpha.py (3)

1-3: LGTM! Consider using a more robust path construction method.

The import statements and file path construction look good. However, to make the script more robust and portable, consider using Path from the pathlib module for path manipulation.

Here's a suggested improvement:

-import fileinput
-from os.path import join, dirname
-version_file = join(dirname(dirname(__file__)), "version.py")
+import fileinput
+from pathlib import Path
+version_file = Path(__file__).parent.parent / "version.py"

This change makes the path construction more readable and less prone to errors on different operating systems.


4-5: LGTM! Consider adding error handling for file operations.

The setup for file iteration and the alpha_var_name variable declaration are correct. However, it's important to handle potential file operation errors.

Consider wrapping the file operations in a try-except block to handle potential IOErrors:

try:
    for line in fileinput.input(version_file, inplace=True):
        # ... (rest of the code)
except IOError as e:
    print(f"Error processing file: {e}")
    sys.exit(1)

This change will make the script more robust by gracefully handling file-related errors.


6-9: LGTM! Consider a minor improvement for clarity.

The logic for modifying the file content is correct. It effectively sets VERSION_ALPHA to 0 and preserves other lines.

For improved clarity, consider using an explicit comparison instead of startswith():

-    if line.startswith(alpha_var_name):
+    if line.strip().startswith(f"{alpha_var_name} ="):
         print(f"{alpha_var_name} = 0")
     else:
         print(line.rstrip('\n'))

This change makes it clearer that we're looking for the variable assignment line, not just any line starting with the variable name.

scripts/bump_alpha.py (2)

1-5: LGTM! Consider parameterizing the version variable name.

The imports and file path setup look good. The relative path construction is a good practice for portability.

Consider making the version_var_name a command-line argument or a configuration value for increased flexibility if the variable name needs to change in the future.


1-15: Overall assessment: Functional but needs robustness improvements.

The script successfully increments the alpha version, but there are several areas for improvement:

  1. Error handling: Add comprehensive error checks throughout the script.
  2. File safety: Implement file backups and safe write operations.
  3. Logging: Add logging statements for better traceability and debugging.
  4. Parameterization: Consider making the script more flexible by accepting command-line arguments.

To enhance the script's robustness and maintainability, consider refactoring it into a main function with smaller, focused helper functions. This would improve readability and make it easier to add unit tests.

Here's a high-level structure suggestion:

import argparse
import logging

def parse_arguments():
    # Parse command-line arguments

def read_version(file_path, var_name):
    # Read and return the current version

def update_version(file_path, var_name, new_version):
    # Update the version in the file

def main():
    args = parse_arguments()
    setup_logging(args.verbose)
    
    try:
        current_version = read_version(args.file, args.var_name)
        new_version = current_version + 1
        update_version(args.file, args.var_name, new_version)
        logging.info(f"Version bumped to {new_version}")
    except Exception as e:
        logging.error(f"Error: {str(e)}")
        return 1
    
    return 0

if __name__ == "__main__":
    exit(main())

This structure allows for better error handling, logging, and future extensibility.

scripts/bump_major.py (1)

13-23: LGTM: File modification logic is sound, but consider adding error handling.

The file modification logic using fileinput is well-implemented. It correctly updates the major version and resets other version components while preserving the file structure.

Consider adding error handling for potential IOErrors during file writing:

try:
    for line in fileinput.input(version_file, inplace=True):
        # ... (existing logic)
except IOError as e:
    print(f"Error updating {version_file}: {e}")
    sys.exit(1)

This addition will make the script more robust against potential file system issues.

.github/workflows/publish_alpha.yml (1)

Line range hint 1-19: Consider a more specific workflow name

The current name "Publish Alpha Build ...aX" is descriptive but could be more specific. Consider updating it to "Publish Python Package Alpha Build" to clearly indicate the nature of the package being published.

🧰 Tools
🪛 actionlint

36-36: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


51-51: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

.github/workflows/publish_build.yml (1)

2-2: Fix the workflow name

The workflow name ends with "..X", which appears to be a typo or placeholder. Consider removing it for a cleaner, more professional name.

Apply this change:

-name: Publish Build Release ..X
+name: Publish Build Release
.github/workflows/publish_minor.yml (3)

6-19: LGTM: Job setup and initial steps are well-configured.

The job configuration and initial steps are appropriate for the task. However, consider using a more recent Python version for potential performance improvements and longer support.

Consider updating the Python version to 3.11 or 3.12 for improved performance and longer support:

- python-version: 3.10
+ python-version: 3.12

76-84: LGTM: Matrix notification step is well-implemented.

Sending a notification to a Matrix channel about the new release is a good practice for team communication. The implementation is secure, using a secret for the Matrix token.

Consider enhancing the notification message with a link to the GitHub release for easy access to the changelog:

  message: |
-   New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
+   New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
+   Release details: https://github.com/${{ github.repository }}/releases/tag/V${{ steps.version.outputs.version }}

1-84: Overall, the workflow is well-designed for automating minor releases.

This GitHub Actions workflow effectively automates the process of publishing minor releases. It covers all necessary steps including:

  1. Version management
  2. Changelog generation
  3. GitHub release creation
  4. Distribution package building
  5. PyPI publishing
  6. Team notification

The workflow follows good practices such as using secrets for sensitive information, leveraging official actions where possible, and maintaining both dev and master branches.

While there are a few minor issues with deprecated commands and unused variables (as noted in previous comments), these can be easily addressed. Once these small updates are made, this workflow will provide a robust and efficient process for managing minor releases.

To further improve this workflow, consider the following suggestions:

  1. Add a step to run tests before building and publishing, ensuring only validated code is released.
  2. Implement a mechanism to automatically update the project's documentation with the new version number.
  3. Consider adding a step to create and push git tags for each release, if not already handled by the actions/create-release action.
🧰 Tools
🪛 actionlint

21-21: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


41-41: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


61-61: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


64-64: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/publish_major.yml (2)

7-19: Consider updating to a more recent Python version.

The workflow setup looks good overall. However, you might want to consider using a more recent Python version, such as 3.11 or 3.12, to take advantage of the latest features and performance improvements.

- python-version: 3.10
+ python-version: '3.12'

This change would ensure you're using the latest stable Python version for your build process.


76-84: LGTM: Matrix notification is a good practice. Consider adding more details to the message.

The Matrix notification step is a great way to keep the team informed about new releases. To make the notification even more useful, consider adding more details to the message, such as:

  1. A link to the GitHub release page.
  2. A brief summary of key changes or features in this release.

Here's an example of how you could enhance the message:

message: |
  New skill-ovos-fallback-unknown release! ${{ steps.version.outputs.version }}
  
  Release page: https://github.com/${{ github.repository }}/releases/tag/V${{ steps.version.outputs.version }}
  
  Key changes:
  - [Add a brief summary of major changes or features]
  
  For full details, please check the release page.

This additional information would provide more context to the team about the new release.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 69f4f29 and aeda977.

📒 Files selected for processing (13)
  • .github/workflows/auto_translate.yml (0 hunks)
  • .github/workflows/publish_alpha.yml (2 hunks)
  • .github/workflows/publish_build.yml (1 hunks)
  • .github/workflows/publish_major.yml (1 hunks)
  • .github/workflows/publish_minor.yml (1 hunks)
  • .github/workflows/publish_release.yml (0 hunks)
  • .github/workflows/pull-request-lint.yml (0 hunks)
  • .github/workflows/test_resources.yml (0 hunks)
  • scripts/bump_alpha.py (1 hunks)
  • scripts/bump_build.py (1 hunks)
  • scripts/bump_major.py (1 hunks)
  • scripts/bump_minor.py (1 hunks)
  • scripts/remove_alpha.py (1 hunks)
💤 Files with no reviewable changes (4)
  • .github/workflows/auto_translate.yml
  • .github/workflows/publish_release.yml
  • .github/workflows/pull-request-lint.yml
  • .github/workflows/test_resources.yml
🧰 Additional context used
🪛 actionlint
.github/workflows/publish_alpha.yml

36-36: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


51-51: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)

.github/workflows/publish_build.yml

21-21: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


41-41: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


61-61: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


64-64: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/publish_major.yml

21-21: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


41-41: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


61-61: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


64-64: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/publish_minor.yml

21-21: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)


41-41: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


61-61: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


64-64: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)

🔇 Additional comments (10)
scripts/bump_build.py (1)

1-5: LGTM: Imports and variable definitions are appropriate.

The imports and variable definitions are well-chosen for the script's purpose. The use of os.path functions ensures cross-platform compatibility when constructing file paths.

scripts/bump_minor.py (1)

1-6: LGTM: Imports and variable definitions are appropriate.

The imports and variable definitions are well-structured and provide a clear setup for the script's functionality. The use of os.path functions ensures cross-platform compatibility.

scripts/bump_major.py (1)

1-7: LGTM: Imports and variable declarations are appropriate.

The imports and variable declarations are well-structured and provide a clear foundation for the script's functionality. The use of os.path functions ensures cross-platform compatibility.

.github/workflows/publish_alpha.yml (1)

53-66: Release creation step looks good

The release creation step is well-configured. It correctly uses the incremented version number, includes the generated changelog, and is appropriately marked as a prerelease for an alpha build.

.github/workflows/publish_build.yml (1)

76-84: LGTM: Matrix notification step

The step for sending a notification to the Matrix channel after a successful release is well-implemented. It provides good visibility for the team about new releases.

.github/workflows/publish_minor.yml (3)

1-4: LGTM: Workflow name and trigger are appropriate.

The workflow name clearly describes its purpose, and the manual trigger via workflow_dispatch is suitable for a release workflow, allowing control over when the release process is initiated.


72-75: LGTM: PyPI publishing step is well-configured.

The use of the official pypa/gh-action-pypi-publish action for publishing to PyPI is a good practice. The PyPI token is correctly referenced as a secret, ensuring secure authentication.


43-71: ⚠️ Potential issue

Release creation steps are well-structured but need minor updates.

The release creation process is comprehensive, covering GitHub release creation, package building, and version incrementing. However, there are a couple of issues to address:

  1. The set-output command is deprecated.
  2. The VER variable in the "Increment Version" step is unused.

Please apply the following changes:

  1. Update the deprecated set-output command:
- run: echo "::set-output name=version::$(python setup.py --version)"
+ run: echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
  1. Remove the unused VER variable:
- VER=$(python setup.py --version)
  python scripts/bump_minor.py

To ensure the bump_minor.py script is functioning correctly, let's examine its contents:

#!/bin/bash
cat scripts/bump_minor.py
🧰 Tools
🪛 actionlint

61-61: workflow command "set-output" was deprecated. use echo "{name}={value}" >> $GITHUB_OUTPUT instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

(deprecated-commands)


64-64: shellcheck reported issue in this script: SC2034:warning:1:1: VER appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/publish_major.yml (2)

1-4: LGTM: Workflow name and trigger are appropriate.

The workflow name clearly indicates its purpose for publishing major releases, and the manual trigger via workflow_dispatch provides necessary control over when to initiate the release process.


72-75: LGTM: PyPI publishing step is secure and follows best practices.

The PyPI publishing step uses the official PyPA action and securely handles the PYPI_TOKEN. This is the recommended way to publish packages to PyPI from GitHub Actions.

scripts/remove_alpha.py Show resolved Hide resolved
scripts/bump_alpha.py Show resolved Hide resolved
scripts/bump_alpha.py Show resolved Hide resolved
scripts/bump_build.py Show resolved Hide resolved
scripts/bump_build.py Show resolved Hide resolved
.github/workflows/publish_build.yml Show resolved Hide resolved
.github/workflows/publish_minor.yml Show resolved Hide resolved
.github/workflows/publish_major.yml Show resolved Hide resolved
.github/workflows/publish_major.yml Show resolved Hide resolved
.github/workflows/publish_major.yml Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
requirements-dev.txt (1)

1-2: Consider specifying versions and adding a file description

To ensure consistency across different development environments and prevent potential compatibility issues, it's recommended to specify the versions of the dependencies. Additionally, adding a comment at the top of the file explaining its purpose can be helpful for new contributors.

Here's a suggested improvement:

+# Development dependencies for testing and code coverage
-pytest
-pytest-cov
+pytest==6.2.5
+pytest-cov==2.12.1

Note: The versions provided are examples. Please use the most appropriate versions for your project.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aeda977 and 636ffaa.

📒 Files selected for processing (3)
  • requirements-dev.txt (1 hunks)
  • setup.py (1 hunks)
  • test/test_skill.py (0 hunks)
💤 Files with no reviewable changes (1)
  • test/test_skill.py
🧰 Additional context used
🔇 Additional comments (2)
requirements-dev.txt (1)

1-2: Excellent addition of testing dependencies!

The inclusion of pytest and pytest-cov is a great step towards improving the project's testing capabilities. These tools will enable developers to write and run tests more effectively, as well as measure code coverage, which are crucial for maintaining code quality.

setup.py (1)

81-81: LGTM! Great addition for managing test dependencies.

This change adds an extras_require parameter to the setup() function, which is an excellent practice for Python packaging. It allows for the separation of development/testing dependencies from the main package requirements. Users can now install these additional dependencies using pip install skill-laugh[test].

Benefits of this change:

  1. Clearer separation of concerns between production and development dependencies.
  2. Easier setup for contributors who want to run tests.
  3. Reduced package size for end-users who don't need testing tools.

The implementation is consistent with the existing code, using the get_requirements() function to read from "requirements-dev.txt".

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.

Not on PyPi
1 participant