-
-
Notifications
You must be signed in to change notification settings - Fork 574
Modernize Records: Add Type Hints, Async Support, Enhanced Context Managers & CI/CD #229
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||||||||||||||||||||
| name: Basic Tests | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||
| branches: [ master, main, dev ] | ||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||
| branches: [ master, main ] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||
| test: | ||||||||||||||||||||||||||||||
| runs-on: ${{ matrix.os }} | ||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||||||||||||||||||||||||||||||
| python-version: ['3.8', '3.9', '3.10', '3.11'] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Set up Python ${{ matrix.python-version }} | ||||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| python-version: ${{ matrix.python-version }} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||
| python -m pip install -e . | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Test basic import | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python -c "import records; print('β Records import successful')" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Test basic functionality | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python -c " | ||||||||||||||||||||||||||||||
| import records | ||||||||||||||||||||||||||||||
| db = records.Database('sqlite:///:memory:') | ||||||||||||||||||||||||||||||
| db.query('CREATE TABLE test (id INTEGER)') | ||||||||||||||||||||||||||||||
| db.query('INSERT INTO test VALUES (1)') | ||||||||||||||||||||||||||||||
| result = db.query('SELECT * FROM test') | ||||||||||||||||||||||||||||||
| assert len(list(result)) == 1 | ||||||||||||||||||||||||||||||
| db.close() | ||||||||||||||||||||||||||||||
| print('β Basic functionality works') | ||||||||||||||||||||||||||||||
| " | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Run enhancement tests | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python test_enhancements_simple.py | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Test context managers | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python test_context_manager.py | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| integration: | ||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| python-version: '3.10' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||
| python -m pip install -e . | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Run full integration test | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python final_integration_test.py | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| lint: | ||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| python-version: '3.10' | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Install linting tools | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||
| python -m pip install flake8 mypy | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Lint with flake8 (non-blocking) | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| flake8 records.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || true | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Type check with mypy (non-blocking) | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| mypy records.py --ignore-missing-imports || true | ||||||||||||||||||||||||||||||
|
Comment on lines
+90
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking lint steps defeat their purpose. The lint and mypy steps use Remove the non-blocking behavior to enforce code quality: - name: Lint with flake8 (non-blocking)
run: |
- flake8 records.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics || true
+ flake8 records.py --count --max-complexity=10 --max-line-length=127 --statistics
- name: Type check with mypy (non-blocking)
run: |
- mypy records.py --ignore-missing-imports || true
+ mypy records.py --ignore-missing-importsIf you want non-blocking during initial rollout, use π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python 3.8 incompatibility with latest pytest. Python 3.8 support was dropped in pytest 8.4.2, but pyproject.toml specifies Update the Python version matrix to align with supported versions and add an upper bound for pytest if continuing to support Python 3.8: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
+ python-version: ['3.9', '3.10', '3.11', '3.12']Or, if Python 3.8 support is required, pin pytest in pyproject.toml: test = [
"pytest>=6.0,<8.4",
"pytest-cov",
]Based on learnings. |
||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e ".[test]" | ||
|
|
||
| - name: Test with pytest | ||
| run: | | ||
| pytest -v | ||
|
|
||
| build-and-publish: | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install build twine | ||
|
|
||
| - name: Build package | ||
| run: | | ||
| python -m build | ||
|
|
||
| - name: Check distribution | ||
| run: | | ||
| python -m twine check dist/* | ||
|
|
||
| - name: Publish to PyPI | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
| run: | | ||
| python -m twine upload dist/* | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||
| name: Tests | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [ master, main, dev ] | ||||||
| pull_request: | ||||||
| branches: [ master, main ] | ||||||
|
|
||||||
| jobs: | ||||||
| test: | ||||||
| runs-on: ${{ matrix.os }} | ||||||
| strategy: | ||||||
| fail-fast: false | ||||||
| matrix: | ||||||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||||||
| python-version: ['3.8', '3.9', '3.10', '3.11'] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python 3.8 incompatibility and workflow inconsistency. Same issue as release.yml: pytest 8.4.2 dropped Python 3.8 support. Additionally, this workflow tests Python 3.8-3.11 while release.yml tests 3.8-3.12, creating inconsistent coverage. Standardize Python versions across all workflows: - python-version: ['3.8', '3.9', '3.10', '3.11']
+ python-version: ['3.9', '3.10', '3.11', '3.12']Based on learnings. π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||
|
|
||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Python ${{ matrix.python-version }} | ||||||
| uses: actions/setup-python@v4 | ||||||
| with: | ||||||
| python-version: ${{ matrix.python-version }} | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: | | ||||||
| python -m pip install --upgrade pip | ||||||
| python -m pip install -e . | ||||||
|
|
||||||
| - name: Test basic import | ||||||
| run: | | ||||||
| python -c "import records; print('β Records import successful')" | ||||||
|
|
||||||
| - name: Test basic functionality | ||||||
| run: | | ||||||
| python -c " | ||||||
| import records | ||||||
| db = records.Database('sqlite:///:memory:') | ||||||
| db.query('CREATE TABLE test (id INTEGER)') | ||||||
| db.query('INSERT INTO test VALUES (1)') | ||||||
| result = db.query('SELECT * FROM test') | ||||||
| assert len(list(result)) == 1 | ||||||
| db.close() | ||||||
| print('β Basic functionality works') | ||||||
| " | ||||||
|
|
||||||
| - name: Run enhancement tests | ||||||
| run: | | ||||||
| python test_enhancements_simple.py | ||||||
|
|
||||||
| integration: | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Python | ||||||
| uses: actions/setup-python@v4 | ||||||
| with: | ||||||
| python-version: '3.10' | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| run: | | ||||||
| python -m pip install --upgrade pip | ||||||
| python -m pip install -e . | ||||||
|
|
||||||
| - name: Test context managers | ||||||
| run: | | ||||||
| python test_context_manager.py | ||||||
|
|
||||||
| - name: Run full integration test | ||||||
| run: | | ||||||
| python final_integration_test.py | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 3.8 incompatibility with latest pytest.
Same issue: pytest 8.4.2 dropped Python 3.8 support.
Based on learnings.
π Committable suggestion
π€ Prompt for AI Agents