Skip to content

Commit 702b3ac

Browse files
committed
Application build, test, and lint with uv
Why these changes are being introduced: This is the first pass in migrating to uv from pipenv. How this addresses that need: * Removes Pipfile and Pipfile.lock * Updates pyproject.toml to be a valid uv project * All dependencies handled via 'uv add' and exist in pyproject.toml * Makefile and pre-commits updated to use uv syntax * Github actions *temporarily* hardcoded in local workflows, with a TODO to move these to a shared workflow when things settle down * Bumps python to 3.13 Side effects of this change: * Many! Hard pivot from Pipenv installation and running of the application. At this time, the largest side effect is the loss of 'pipenv run <appname>'. A future commit will apply a new strategy, but that is not present now. A workaround is 'uv run my_app/cli.py`. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/IN-1425
1 parent c754e9b commit 702b3ac

File tree

9 files changed

+789
-833
lines changed

9 files changed

+789
-833
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@ name: CI
22
on: push
33
jobs:
44
test:
5-
uses: mitlibraries/.github/.github/workflows/python-shared-test.yml@main
5+
# TODO: move this into a shared workflow, https://github.com/MITLibraries/.github/tree/main/.github/workflows
6+
name: Run tests and report coverage
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Install uv
12+
uses: astral-sh/setup-uv@v6
13+
14+
- name: Create virtual environment
15+
run: |
16+
make install
17+
18+
- name: Run tests and make coverage report
19+
run: |
20+
make test
21+
make coveralls
22+
23+
- name: Coveralls
24+
uses: coverallsapp/[email protected]
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
fail-on-error: false
628
lint:
7-
uses: mitlibraries/.github/.github/workflows/python-shared-lint.yml@main
29+
# TODO: move this into a shared workflow, https://github.com/MITLibraries/.github/tree/main/.github/workflows
30+
name: Run linters
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v6
37+
38+
- name: Create virtual environment
39+
run: |
40+
make install
41+
42+
- name: Lint
43+
run: make lint

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
default_language_version:
2-
python: python3.12 # set for project python version
2+
python: python3.13
33
repos:
44
- repo: local
55
hooks:
66
- id: black-apply
77
name: black-apply
8-
entry: pipenv run black
8+
entry: uv run black
99
language: system
1010
pass_filenames: true
1111
types: ["python"]
1212
- id: mypy
1313
name: mypy
14-
entry: pipenv run mypy
14+
entry: uv run mypy
1515
language: system
1616
pass_filenames: true
1717
types: ["python"]
1818
exclude: "tests/"
1919
- id: ruff-apply
2020
name: ruff-apply
21-
entry: pipenv run ruff check --fix
21+
entry: uv run ruff check --fix
2222
language: system
2323
pass_filenames: true
2424
types: ["python"]
2525
- id: pip-audit
2626
name: pip-audit
27-
entry: pipenv run pip-audit
27+
entry: uv run pip-audit
2828
language: system
2929
pass_filenames: false

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12
1+
3.13

Makefile

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,40 @@ help: # Preview Makefile commands
55
@awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \
66
/^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST)
77

8-
#######################
9-
# Dependency commands
10-
#######################
8+
# ensure OS binaries aren't called if naming conflict with Make recipes
9+
.PHONY: help venv install update test coveralls lint black mypy ruff safety lint-apply black-apply ruff-apply
1110

12-
install: # Install Python dependencies
13-
pipenv install --dev
14-
pipenv run pre-commit install
11+
##############################################
12+
# Python Environment and Dependency commands
13+
##############################################
1514

16-
update: install # Update Python dependencies
17-
pipenv clean
18-
pipenv update --dev
15+
install: .venv .git/hooks/pre-commit # Install Python dependencies and create virtual environment if not exists
16+
uv sync --dev
17+
18+
.venv: # Creates virtual environment if not found
19+
@echo "Creating virtual environment at .venv..."
20+
uv venv .venv
21+
22+
.git/hooks/pre-commit: # Sets up pre-commit hook if not setup
23+
@echo "Installing pre-commit hooks..."
24+
uv run pre-commit install
25+
26+
venv: .venv # Create the Python virtual environment
27+
28+
update: # Update Python dependencies
29+
uv lock --upgrade
30+
uv sync --dev
1931

2032
######################
2133
# Unit test commands
2234
######################
2335

2436
test: # Run tests and print a coverage report
25-
pipenv run coverage run --source=my_app -m pytest -vv
26-
pipenv run coverage report -m
37+
uv run coverage run --source=my_app -m pytest -vv
38+
uv run coverage report -m
2739

2840
coveralls: test # Write coverage data to an LCOV report
29-
pipenv run coverage lcov -o ./coverage/lcov.info
41+
uv run coverage lcov -o ./coverage/lcov.info
3042

3143
####################################
3244
# Code quality and safety commands
@@ -35,23 +47,21 @@ coveralls: test # Write coverage data to an LCOV report
3547
lint: black mypy ruff safety # Run linters
3648

3749
black: # Run 'black' linter and print a preview of suggested changes
38-
pipenv run black --check --diff .
50+
uv run black --check --diff .
3951

4052
mypy: # Run 'mypy' linter
41-
pipenv run mypy .
53+
uv run mypy .
4254

4355
ruff: # Run 'ruff' linter and print a preview of errors
44-
pipenv run ruff check .
56+
uv run ruff check .
4557

46-
safety: # Check for security vulnerabilities and verify Pipfile.lock is up-to-date
47-
pipenv run pip-audit
48-
pipenv verify
58+
safety: # Check for security vulnerabilities
59+
uv run pip-audit
4960

50-
lint-apply: # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'
51-
black-apply ruff-apply
61+
lint-apply: black-apply ruff-apply # Apply changes with 'black' and resolve 'fixable errors' with 'ruff'
5262

5363
black-apply: # Apply changes with 'black'
54-
pipenv run black .
64+
uv run black .
5565

5666
ruff-apply: # Resolve 'fixable errors' with 'ruff'
57-
pipenv run ruff check --fix .
67+
uv run ruff check --fix .

Pipfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)