Skip to content

Commit

Permalink
feat: introduce uv (#269)
Browse files Browse the repository at this point in the history
* PDM to UV
* Docstrings and documentation updates

Co-authored-by: Alc-Alc <[email protected]>
Signed-off-by: Cody Fincher <[email protected]>

* Update CONTRIBUTING.rst

Co-authored-by: Alc-Alc <[email protected]>
Signed-off-by: Cody Fincher <[email protected]>

* Update advanced_alchemy/extensions/litestar/dto.py

Co-authored-by: Alc-Alc <[email protected]>
Signed-off-by: Cody Fincher <[email protected]>

* Update advanced_alchemy/config/sync.py

Co-authored-by: Alc-Alc <[email protected]>
Signed-off-by: Cody Fincher <[email protected]>

---------

Signed-off-by: Cody Fincher <[email protected]>
Co-authored-by: Alc-Alc <[email protected]>
  • Loading branch information
cofin and Alc-Alc authored Oct 28, 2024
1 parent a479df1 commit dc5aa05
Show file tree
Hide file tree
Showing 122 changed files with 7,114 additions and 5,799 deletions.
91 changes: 71 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,86 @@ concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true


jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install Pre-Commit
run: python -m pip install pre-commit && pre-commit install
- name: Create virtual environment
run: uv sync --all-extras --dev

- name: Install Pre-Commit hooks
run: uv run pre-commit install

- name: Load cached Pre-Commit Dependencies
id: cached-pre-commit-dependencies
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Execute Pre-Commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run mypy
run: uv run mypy

pyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run pyright
run: uv run pyright

# # TODO(cofin)
# # AttributeError: 'SuiteRequirements' object has no attribute 'computed_reflects_normally'
slotscheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run slotscheck
run: uv run slotscheck -m advanced_alchemy.config -m advanced_alchemy.repository -m advanced_alchemy.service -m advanced_alchemy.extensions -m advanced_alchemy.base -m advanced_alchemy.types -m advanced_alchemy.operations

test:
name: "test (${{ matrix.python-version }}"
Expand Down Expand Up @@ -103,7 +161,6 @@ jobs:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
slug: litestar-org/advanced-alchemy

build-docs:
needs:
- validate
Expand All @@ -116,23 +173,17 @@ jobs:
- name: Install Microsoft ODBC
run: sudo ACCEPT_EULA=Y apt-get install msodbcsql18 -y

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.12"
allow-python-prereleases: true
cache: true
- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: pdm install -G:docs
run: uv sync --all-extras --dev

- name: Build docs
run: pdm run make docs
run: uv run make docs

- name: Save PR number
env:
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.12"
allow-python-prereleases: true
cache: true
- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: pdm install -G:docs
run: uv sync --all-extras --dev

- name: Fetch gh pages
run: git fetch origin gh-pages --depth=1

- name: Build release docs
run: pdm run python tools/build_docs.py docs-build
run: uv run python tools/build_docs.py docs-build
if: github.event_name == 'release'

- name: Build dev docs
run: pdm run python tools/build_docs.py docs-build
run: uv run python tools/build_docs.py docs-build
if: github.event_name == 'push'

- name: Deploy
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:

jobs:
publish-release:
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -16,19 +15,17 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: "3.12"
allow-python-prereleases: false
cache: true
- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --all-extras

- name: Build package
run: pdm build
run: uv build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 7 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,25 @@ jobs:
&& sudo rm -rf /var/cache/apt/* \
&& sudo apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
- name: Set up python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: ${{ inputs.python-version }}
allow-python-prereleases: false
cache: true
cache-dependency-path: |
./pdm.lock
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install base libraries
# install a few core libraries for testing and building
run: pip install nodeenv cython setuptools mypy cython pip --upgrade --quiet --user
- name: Set up Python
run: uv python install ${{ inputs.python-version }}

- name: Install dependencies
run: pdm install -G:all
run: uv sync --all-extras --dev

- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Test
if: ${{ !inputs.coverage }}
run: pdm run pytest --dist "loadgroup" -m "" tests -n 2
run: uv run pytest --dist "loadgroup" -m "" tests -n 2

- name: Test with coverage
if: ${{ inputs.coverage }}
run: pdm run pytest tests --dist "loadgroup" -m "" --cov=advanced_alchemy --cov-report=xml -n 2
run: uv run pytest tests --dist "loadgroup" -m "" --cov=advanced_alchemy --cov-report=xml -n 2

- uses: actions/upload-artifact@v4
if: ${{ inputs.coverage }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/

# Distribution / packaging
.Python
.python-version
build/
develop-eggs/
dist/
Expand Down
57 changes: 14 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
default_language_version:
python: python3
default_install_hook_types: [commit-msg, pre-commit]
python: "3"
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
rev: v3.6.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -23,54 +22,26 @@ repos:
- id: unasyncd
additional_dependencies: ["ruff"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.6.1"
rev: "v0.7.1"
hooks:
- id: ruff
args: ["--fix"]
exclude: "docs"
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
exclude: "pdm.lock|examples/us_state_lookup.json"
exclude: "uv.lock|examples/us_state_lookup.json"
additional_dependencies:
- tomli
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.1"
hooks:
- id: mypy
exclude: "docs"
additional_dependencies:
[
aiosqlite,
alembic,
async_timeout,
asyncmy,
asyncpg,
asyncpg_stubs,
uuid_utils,
oracledb,
psycopg,
pytest,
pytest-asyncio,
pytest-lazy-fixture,
time-machine,
httpx,
"sanic[ext]",
fastapi,
pytest-mock,
pytest-timeout,
sqlalchemy>=2.0.12,
msgspec,
click,
rich,
"litestar[cli]",
]
# - repo: https://github.com/RobertCraigie/pyright-python
# rev: v1.1.368
# hooks:
# - id: pyright
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: "v0.9.1"
rev: "v1.0.0"
hooks:
- id: sphinx-lint
- repo: local
hooks:
- id: pypi-readme
name: pypi-readme
language: python
entry: python tools/pypi_readme.py
types: [markdown]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
12 changes: 4 additions & 8 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ Contribution guide
Setting up the environment
--------------------------

1. Install `PDM <https://pdm.fming.dev/latest/>`_
2. Run ``pdm install -G:all`` to create a `virtual environment <https://docs.python.org/3/tutorial/venv.html>`_ and install
the dependencies
3. If you're working on the documentation and need to build it locally, install the extra dependencies with ``pdm install -G:docs``
4. Install `pre-commit <https://pre-commit.com/>`_
5. Run ``pre-commit install`` to install pre-commit hooks
1. Run ``make install-uv`` to install `uv <https://docs.astral.sh/uv/>`_ if not already installed
1. Run ``make install`` to install all dependencies and pre-commit hooks

Code contributions
------------------
Expand All @@ -21,8 +17,8 @@ Workflow
2. Clone your fork locally with git
3. `Set up the environment <#setting-up-the-environment>`_
4. Make your changes
5. (Optional) Run ``pre-commit run --all-files`` to run linters and formatters. This step is optional and will be executed
automatically by git before you make a commit, but you may want to run it manually in order to apply fixes
5. Run ``make lint`` to run linters and formatters. This step is optional and will be executed
automatically by git before you make a commit, but you may want to run it manually in order to apply fixes automatically by git before you make a commit, but you may want to run it manually in order to apply fixes
6. Commit your changes to git
7. Push the changes to your fork
8. Open a `pull request <https://docs.github.com/en/pull-requests>`_. Give the pull request a descriptive title
Expand Down
Loading

0 comments on commit dc5aa05

Please sign in to comment.