Skip to content

Commit de0b1c6

Browse files
authored
Switch to uv (#34)
1 parent 875344d commit de0b1c6

File tree

10 files changed

+1605
-135
lines changed

10 files changed

+1605
-135
lines changed

.github/workflows/ci.yml

+55-61
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ on:
88
- '**'
99
pull_request: {}
1010

11+
env:
12+
CI: true
13+
COLUMNS: 120
14+
UV_PYTHON: 3.12
15+
UV_FROZEN: '1'
16+
1117
jobs:
1218
server-lint:
1319
runs-on: ubuntu-latest
1420

1521
steps:
16-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
1723

18-
- uses: actions/setup-node@v3
24+
- uses: actions/setup-node@v4
1925
with:
2026
node-version: '18.x'
2127

@@ -27,89 +33,83 @@ jobs:
2733
runs-on: ubuntu-latest
2834

2935
steps:
30-
- uses: actions/checkout@v3
36+
- uses: actions/checkout@v4
3137

32-
- uses: actions/setup-python@v4
38+
- uses: astral-sh/setup-uv@v5
3339
with:
34-
python-version: '3.11'
35-
36-
- name: install
37-
run: |
38-
pip install -U pip
39-
pip install -r requirements/cli.txt
40+
enable-cache: true
4041

41-
- run: make lint
42-
working-directory: cli
43-
- run: make mypy
42+
- run: uv sync
4443
working-directory: cli
4544

45+
- uses: pre-commit/action@v3.0.0
46+
with:
47+
extra_args: --all-files --verbose
48+
env:
49+
SKIP: lint-js
50+
4651
cli-test:
4752
name: cli-test-${{ matrix.os }}-py${{ matrix.python-version }}
4853
strategy:
4954
fail-fast: false
5055
matrix:
5156
os: [ubuntu, macos]
52-
python-version: ['3.8', '3.9', '3.10', '3.11']
57+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
5358

5459
runs-on: ${{ matrix.os }}-latest
60+
env:
61+
UV_PYTHON: ${{ matrix.python-version }}
5562

5663
steps:
57-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
5865

59-
- name: set up python
60-
uses: actions/setup-python@v4
66+
- uses: astral-sh/setup-uv@v5
6167
with:
62-
python-version: ${{ matrix.python-version }}
63-
64-
- name: install
65-
run: |
66-
pip install -U pip
67-
pip install -r requirements/cli.txt
68-
- run: pip freeze
68+
enable-cache: true
6969

70-
- name: test
71-
working-directory: cli
72-
run: make test
70+
- run: mkdir coverage
7371

74-
- name: rename coverage
72+
- run: uv run coverage run -m pytest
7573
working-directory: cli
76-
run: |
77-
mkdir coverage
78-
mv .coverage coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }}
74+
env:
75+
COVERAGE_FILE: ../coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }}
7976

8077
- name: store coverage files
81-
uses: actions/upload-artifact@v3
78+
uses: actions/upload-artifact@v4
8279
with:
83-
name: coverage
84-
path: cli/coverage
80+
name: coverage-${{ matrix.os }}-py${{ matrix.python-version }}
81+
path: coverage
82+
include-hidden-files: true
8583

8684
cli-coverage-check:
8785
# dogfooding! use smokeshow to view our coverage report
8886
needs: [cli-test]
8987
runs-on: ubuntu-latest
9088

9189
steps:
92-
- uses: actions/checkout@v3
90+
- uses: actions/checkout@v4
9391

94-
- uses: actions/setup-python@v4
92+
- uses: astral-sh/setup-uv@v5
9593
with:
96-
python-version: '3.11'
94+
enable-cache: true
9795

9896
- name: get coverage files
99-
uses: actions/download-artifact@v2
97+
uses: actions/download-artifact@v4
10098
with:
101-
name: coverage
99+
merge-multiple: true
102100
path: cli
103101

104-
- run: pip install coverage smokeshow
102+
- run: uv sync
103+
working-directory: cli
105104

106105
- name: build coverage
107-
working-directory: cli
108106
run: |
109-
coverage combine
110-
coverage html -i
107+
uv run coverage combine
108+
uv run coverage html -i
109+
working-directory: cli
111110

112-
- run: smokeshow upload cli/htmlcov
111+
- run: uv run -m smokeshow upload htmlcov
112+
working-directory: cli
113113
env:
114114
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: CLI Coverage {coverage-percentage}
115115
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90
@@ -122,7 +122,7 @@ jobs:
122122
environment: cloudflare-staging-deploy
123123

124124
steps:
125-
- uses: actions/checkout@v3
125+
- uses: actions/checkout@v4
126126

127127
- uses: cloudflare/wrangler-action@v3
128128
with:
@@ -153,7 +153,7 @@ jobs:
153153
environment: cloudflare-production-deploy
154154

155155
steps:
156-
- uses: actions/checkout@v3
156+
- uses: actions/checkout@v4
157157

158158
- uses: cloudflare/wrangler-action@v3
159159
with:
@@ -176,27 +176,21 @@ jobs:
176176
id-token: write
177177

178178
steps:
179-
- uses: actions/checkout@v3
179+
- uses: actions/checkout@v4
180180

181-
- name: set up python
182-
uses: actions/setup-python@v4
181+
- uses: astral-sh/setup-uv@v5
183182
with:
184-
python-version: '3.11'
183+
enable-cache: true
185184

186-
- name: install
187-
run: pip install -U build
188-
189-
- name: check version
190-
id: check-version
191-
uses: samuelcolvin/check-python-version@v4
185+
- name: check GITHUB_REF matches package version
186+
uses: samuelcolvin/check-python-version@v4.1
192187
with:
193-
version_file_path: 'cli/smokeshow/version.py'
188+
version_file_path: 'cli/pyproject.toml'
194189

195-
- name: build
196-
working-directory: cli
197-
run: python -m build
190+
- run: uv build
198191

199-
- name: Upload package to PyPI
192+
- name: Publish to PyPI
200193
uses: pypa/gh-action-pypi-publish@release/v1
201194
with:
195+
skip-existing: true
202196
packages-dir: cli/dist/

.pre-commit-config.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ repos:
1616
types: [javascript]
1717
language: system
1818
pass_filenames: false
19+
- id: format-python
20+
name: Format Python
21+
entry: make -C cli lint
22+
types: [python]
23+
language: system
24+
pass_filenames: false
1925
- id: lint-python
2026
name: Lint Python
2127
entry: make -C cli lint
2228
types: [python]
2329
language: system
2430
pass_filenames: false
25-
- id: mypy
26-
name: Mypy
27-
entry: make -C cli mypy
31+
- id: typecheck
32+
name: Typecheck Python
33+
entry: make -C cli typecheck
2834
types: [python]
2935
language: system
3036
pass_filenames: false

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
.PHONY: install
44
install:
5-
pip install -U pip pip-tools pre-commit
6-
pip install -U -r requirements/cli.txt
5+
make -C cli install
76
pre-commit install
87

98
.PHONY: format-js

cli/.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/env/
2-
/env37/
1+
/.venv/
32
/build/
43
/htmlcov/
5-
*.lock
64
*.py[cod]
75
*.egg-info/
86
.cache/
97
.mypy_cache/
108
/upload.sh
9+
.python-version

cli/Makefile

+24-29
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,45 @@
11
.DEFAULT_GOAL := all
22
sources = smokeshow tests
33

4+
.PHONY: .uv
5+
.uv:
6+
@uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
7+
8+
.PHONY: .pre-commit
9+
.pre-commit:
10+
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'
11+
12+
.PHONY: install
13+
install: .uv .pre-commit
14+
uv sync --frozen
15+
416
.PHONY: format
517
format:
6-
ruff --fix-only $(sources)
7-
black $(sources)
18+
uv run ruff format
19+
uv run ruff check --fix --fix-only
820

921
.PHONY: lint
1022
lint:
11-
ruff $(sources)
12-
black $(sources) --check --diff
23+
uv run ruff format --check
24+
uv run ruff check
1325

14-
.PHONY: mypy
15-
mypy:
16-
mypy --version
17-
mypy smokeshow
26+
.PHONY: typecheck
27+
typecheck:
28+
uv run pyright --version
29+
uv run pyright smokeshow
1830

1931
.PHONY: test
2032
test:
21-
coverage run -m pytest
33+
uv run coverage run -m pytest
2234

2335
.PHONY: test-live
2436
test-live:
25-
pytest tests/test_live.py --cf-auth-client --cf-wrangler-dir ..
37+
uv run pytest tests/test_live.py --cf-auth-client --cf-wrangler-dir ..
2638

2739
.PHONY: testcov
2840
testcov: test
2941
@echo "building coverage html"
30-
@coverage html
42+
@uv run coverage html
3143

3244
.PHONY: all
33-
all: lint mypy testcov
34-
35-
.PHONY: clean
36-
clean:
37-
rm -rf `find . -name __pycache__`
38-
rm -f `find . -type f -name '*.py[co]' `
39-
rm -f `find . -type f -name '*~' `
40-
rm -f `find . -type f -name '.*~' `
41-
rm -rf .cache
42-
rm -rf .pytest_cache
43-
rm -rf .mypy_cache
44-
rm -rf htmlcov
45-
rm -rf *.egg-info
46-
rm -f .coverage
47-
rm -f .coverage.*
48-
rm -rf build
49-
rm -rf dist
50-
rm -rf site
45+
all: lint typecheck testcov

0 commit comments

Comments
 (0)