Skip to content

Commit 1c1293a

Browse files
committed
Use ufmt makefile/CI workflow, use uv when available
1 parent cfd2192 commit 1c1293a

File tree

3 files changed

+107
-63
lines changed

3 files changed

+107
-63
lines changed

.github/workflows/build.yml

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

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- v*
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
UV_SYSTEM_PYTHON: 1
15+
16+
jobs:
17+
test:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
23+
os: [macos-latest, ubuntu-latest, windows-latest]
24+
exclude:
25+
- os: macos-latest
26+
python-version: "3.7"
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Set Up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
allow-prereleases: true
36+
- uses: astral-sh/setup-uv@v2
37+
with:
38+
enable-cache: true
39+
cache-dependency-glob: pyproject.toml
40+
cache-suffix: ${{ matrix.python-version }}
41+
- name: Install
42+
run: make EXTRAS=dev install
43+
- name: Test
44+
run: make test
45+
- name: Lint
46+
run: make lint
47+
48+
build:
49+
needs: test
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.12'
56+
- uses: astral-sh/setup-uv@v2
57+
with:
58+
enable-cache: true
59+
cache-dependency-glob: pyproject.toml
60+
- name: Install
61+
run: make EXTRAS=dev install
62+
- name: Build
63+
run: python -m build
64+
- name: Upload
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: sdist
68+
path: dist
69+
70+
publish:
71+
needs: build
72+
runs-on: ubuntu-latest
73+
if: startsWith(github.ref, 'refs/tags/v')
74+
permissions:
75+
id-token: write
76+
steps:
77+
- uses: actions/download-artifact@v3
78+
with:
79+
name: sdist
80+
path: dist
81+
- uses: pypa/gh-action-pypi-publish@release/v1

makefile

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1+
SRCS:=diff_match_patch
2+
EXTRAS:=dev
3+
4+
ifeq ($(OS),Windows_NT)
5+
ACTIVATE:=.venv/Scripts/activate
6+
else
7+
ACTIVATE:=.venv/bin/activate
8+
endif
9+
10+
UV:=$(shell uv --version)
11+
ifdef UV
12+
VENV:=uv venv
13+
PIP:=uv pip
14+
else
15+
VENV:=python -m venv
16+
PIP:=python -m pip
17+
endif
18+
119
.venv:
2-
python -m venv .venv
3-
source .venv/bin/activate && make install
4-
echo 'run `source .venv/bin/activate` to develop diff-match-patch'
20+
$(VENV) .venv
521

622
venv: .venv
23+
source $(ACTIVATE) && make install
24+
echo 'run `source $(ACTIVATE)` to use virtualenv'
725

826
install:
9-
python -m pip install -e .[dev]
27+
$(PIP) install -Ue .[$(EXTRAS)]
1028

1129
release: lint test clean
1230
python -m flit publish
1331

1432
format:
15-
python -m ufmt format diff_match_patch
33+
python -m ufmt format $(SRCS)
1634

1735
lint:
18-
python -m ufmt check diff_match_patch
19-
python -m mypy -p diff_match_patch
36+
python -m ufmt check $(SRCS)
37+
python -m mypy -p $(SRCS)
2038

2139
test:
22-
python -m unittest -v diff_match_patch.tests
40+
python -m unittest -v $(SRCS).tests
2341

2442
clean:
2543
rm -rf build dist html README MANIFEST *.egg-info

0 commit comments

Comments
 (0)