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 GitHub Actions workflows for formatting, linting, and test covera… #1

Merged
merged 2 commits into from
Jan 5, 2025

Conversation

ghodsizadeh
Copy link
Owner

@ghodsizadeh ghodsizadeh commented Jan 5, 2025

Add github workflow

Summary by Sourcery

CI:

  • Add GitHub Actions workflows to perform formatting checks using ruff, linting using ruff, and test coverage reporting using pytest and codecov.

Copy link

sourcery-ai bot commented Jan 5, 2025

Reviewer's Guide by Sourcery

This pull request introduces GitHub Actions workflows for formatting, linting, and test coverage. It also adds a Codecov badge to the README.

Sequence diagram for GitHub Actions workflow execution

sequenceDiagram
    participant PR as Pull Request
    participant GH as GitHub Actions
    participant Fmt as Formatting Job
    participant Lint as Linting Job
    participant Test as Test Coverage Job

    PR->>GH: Create/Update PR
    activate GH
    par Parallel Jobs
        GH->>Fmt: Run formatting check
        activate Fmt
        Fmt-->>GH: Return formatting results
        deactivate Fmt
    and
        GH->>Lint: Run linting check
        activate Lint
        Lint-->>GH: Return linting results
        deactivate Lint
    and
        GH->>Test: Run test coverage
        activate Test
        Test-->>GH: Upload coverage report
        deactivate Test
    end
    GH-->>PR: Update PR status
    deactivate GH
Loading

File-Level Changes

Change Details Files
Added a GitHub Actions workflow for code formatting.
  • This workflow uses ruff to format the code on every pull request.
  • It runs on the ubuntu-latest runner and installs ruff as a dependency.
.github/workflows/formatting.yml
Added a GitHub Actions workflow for linting.
  • This workflow uses ruff to lint the code on every pull request.
  • It runs on the ubuntu-latest runner and installs ruff as a dependency.
.github/workflows/linting.yml
Added a GitHub Actions workflow for test coverage.
  • This workflow runs tests with coverage on every pull request using pytest and pytest-cov.
  • It uploads the coverage report to Codecov.
  • It runs on the ubuntu-latest runner and installs pytest and pytest-cov as dependencies.
.github/workflows/test_coverage.yml
Added a Codecov badge to the README.
  • A Codecov badge has been included in the README file to display the project's test coverage status.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@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 @ghodsizadeh - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The test coverage workflow is missing installation of the package dependencies. Please add pip install -e . or your package requirements to the dependencies installation step.
  • Please improve the PR description to better explain what workflows are being added and their purpose. This helps with future maintenance and understanding of the changes.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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 and I'll use the feedback to improve your reviews.

with:
python-version: '3.x'

- name: Install dependencies
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Add dependency caching to improve workflow performance

Using actions/cache for pip dependencies can significantly speed up workflow execution by avoiding repeated downloads.

Suggested implementation:

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'

    - name: Cache pip dependencies
      uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
        restore-keys: |
          ${{ runner.os }}-pip-

    - name: Install dependencies

Note: This assumes you have a requirements.txt file. If you're using a different dependency management file (like setup.py, pyproject.toml, etc.), you should adjust the hashFiles() pattern accordingly. For example:

  • For pyproject.toml: hashFiles('**/pyproject.toml')
  • For setup.py: hashFiles('**/setup.py')
  • For multiple files: hashFiles('**/requirements.txt', '**/setup.py')

@ghodsizadeh ghodsizadeh merged commit acb60cd into main Jan 5, 2025
3 checks passed
@ghodsizadeh ghodsizadeh deleted the workflow branch January 5, 2025 19:23
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.

1 participant