Skip to content

Add ci to each pull request that runs tests and lints#3

Merged
zkoppert merged 7 commits intomainfrom
zkoppert-patch-1
May 31, 2025
Merged

Add ci to each pull request that runs tests and lints#3
zkoppert merged 7 commits intomainfrom
zkoppert-patch-1

Conversation

@zkoppert
Copy link
Copy Markdown
Member

@zkoppert zkoppert commented May 30, 2025

This pull request introduces several enhancements and refinements to the GitHub User Engagement Metrics module and its associated test suite. Key updates include the addition of comprehensive docstrings for improved code clarity, refactoring for consistency in variable naming, better error handling, and the inclusion of a CI workflow for Python testing. These changes collectively improve maintainability, readability, and reliability of the codebase.

Continuous Integration Setup

  • Added a new GitHub Actions workflow (.github/workflows/python-ci.yml) to run Python tests and linting across multiple Python versions (3.11 and 3.12). This includes caching pip dependencies and using flake8 and pylint for linting.

Dependency Updates

  • Added types-requests to requirements-test.txt to improve type checking for the requests library.

Testing Enhancements

Code Refactoring and Documentation

  • Refactored user_engagement_metrics.py functions for improved readability and consistency, including renaming parameters (e.g., username to user) and adding docstrings to all functions. [1] [2] [3] [4]
  • Enhanced error handling in the main script to differentiate between network errors and data errors.
  • Replaced inline imports with from re import search for better modularity.

Additional Improvements

  • Added UTF-8 encoding to file operations in user_engagement_metrics.py to ensure compatibility across environments.

Copilot AI review requested due to automatic review settings May 30, 2025 23:51
@zkoppert zkoppert self-assigned this May 30, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new GitHub Actions workflow to automate dependency installation, linting, and testing across Python 3.11 and 3.12 for each push and pull request on main.

  • Introduces .github/workflows/python-ci.yml
  • Configures a matrix build for Python 3.11 and 3.12
  • Defines steps: checkout, setup Python, install dependencies, lint, and run tests
Comments suppressed due to low confidence (1)

.github/workflows/python-ci.yml:23

  • [nitpick] Pinning the actions/checkout action to a specific commit SHA can lead to maintenance overhead. Consider using a semantic version tag like actions/checkout@v4 to receive non-breaking updates automatically.
-      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

Comment thread .github/workflows/python-ci.yml Outdated
Comment thread .github/workflows/python-ci.yml
zkoppert and others added 5 commits May 30, 2025 16:53
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Zack Koppert <zkoppert@github.com>
Signed-off-by: Zack Koppert <zkoppert@github.com>
Signed-off-by: Zack Koppert <zkoppert@github.com>
@zkoppert zkoppert requested a review from Copilot May 31, 2025 03:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a Python CI workflow and enriches the user engagement metrics module with documentation, error handling, and encoding support, alongside expanding the test suite.

  • Introduces .github/workflows/python-ci.yml to run linting and tests on multiple Python versions.
  • Adds docstrings, timeouts, encoding, and refined error catching in user_engagement_metrics.py.
  • Enhances tests in test_user_engagement_metrics.py and updates dev dependencies in requirements-test.txt.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
user_engagement_metrics.py Added docstrings, timeout to safe_get, encoding for file I/O, and more specific exception handling.
test_user_engagement_metrics.py Expanded test fixtures with docstrings and temp-path patching; added new tests.
requirements-test.txt Included types-requests for type checking.
.github/workflows/python-ci.yml Configured GitHub Actions to cache dependencies, lint, and run pytest across Python versions.
Comments suppressed due to low confidence (4)

test_user_engagement_metrics.py:16

  • pytest is used here but not imported; add import pytest at the top of the file.
@pytest.fixture(autouse=True)

test_user_engagement_metrics.py:29

  • The module user_engagement_metrics is referenced but not imported; add import user_engagement_metrics.
user_engagement_metrics, "USERNAMES_FILE", str(tmp_path / "usernames.txt")

user_engagement_metrics.py:101

  • [nitpick] Parameter name user_name is inconsistent with other functions using user; consider renaming to username for consistency.
def get_user_repos(user_name):

user_engagement_metrics.py:167

  • [nitpick] Parameter type_ is ambiguous; consider renaming to contribution_type to clarify its purpose.
def search_user_contributions(user, type_):

@zkoppert zkoppert merged commit 554f244 into main May 31, 2025
4 checks passed
@zkoppert zkoppert deleted the zkoppert-patch-1 branch May 31, 2025 03:38
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