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

140 move to uv #142

Merged
merged 32 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 121 additions & 3 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,136 @@ jobs:
sphinx:
runs-on: "ubuntu-latest"
steps:
- uses: cvxgrp/.github/actions/sphinx@main
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Install sphinx
shell: bash
run: |
uv pip install --no-cache-dir \
sphinx==7.2.6 \
sphinx-autoapi \
sphinx-rtd-theme
#recommonmark \
#toml

- name: Build sphinx
shell: bash
run: |
uv run sphinx-build -b html 'book/sphinx' artifacts/sphinx

- name: Archive sphinx documentation
uses: actions/upload-artifact@v4
with:
name: sphinx
path: artifacts/sphinx
retention-days: 1

test:
runs-on: "ubuntu-latest"
steps:
- uses: cvxgrp/.github/actions/coverage@main
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Test on Linux
shell: bash
run: |
uv pip install --no-cache-dir \
pytest-cov \
pytest-html \
pytest-random-order

uv run pytest --cov='cvx' --random-order --verbose \
--html=artifacts/tests/html-report/report.html \
--cov-report term \
--cov-report xml:artifacts/tests/coverage/coverage.xml \
--cov-report json:artifacts/tests/coverage/coverage.json \
--cov-report lcov:artifacts/tests/coverage/coverage.info \
--cov-report html:artifacts/tests/html-coverage \
tests/

# I want to upload the result to gh-pages, hence this file disturbs
rm -f artifacts/tests/html-coverage/.gitignore

- name: Archive tests results
uses: actions/upload-artifact@v4
with:
name: tests_coverage
path: artifacts/tests
retention-days: 1

jupyter:
runs-on: "ubuntu-latest"
steps:
- uses: cvxgrp/.github/actions/jupyter@main
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Install jupyterbook
shell: bash
run: |
uv pip install jupyter-book
# There is no need to create the kernel if the jupyter book is installed within the same virtual environment as the package
# poetry run python -m ipykernel install --user --name='cvx'

- uses: actions/cache@v4
name: Jupyter Cache
with:
path: ~/book/_build/.jupyter_cache
key: ${{ runner.os }}-jupyter-${{ hashFiles('**/*') }}
restore-keys: |
${{ runner.os }}-jupyter-

# Build the book
- name: Build the book
shell: bash
run: |
uv run jupyter-book clean book
uv run jupyter-book build book
# Create this weird .nojekyll file
# We do this in the book action... This is the wrong place
# see https://jupyterbook.org/en/stable/publish/gh-pages.html#option-1-copy-and-paste-your-books-build-contents-into-a-new-folder
# touch book/_build/html/.nojekyll

# Upload the book
- name: Archive book
uses: actions/upload-artifact@v4
with:
name: book
path: book/_build/html/
retention-days: 1
book:
runs-on: "ubuntu-latest"
needs: [test, sphinx, jupyter]
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: cvxgrp/.github/actions/test@main
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Test
shell: bash
run: |
uv run pytest tests
74 changes: 65 additions & 9 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,80 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pre-commit/action@v3.0.1
with:
extra_args: '--verbose --all-files'

test:
runs-on: ubuntu-latest
steps:
- uses: cvxgrp/.github/actions/coverage@main
- uses: actions/checkout@v4

# Uncomment once the package is public
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
files: artifacts/tests/coverage/coverage.info
format: lcov
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Set up Pytest
run: uv pip install --no-cache-dir \
pytest \
pytest-cov \
pytest-html \
pytest-random-order


- name: Test on Linux
shell: bash
run: |
uv run pytest --cov='cvx' --random-order --verbose \
--html=artifacts/tests/html-report/report.html \
--cov-report term \
--cov-report xml:artifacts/tests/coverage/coverage.xml \
--cov-report json:artifacts/tests/coverage/coverage.json \
--cov-report lcov:artifacts/tests/coverage/coverage.info \
--cov-report html:artifacts/tests/html-coverage \
tests/

# I want to upload the result to gh-pages, hence this file disturbs
rm -f artifacts/tests/html-coverage/.gitignore
# Uncomment once the package is public
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
files: artifacts/tests/coverage/coverage.info
format: lcov

deptry:
runs-on: ubuntu-latest
steps:
- uses: cvxgrp/.github/actions/deptry@main
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Install deptry
shell: bash
run: |
uv pip install --no-cache-dir deptry

- name: Run deptry
shell: bash
run : |
uv run deptry 'cvx'
34 changes: 0 additions & 34 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,9 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
32 changes: 17 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ UNAME=$(shell uname -s)

.PHONY: install
install: ## Install a virtual environment
@poetry install -vv

@uv venv
@uv sync -vv
. .venv/bin/activate

.PHONY: fmt
fmt: ## Run autoformatting and linting
@poetry run pip install pre-commit
@poetry run pre-commit install
@poetry run pre-commit run --all-files
@uv run pip install pre-commit
@uv run pre-commit install
@uv run pre-commit run --all-files


.PHONY: test
test: install ## Run tests
@poetry run pytest
@uv run pytest


.PHONY: clean
Expand All @@ -28,9 +29,9 @@ clean: ## Clean up caches and build artifacts

.PHONY: coverage
coverage: install ## test and coverage
@poetry run coverage run --source=cvx/. -m pytest
@poetry run coverage report -m
@poetry run coverage html
@uv run coverage run --source=cvx/. -m pytest
@uv run coverage report -m
@uv run coverage html

@if [ ${UNAME} == "Darwin" ]; then \
open htmlcov/index.html; \
Expand All @@ -47,11 +48,12 @@ help: ## Display this help screen

.PHONY: jupyter
jupyter: install ## Start jupyter lab
@poetry run pip install jupyterlab
@poetry run jupyter lab
# @uvx tool install jupyterlab
@uv pip install jupyterlab
@uv run jupyter lab


.PHONY: boil
boil: ## Update the boilerplate code
@poetry run pip install cvxcooker
@poetry run cook pyproject.toml
#.PHONY: boil
#boil: ## Update the boilerplate code
# @poetry run pip install cvxcooker
# @poetry run cook pyproject.toml
Loading