Skip to content

Commit 25cfa78

Browse files
switch to using uv for project management (#127)
1 parent a2e96f8 commit 25cfa78

File tree

9 files changed

+1032
-280
lines changed

9 files changed

+1032
-280
lines changed

.envrc

-1
This file was deleted.

.github/workflows/examples.yml

+32-6
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ on:
77
- "examples/**.yml"
88
- "src/**"
99
- "copier.yml"
10+
workflow_call:
1011
workflow_dispatch:
1112

1213
concurrency:
13-
group: ${{ github.workflow }}-${{ github.head_ref }}
14+
group: examples-${{ github.head_ref }}
1415
cancel-in-progress: true
1516

1617
env:
1718
PYTHONUNBUFFERED: "1"
1819
FORCE_COLOR: "1"
1920

2021
jobs:
21-
examples:
22+
generate:
2223
runs-on: ubuntu-latest
2324
steps:
2425
- uses: actions/checkout@v4
2526

2627
- uses: extractions/setup-just@v2
2728

28-
- uses: westerveltco/setup-ci-action@v0
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v3
2931
with:
30-
python-version: "3.8"
31-
python-requirements: requirements-dev.lock
32-
use-uv: true
32+
enable-cache: true
33+
version: "0.4.x"
3334

3435
- name: Setup Git
3536
run: |
@@ -40,6 +41,31 @@ jobs:
4041
run: |
4142
just generate-examples
4243
44+
- name: Upload examples artifact
45+
if: github.event_name != 'pull_request'
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: generated-examples
49+
path: examples/
50+
51+
update-repo:
52+
needs: generate
53+
if: github.event_name != 'pull_request'
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Download examples artifact
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: generated-examples
62+
path: examples/
63+
64+
- name: Setup Git
65+
run: |
66+
git config --global user.name "GitHub Actions"
67+
git config --global user.email "[email protected]"
68+
4369
- name: Get SHA of push commit
4470
id: shortsha
4571
run: echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

.github/workflows/test.yml

+7-26
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77

88
concurrency:
9-
group: ${{ github.workflow }}-${{ github.head_ref }}
9+
group: test-${{ github.head_ref }}
1010
cancel-in-progress: true
1111

1212
env:
@@ -19,34 +19,15 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- uses: westerveltco/setup-ci-action@v0
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v3
2324
with:
24-
python-version: "3.8"
25-
python-requirements: requirements-dev.lock
26-
use-uv: true
25+
enable-cache: true
26+
version: "0.4.x"
2727

2828
- name: Run tests
2929
run: |
30-
python -m pytest
30+
uv run pytest
3131
3232
examples:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v4
36-
37-
- uses: extractions/setup-just@v2
38-
39-
- uses: westerveltco/setup-ci-action@v0
40-
with:
41-
python-version: "3.8"
42-
python-requirements: requirements-dev.lock
43-
use-uv: true
44-
45-
- name: Setup Git
46-
run: |
47-
git config --global user.name "GitHub Actions"
48-
git config --global user.email "[email protected]"
49-
50-
- name: Generate examples
51-
run: |
52-
just generate-examples
33+
uses: ./.github/workflows/examples.yml

Justfile

+21-32
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,36 @@
11
set dotenv-load := true
2+
set unstable := true
23

3-
@_default:
4-
just --list
4+
[private]
5+
default:
6+
@just --list
57

6-
bootstrap *ARGS:
7-
rye sync {{ ARGS }}
8-
9-
lock *ARGS:
10-
rye lock {{ ARGS }}
11-
12-
# ----------------------------------------------------------------------
13-
# EXAMPLES
14-
# ----------------------------------------------------------------------
15-
16-
# generate all examples from examples/*.yml copier answer files
17-
@generate-examples:
18-
for file in `ls examples/*.yml`; do \
19-
just _generate-example $file; \
20-
done
8+
[private]
9+
fmt:
10+
@just --fmt
2111

22-
_generate-example DATA_FILE:
12+
[private]
13+
@generate-example DATA_FILE:
2314
#!/usr/bin/env bash
2415

2516
set -euo pipefail
2617

2718
DIRECTORY="{{ trim_end_match(DATA_FILE, '.yml') }}"
2819
rm -rf $DIRECTORY
2920

30-
COMMAND="copier copy -r HEAD . $DIRECTORY --force --trust --data-file {{ DATA_FILE }}"
31-
if [ -z "$(command -v rye)" ]; then
32-
eval $COMMAND
33-
else
34-
rye run $COMMAND
35-
fi
21+
uv run copier copy -r HEAD . $DIRECTORY --force --trust --data-file {{ DATA_FILE }}
3622

37-
# ----------------------------------------------------------------------
38-
# UTILS
39-
# ----------------------------------------------------------------------
23+
bootstrap:
24+
uv python install
25+
uv sync --frozen
4026

41-
# format justfile
42-
fmt:
43-
just --fmt --unstable
27+
generate-examples:
28+
for file in `ls examples/*.yml`; do \
29+
just generate-example $file; \
30+
done
4431

45-
# run pre-commit on all files
4632
lint:
47-
rye run pre-commit run --all-files
33+
uv run --with pre-commit-uv pre-commit run --all-files
34+
35+
lock *ARGS:
36+
uv lock {{ ARGS }}

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# django-twc-package
22

3-
[![Rye](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/mitsuhiko/rye/main/artwork/badge.json)](https://rye-up.com)
43
[![Copier](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/joshuadavidthomas/7c88611504b557ff7aa2a7524ad996e2/raw/4ba6834953dd8a14afc3dbb7bb41f49f181a59bf/badge.json)](https://copier.readthedocs.io)
54

65
`django-twc-package` is the template for a Django package at The Westervelt Company. This template is a starting point for creating a new Django package that can be installed and used in other projects.

pyproject.toml

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
[build-system]
2-
build-backend = "hatchling.build"
3-
requires = ["hatchling"]
4-
51
[project]
62
authors = [{name = "Josh", email = "[email protected]"}]
7-
dependencies = ["copier>=9.1.1", "copier-templates-extensions>=0.3.0"]
3+
dependencies = [
4+
"copier>=9.1.1",
5+
"copier-templates-extensions>=0.3.0"
6+
]
87
description = "A Django package template for The Westervelt Company."
98
dynamic = ["version"]
109
license = {file = "LICENSE"}
@@ -25,13 +24,6 @@ version_pattern = "YYYY.INC1"
2524
"copier.yml" = ['default: "{version}"']
2625
"tests/test_version.py" = ['assert version == "{version}"']
2726

28-
[tool.hatch.metadata]
29-
allow-direct-references = true
30-
31-
[tool.hatch.version]
32-
path = "VERSION"
33-
pattern = "^(?P<version>[0-9]+(?:\\.[0-9]+)*)$"
34-
3527
[tool.pytest.ini_options]
3628
addopts = "-n auto --dist loadfile --doctest-modules"
3729
norecursedirs = ".* bin build dist *.egg examples htmlcov logs node_modules src templates venv"
@@ -103,7 +95,7 @@ required-imports = ["from __future__ import annotations"]
10395
# Preserve types, even if a file imports `from __future__ import annotations`.
10496
keep-runtime-typing = true
10597

106-
[tool.rye]
98+
[tool.uv]
10799
dev-dependencies = [
108100
"bumpver>=2023.1129",
109101
"djlint>=1.34.1",
@@ -115,5 +107,3 @@ dev-dependencies = [
115107
"jinja2>=3.1.3",
116108
"pre-commit>=3.5.0"
117109
]
118-
managed = true
119-
virtual = true

requirements-dev.lock

-138
This file was deleted.

0 commit comments

Comments
 (0)