Skip to content

Commit 14922d2

Browse files
authored
build(uv): Lean on uv for all tasks within Makefile (#316)
1 parent 9e4f173 commit 14922d2

File tree

17 files changed

+149
-154
lines changed

17 files changed

+149
-154
lines changed

.github/workflows/ci.yaml

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ on:
44
concurrency:
55
group: ${{ github.workflow }}-${{ github.ref }}
66
cancel-in-progress: true
7-
env:
8-
UV_SYSTEM_PYTHON: true
97
jobs:
108
lint:
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
15-
with:
16-
python-version: 3.x
17-
check-latest: true
18-
cache: 'pip'
19-
- run: make deps
12+
- uses: astral-sh/setup-uv@v3
13+
- run: uv python install
14+
- run: make dev
2015
- run: make lint
2116
- run: make fmt
2217

@@ -26,21 +21,18 @@ jobs:
2621
fail-fast: false
2722
matrix:
2823
python-version:
29-
- '3.8'
30-
- '3.9'
31-
- '3.10'
32-
- '3.11'
33-
- '3.12'
24+
- "3.8"
25+
- "3.9"
26+
- "3.10"
27+
- "3.11"
28+
- "3.12"
29+
- "3.13"
3430
steps:
35-
- uses: actions/checkout@v4
36-
- uses: actions/setup-python@v5
37-
with:
38-
python-version: ${{ matrix.python-version }}
39-
check-latest: true
40-
cache: 'pip'
41-
- run: make deps
42-
- run: make dev
43-
- run: make test
31+
- uses: actions/checkout@v4
32+
- uses: astral-sh/setup-uv@v3
33+
- run: uv python install ${{ matrix.python-version }}
34+
- run: make dev
35+
- run: make test
4436

4537
integration-test:
4638
runs-on: ubuntu-latest
@@ -68,18 +60,20 @@ jobs:
6860
- 2022.12.0
6961
- 2022.11.0
7062
steps:
71-
- uses: actions/checkout@v4
72-
- uses: docker/setup-buildx-action@v3
73-
- name: Write Posit Connect license to disk
74-
run: echo "$CONNECT_LICENSE" > ./integration/license.lic
75-
env:
76-
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
77-
- run: make -C ./integration ${{ matrix.CONNECT_VERSION }}
78-
- uses: actions/upload-artifact@v4
79-
if: always()
80-
with:
81-
name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report
82-
path: integration/reports/*.xml
63+
- uses: actions/checkout@v4
64+
- uses: docker/setup-buildx-action@v3
65+
- name: Write Posit Connect license to disk
66+
run: echo "$CONNECT_LICENSE" > ./integration/license.lic
67+
env:
68+
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
69+
- uses: astral-sh/setup-uv@v3
70+
- run: uv python install
71+
- run: make -C ./integration ${{ matrix.CONNECT_VERSION }}
72+
- uses: actions/upload-artifact@v4
73+
if: always()
74+
with:
75+
name: ${{ matrix.CONNECT_VERSION }} - Integration Test Report
76+
path: integration/reports/*.xml
8377

8478
integration-test-report:
8579
needs: integration-test
@@ -99,15 +93,11 @@ jobs:
9993
files: "artifacts/**/*.xml"
10094
report_individual_runs: true
10195

102-
10396
build:
10497
runs-on: ubuntu-latest
10598
steps:
10699
- uses: actions/checkout@v4
107-
- uses: actions/setup-python@v5
108-
with:
109-
python-version: 3.x
110-
check-latest: true
111-
cache: 'pip'
112-
- run: make deps
100+
- uses: astral-sh/setup-uv@v3
101+
- run: uv python install
102+
- run: make dev
113103
- run: make build

.github/workflows/coverage.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,18 @@ on:
44
concurrency:
55
group: ${{ github.workflow }}-${{ github.ref }}
66
cancel-in-progress: true
7-
env:
8-
UV_SYSTEM_PYTHON: true
97
jobs:
108
cov:
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
15-
with:
16-
python-version: 3.x
17-
check-latest: true
18-
cache: 'pip'
19-
- run: make deps
12+
- uses: astral-sh/setup-uv@v3
13+
- run: uv python install
2014
- run: make dev
2115
- run: make test
2216
- run: make cov-xml
2317
- if: ${{ ! github.event.pull_request.head.repo.fork }}
2418
uses: orgoro/[email protected]
2519
with:
26-
coverageFile: coverage.xml
27-
token: ${{ secrets.GITHUB_TOKEN }}
20+
coverageFile: coverage.xml
21+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,19 @@ on:
33
push:
44
tags:
55
- "v*.*.*"
6-
env:
7-
UV_SYSTEM_PYTHON: true
86
jobs:
97
default:
108
runs-on: ubuntu-latest
119
permissions:
1210
id-token: write
1311
steps:
14-
- uses: actions/checkout@v4
15-
with:
16-
fetch-depth: 0
17-
- uses: actions/setup-python@v5
18-
with:
19-
python-version: 3.x
20-
check-latest: true
21-
cache: 'pip'
22-
- uses: actions/setup-node@v4
23-
- run: make deps
24-
- run: make build
25-
- run: make install
26-
- id: release
27-
uses: pypa/gh-action-pypi-publish@release/v1
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- uses: astral-sh/setup-uv@v3
16+
- run: uv python install
17+
- uses: actions/setup-node@v4
18+
- run: make build
19+
- run: make install
20+
- id: release
21+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/site.yaml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
- "v*.*.*"
77
pull_request:
88

9-
env:
10-
UV_SYSTEM_PYTHON: true
11-
129
permissions:
1310
id-token: write
1411
pages: write
@@ -25,14 +22,9 @@ jobs:
2522
- uses: actions/checkout@v4
2623
with:
2724
fetch-depth: 0
28-
- uses: actions/setup-python@v5
29-
with:
30-
python-version: 3.x
31-
check-latest: true
32-
cache: 'pip'
33-
- run: make deps
34-
- run: make build
35-
- run: make install
25+
- uses: astral-sh/setup-uv@v3
26+
- run: uv python install
27+
- run: make build install
3628
- uses: quarto-dev/quarto-actions/setup@v2
3729
- run: make docs
3830
- uses: actions/configure-pages@v3
@@ -48,14 +40,10 @@ jobs:
4840
- uses: actions/checkout@v4
4941
with:
5042
fetch-depth: 0
51-
- uses: actions/setup-python@v5
52-
with:
53-
python-version: 3.x
54-
check-latest: true
55-
cache: 'pip'
43+
- uses: astral-sh/setup-uv@v3
44+
- run: uv python install
5645
- uses: actions/setup-node@v4
5746
- uses: quarto-dev/quarto-actions/setup@v2
58-
- run: make deps
5947
- run: make dev
6048
- run: make docs
6149
- id: preview

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ share/python-wheels/
2727
.installed.cfg
2828
*.egg
2929
MANIFEST
30+
uv.lock
3031

3132
# PyInstaller
3233
# Usually these files are written by a python script from a template
@@ -166,3 +167,5 @@ cython_debug/
166167

167168
# Ruff
168169
.ruff_cache/
170+
171+
/.luarc.json

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The `posit-sdk` is a software development kit (SDK) for working with Posit's pro
88

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

11-
- Python >=3.8
11+
- Python >=3.9
1212

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

1919
> [!WARNING]
20-
> Executing `make` will install third-party packages in your Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands.
20+
> 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.
2121
2222
1. Fork the repository and open it in your development environment.
2323
2. Activate your Python environment (e.g., `source .venv/bin/activate`)
@@ -33,7 +33,7 @@ Use the default make target to execute the full build pipeline. For details on s
3333

3434
## Style Guide
3535

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

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

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
FROM python:3
22

3-
ENV UV_SYSTEM_PYTHON=true
4-
53
RUN apt-get update && apt-get install -y make
64

75
WORKDIR /sdk
86

9-
COPY Makefile pyproject.toml requirements.txt requirements-dev.txt vars.mk ./
7+
COPY Makefile pyproject.toml vars.mk uv.lock ./
108

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

1312
COPY .git .git
1413
COPY src src

Makefile

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ include vars.mk
22

33
.DEFAULT_GOAL := all
44

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

7-
all: deps dev test lint build
7+
all: dev test lint build
88

9-
build:
9+
build: dev
1010
$(UV) build
1111

1212
clean:
@@ -19,62 +19,73 @@ clean:
1919
find . -name "__pycache__" -exec rm -rf {} +
2020
find . -type d -empty -delete
2121

22-
cov:
23-
$(PYTHON) -m coverage report
22+
cov: dev
23+
$(UV) run coverage report
2424

25-
cov-html:
26-
$(PYTHON) -m coverage html
25+
cov-html: dev
26+
$(UV) run coverage html
2727
open htmlcov/index.html
2828

29-
cov-xml:
30-
$(PYTHON) -m coverage xml
31-
32-
deps: ensure-uv
33-
$(UV) pip install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt
29+
cov-xml: dev
30+
$(UV) run coverage xml
3431

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

38-
docs:
35+
docker-deps: ensure-uv
36+
# Sync given the `uv.lock` file
37+
# --frozen : assert that the lock file exists
38+
# --no-install-project : do not install the project itself, but install its dependencies
39+
$(UV) sync --frozen --no-install-project
40+
41+
docs: ensure-uv
3942
$(MAKE) -C ./docs
4043

44+
$(VIRTUAL_ENV):
45+
$(UV) venv $(VIRTUAL_ENV)
4146
ensure-uv:
4247
@if ! command -v $(UV) >/dev/null; then \
43-
$(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \
48+
$(PYTHON) -m ensurepip && $(PYTHON) -m pip install "uv >= 0.4.27"; \
4449
fi
50+
@# Install virtual environment (before calling `uv pip install ...`)
51+
@$(MAKE) $(VIRTUAL_ENV) 1>/dev/null
52+
@# Be sure recent uv is installed
53+
@$(UV) pip install "uv >= 0.4.27" --quiet
4554

46-
fmt:
47-
$(PYTHON) -m ruff check --fix
48-
$(PYTHON) -m ruff format
55+
fmt: dev
56+
$(UV) run ruff check --fix
57+
$(UV) run ruff format
4958

50-
install: ensure-uv
59+
install: build
5160
$(UV) pip install dist/*.whl
5261

53-
it:
62+
$(UV_LOCK): dev
63+
$(UV) lock
64+
it: $(UV_LOCK)
5465
$(MAKE) -C ./integration
5566

56-
lint:
57-
$(PYTHON) -m pyright
58-
$(PYTHON) -m ruff check
67+
lint: dev
68+
$(UV) run pyright
69+
$(UV) run ruff check
5970

60-
test:
61-
$(PYTHON) -m coverage run --source=src -m pytest tests
71+
test: dev
72+
$(UV) run coverage run --source=src -m pytest tests
6273

6374
uninstall: ensure-uv
6475
$(UV) pip uninstall $(PROJECT_NAME)
6576

6677
version:
67-
@$(PYTHON) -m setuptools_scm
78+
@$(MAKE) ensure-uv &>/dev/null
79+
@$(UV) run --quiet --with "setuptools_scm" python -m setuptools_scm
6880

6981
help:
7082
@echo "Makefile Targets"
71-
@echo " all Run deps, dev, test, lint, and build"
83+
@echo " all Run dev, test, lint, and build"
7284
@echo " build Build the project"
7385
@echo " clean Clean up project artifacts"
7486
@echo " cov Generate a coverage report"
7587
@echo " cov-html Generate an HTML coverage report and open it"
7688
@echo " cov-xml Generate an XML coverage report"
77-
@echo " deps Install dependencies"
7889
@echo " dev Install the project in editable mode"
7990
@echo " docs Build the documentation"
8091
@echo " ensure-uv Ensure 'uv' is installed"

0 commit comments

Comments
 (0)