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

build(uv): Lean on uv for all tasks within Makefile #316

Merged
merged 42 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
798aa61
Auto white space formatting
schloerke Oct 28, 2024
bfa0bae
Ignore `uv.lock`
schloerke Oct 28, 2024
39d99f2
Move requirements into pyproject.toml
schloerke Oct 28, 2024
4f26946
Add `VENV` to makefile vars
schloerke Oct 28, 2024
02bbe65
Remove `deps` target in favor of consolidated `dev` target
schloerke Oct 28, 2024
7013ada
Replace all `$(PYTHON) -m` with `$(UV) run` to force local venv
schloerke Oct 28, 2024
8c2b6e0
Update virtual env name
schloerke Oct 28, 2024
f90be40
Require a uv version
schloerke Oct 28, 2024
0f7740c
Use uv install groups
schloerke Oct 28, 2024
736ef34
Remove `make deps` calls. Remove pip cache. Autoformating
schloerke Oct 28, 2024
e10b742
Remove requirements files
schloerke Oct 29, 2024
1e353d1
Remove `package: posit` as top level package covers it
schloerke Oct 29, 2024
8446578
Make sure version has dev deps installed to calc version directly
schloerke Oct 29, 2024
fe67a36
Update .gitignore
schloerke Oct 29, 2024
ab55352
Only install quarto extensions if necessary
schloerke Oct 29, 2024
ae7c6fa
Activate uv env before running quartodoc or quarto commands
schloerke Oct 29, 2024
55f6f5f
Add setuptools as a package dep for the version
schloerke Oct 29, 2024
3fb419b
Add more dev pkgs
schloerke Oct 29, 2024
9ddbd5f
!: Remove support for python 3.8 (EOL)
schloerke Oct 29, 2024
845ccd6
Drop 3.8 in CI and docs
schloerke Oct 29, 2024
81c7bc0
Do not use uv system envvar; Use uv to install python
schloerke Oct 29, 2024
d280f65
Update site.yaml
schloerke Oct 29, 2024
96c2535
Activate UV before calling rsconnect
schloerke Oct 29, 2024
f3c1e9f
Update Makefile
schloerke Oct 29, 2024
5cd225c
Use UV to run quartodoc now that the system isn't being used
schloerke Oct 29, 2024
b38b830
Update CONTRIBUTING.md
schloerke Oct 29, 2024
6ceed86
Test on python 3.13
schloerke Oct 29, 2024
89a1608
Add back python 3.8 support and tests
schloerke Oct 29, 2024
1ea9dd8
Comment examples install group for now
schloerke Oct 29, 2024
b8047c8
Get quartodoc to install on the fly when building
schloerke Oct 29, 2024
5dede91
Collapse to a single target
schloerke Oct 29, 2024
c0f6bc8
Use uv tool run
schloerke Oct 29, 2024
1b6665a
Be sure to build before installing
schloerke Oct 29, 2024
3c14bb5
Use uv quiet param to produce no unexpected output for version
schloerke Oct 29, 2024
1dc01fc
Update Makefile
schloerke Oct 29, 2024
657d227
Update Makefile
schloerke Oct 29, 2024
6a3e3ea
Revert version change
schloerke Oct 29, 2024
d89cbdd
Remove `setuptools-scm` from direct deps
schloerke Oct 29, 2024
979afd8
Install project deps before copying src for faster builds
schloerke Oct 29, 2024
bde1ba3
Create the lock file if it does not exist
schloerke Oct 29, 2024
b01cb20
Make sure uv.lock exists
schloerke Oct 29, 2024
8d8c0ae
Add uv to integration CI
schloerke Oct 29, 2024
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
72 changes: 31 additions & 41 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_SYSTEM_PYTHON: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- run: make deps
- uses: astral-sh/setup-uv@v3
tdstein marked this conversation as resolved.
Show resolved Hide resolved
- run: uv python install
- run: make dev
- run: make lint
- run: make fmt

Expand All @@ -26,21 +21,18 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: 'pip'
- run: make deps
- run: make dev
- run: make test
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv python install ${{ matrix.python-version }}
- run: make dev
- run: make test

integration-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,18 +60,20 @@ jobs:
- 2022.12.0
- 2022.11.0
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Write Posit Connect license to disk
run: echo "$CONNECT_LICENSE" > ./integration/license.lic
env:
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
- run: make -C ./integration ${{ matrix.CONNECT_VERSION }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report
path: integration/reports/*.xml
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Write Posit Connect license to disk
run: echo "$CONNECT_LICENSE" > ./integration/license.lic
env:
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: make -C ./integration ${{ matrix.CONNECT_VERSION }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report
path: integration/reports/*.xml

integration-test-report:
needs: integration-test
Expand All @@ -99,15 +93,11 @@ jobs:
files: "artifacts/**/*.xml"
report_individual_runs: true


build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- run: make deps
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: make dev
- run: make build
14 changes: 4 additions & 10 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_SYSTEM_PYTHON: true
jobs:
cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- run: make deps
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: make dev
- run: make test
- run: make cov-xml
- if: ${{ ! github.event.pull_request.head.repo.fork }}
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 10 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@ on:
push:
tags:
- "v*.*.*"
env:
UV_SYSTEM_PYTHON: true
jobs:
default:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- uses: actions/setup-node@v4
- run: make deps
- run: make build
- run: make install
- id: release
uses: pypa/gh-action-pypi-publish@release/v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v3
- run: uv python install
- uses: actions/setup-node@v4
- run: make build
- run: make install
- id: release
uses: pypa/gh-action-pypi-publish@release/v1
22 changes: 5 additions & 17 deletions .github/workflows/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
- "v*.*.*"
pull_request:

env:
UV_SYSTEM_PYTHON: true

permissions:
id-token: write
pages: write
Expand All @@ -25,14 +22,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- run: make deps
- run: make build
- run: make install
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: make build install
- uses: quarto-dev/quarto-actions/setup@v2
- run: make docs
- uses: actions/configure-pages@v3
Expand All @@ -48,14 +40,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.x
check-latest: true
cache: 'pip'
- uses: astral-sh/setup-uv@v3
- run: uv python install
- uses: actions/setup-node@v4
- uses: quarto-dev/quarto-actions/setup@v2
- run: make deps
- run: make dev
- run: make docs
- id: preview
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
uv.lock

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -166,3 +167,5 @@ cython_debug/

# Ruff
.ruff_cache/

/.luarc.json
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `posit-sdk` is a software development kit (SDK) for working with Posit's pro

Before contributing to the `posit-sdk`, ensure that the following prerequisites are met:

- Python >=3.8
- Python >=3.9

> [!INFO]
> We require using virtual environments to maintain a clean and consistent development environment.
Expand All @@ -17,7 +17,7 @@ Before contributing to the `posit-sdk`, ensure that the following prerequisites
## Instructions

> [!WARNING]
> Executing `make` will install third-party packages in your Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands.
> Executing `make` will install third-party packages in your `.venv` virtual Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands.

1. Fork the repository and open it in your development environment.
2. Activate your Python environment (e.g., `source .venv/bin/activate`)
Expand All @@ -33,7 +33,7 @@ Use the default make target to execute the full build pipeline. For details on s

## Style Guide

We use [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting. Run `make deps` to install it.
We use [Ruff](https://docs.astral.sh/ruff/) for linting and code formatting.

All proposed changes must successfully pass the `make lint` rules prior to merging.

Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM python:3

ENV UV_SYSTEM_PYTHON=true

RUN apt-get update && apt-get install -y make

WORKDIR /sdk

COPY Makefile pyproject.toml requirements.txt requirements-dev.txt vars.mk ./
COPY Makefile pyproject.toml vars.mk uv.lock ./

RUN --mount=type=cache,mode=0755,target=/root/.cache/pip make deps
# Run before `COPY src src` to cache dependencies for faster iterative builds
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip make docker-deps

COPY .git .git
COPY src src
Expand Down
65 changes: 38 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ include vars.mk

.DEFAULT_GOAL := all

.PHONY: build clean cov default deps dev docs ensure-uv fmt fix install it lint test uninstall version help
.PHONY: build clean cov default dev docker-deps docs ensure-uv fmt fix install it lint test uninstall version help

all: deps dev test lint build
all: dev test lint build

build:
build: dev
$(UV) build

clean:
Expand All @@ -19,62 +19,73 @@ clean:
find . -name "__pycache__" -exec rm -rf {} +
find . -type d -empty -delete

cov:
$(PYTHON) -m coverage report
cov: dev
$(UV) run coverage report

cov-html:
$(PYTHON) -m coverage html
cov-html: dev
$(UV) run coverage html
open htmlcov/index.html

cov-xml:
$(PYTHON) -m coverage xml

deps: ensure-uv
$(UV) pip install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt
cov-xml: dev
$(UV) run coverage xml

dev: ensure-uv
$(UV) pip install -e .

docs:
docker-deps: ensure-uv
# Sync given the `uv.lock` file
# --frozen : assert that the lock file exists
# --no-install-project : do not install the project itself, but install its dependencies
$(UV) sync --frozen --no-install-project

docs: ensure-uv
$(MAKE) -C ./docs

$(VIRTUAL_ENV):
$(UV) venv $(VIRTUAL_ENV)
ensure-uv:
@if ! command -v $(UV) >/dev/null; then \
$(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \
$(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \
schloerke marked this conversation as resolved.
Show resolved Hide resolved
fi
@# Install virtual environment (before calling `uv pip install ...`)
@$(MAKE) $(VIRTUAL_ENV) 1>/dev/null
@# Be sure recent uv is installed
@$(UV) pip install "uv >= 0.4.27" --quiet

fmt:
$(PYTHON) -m ruff check --fix
$(PYTHON) -m ruff format
fmt: dev
schloerke marked this conversation as resolved.
Show resolved Hide resolved
$(UV) run ruff check --fix
$(UV) run ruff format

install: ensure-uv
install: build
$(UV) pip install dist/*.whl

it:
$(UV_LOCK): dev
$(UV) lock
it: $(UV_LOCK)
$(MAKE) -C ./integration

lint:
$(PYTHON) -m pyright
$(PYTHON) -m ruff check
lint: dev
$(UV) run pyright
$(UV) run ruff check

test:
$(PYTHON) -m coverage run --source=src -m pytest tests
test: dev
$(UV) run coverage run --source=src -m pytest tests

uninstall: ensure-uv
$(UV) pip uninstall $(PROJECT_NAME)

version:
@$(PYTHON) -m setuptools_scm
@$(MAKE) ensure-uv &>/dev/null
@$(UV) run --quiet --with "setuptools_scm" python -m setuptools_scm
schloerke marked this conversation as resolved.
Show resolved Hide resolved

help:
@echo "Makefile Targets"
@echo " all Run deps, dev, test, lint, and build"
@echo " all Run dev, test, lint, and build"
@echo " build Build the project"
@echo " clean Clean up project artifacts"
@echo " cov Generate a coverage report"
@echo " cov-html Generate an HTML coverage report and open it"
@echo " cov-xml Generate an XML coverage report"
@echo " deps Install dependencies"
@echo " dev Install the project in editable mode"
@echo " docs Build the documentation"
@echo " ensure-uv Ensure 'uv' is installed"
Expand Down
Loading