Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions .github/workflows/build.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
name: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:

permissions:
contents: read

env:
UV_SYSTEM_PYTHON: 1

jobs:
test:
runs-on: ${{matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
os: [macos-latest, ubuntu-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "3.7"

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Up Python ${{matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version }}
allow-prereleases: true
- uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
cache-suffix: ${{matrix.python-version }}
- name: Install
run: make EXTRAS=dev install
- name: Test
run: make test
- name: Lint
run: make lint

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
- name: Install
run: make EXTRAS=dev install
- name: Build
run: python -m build
- name: Upload
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist

publish:
needs: [build, test]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
34 changes: 26 additions & 8 deletions makefile
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
SRCS:=diff_match_patch
EXTRAS:=dev

ifeq ($(OS),Windows_NT)
ACTIVATE:=.venv/Scripts/activate
else
ACTIVATE:=.venv/bin/activate
endif

UV:=$(shell uv --version)
ifdef UV
VENV:=uv venv
PIP:=uv pip
else
VENV:=python -m venv
PIP:=python -m pip
endif

.venv:
python -m venv .venv
source .venv/bin/activate && make install
echo 'run `source .venv/bin/activate` to develop diff-match-patch'
$(VENV) .venv

venv: .venv
source $(ACTIVATE) && make install
echo 'run `source $(ACTIVATE)` to use virtualenv'

install:
python -m pip install -e .[dev]
$(PIP) install -Ue .[$(EXTRAS)]

release: lint test clean
python -m flit publish

format:
python -m ufmt format diff_match_patch
python -m ufmt format $(SRCS)

lint:
python -m ufmt check diff_match_patch
python -m mypy -p diff_match_patch
python -m ufmt check $(SRCS)
python -m mypy -p $(SRCS)

test:
python -m unittest -v diff_match_patch.tests
python -m unittest -v $(SRCS).tests

clean:
rm -rf build dist html README MANIFEST *.egg-info
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,7 @@ dependencies = []
[project.optional-dependencies]
dev = [
"attribution==1.6.2",
"build>=1",
"black==23.3.0",
"flit==3.8.0",
"mypy==1.2.0",
Expand All@@ -50,4 +51,4 @@ signed_tags = true
version_file = true

[tool.mypy]
python_version = "3.7"
python_version = "3.7"