diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 5eb886a..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Build -on: - push: - branches: - - main - tags: - - v* - pull_request: - -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@v3 - - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - cache: pip - cache-dependency-path: pyproject.toml - python-version: ${{ matrix.python-version }} - - name: Install - run: | - pip install -U . - - name: Test - run: make test - - lint: - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.12"] - os: [ubuntu-latest] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set Up Python - uses: actions/setup-python@v4 - with: - cache: pip - cache-dependency-path: pyproject.toml - python-version: ${{ matrix.python-version }} - - name: Install - run: | - pip install -U .[dev] - - name: Lint - run: make lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0230df9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/makefile b/makefile index f3b4605..ebf8858 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/pyproject.toml b/pyproject.toml index c38ab0d..ad3660f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -50,4 +51,4 @@ signed_tags = true version_file = true [tool.mypy] -python_version = "3.7" \ No newline at end of file +python_version = "3.7"