Skip to content

Commit

Permalink
add .Python version 3.12, style checks, test coverages and pre-commit…
Browse files Browse the repository at this point in the history
…s and pyproject file
  • Loading branch information
guzmanlopez committed Oct 23, 2024
1 parent 79df22c commit f55bf0a
Show file tree
Hide file tree
Showing 8 changed files with 2,609 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Title: [Brief description of the change]

## Description

<!-- Describe what this PR does and how it has been implemented -->

## Checklist

- [ ] Code follows project style guidelines
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] Changelog updated (if applicable)

## Testing

<!-- Explain how this change has been tested and how the reviewer may replicate those tests.-->

## Outcome/Results

<!--
Describe the expected outcomes of this change. If applicable,
mention any metrics or KPIs that will be affected.
-->

## Additional Context:

<!--
The following sections are optional.
Feel free to delete them if they do not apply to your PR
-->

### Motivation

<!-- Explain why this change is needed and what problem it solves -->

### Related Issues/Dependencies

<!-- List any related GitHub issues or dependencies -->

### Additional Notes

<!-- Add any other context or screenshots about the pull request here -->
47 changes: 47 additions & 0 deletions .github/workflows/style-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Style check

on: push

jobs:
style-check:
env:
UV_CACHE_DIR: ${{ github.workspace }}/.cache/uv
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Install uv
uses: astral-sh/[email protected]
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/[email protected]
with:
python-version-file: "pyproject.toml"

- name: Restore uv cache
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/.cache/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: uv sync --all-extras --dev

- name: Check linting with Ruff
run: uv run ruff check

- name: Check format with Ruff
run: uv run ruff format --check

- name: Check docstring coverage
run: uv run docstr-coverage ./**/*.py --fail-under 20 --skip-file-doc --verbose=2

- name: Minimize uv cache
run: uv cache prune --ci
49 changes: 49 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test Coverage

on: push

jobs:
test-coverage:
env:
UV_CACHE_DIR: ${{ github.workspace }}/.cache/uv
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Install uv
uses: astral-sh/[email protected]
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/[email protected]
with:
python-version-file: "pyproject.toml"

- name: Restore uv cache
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/.cache/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
run: uv sync --all-extras --dev

#- name: Pyright typechecking
# uses: jakebailey/[email protected]
# with:
# version: 1.1.370
# skip-unannotated: true
# level: error

- name: Run tests and check coverage
run: |
uv run pytest --cov=. --cov-fail-under=0
- name: Minimize uv cache
run: uv cache prune --ci
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# If you make changes to this file, you should run `uv run pre-commit install` to update the hooks
# Remember to update the version of the ruff-pre-commit repo when you update Ruff
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
args: ["--maxkb=5120"]
- id: check-json
- id: check-toml
types: [toml]
- id: check-yaml
types: [yaml]
- repo: https://github.com/Yelp/detect-secrets
rev: v1.3.0
hooks:
- id: detect-secrets
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.13
hooks:
- id: uv-lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
Loading

0 comments on commit f55bf0a

Please sign in to comment.