Skip to content

Commit

Permalink
Modernize workflows (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese authored Feb 3, 2025
1 parent a726642 commit 7b8e351
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 49 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/build.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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.9", "3.10", "3.11", "3.12"]
os: [macOS-latest, ubuntu-latest, windows-latest]

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@v3
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:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v3
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@v4
with:
name: sdist
path: dist

publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
37 changes: 21 additions & 16 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
SRCS:=thx
PKG:=thx
EXTRAS:=dev,docs

.venv:
python -m venv .venv
source .venv/bin/activate && make install
echo 'run `source .venv/bin/activate` to use virtualenv'

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

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

release: lint test clean
flit publish
.venv:
$(VENV) .venv

venv: .venv
source .venv/bin/activate && make install
echo 'run `source .venv/bin/activate` to activate virtualenv'

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

lint:
python -m flake8 $(SRCS)
python -m ufmt check $(SRCS)
python -m flake8 $(PKG)
python -m ufmt check $(PKG)

test:
python -m coverage run -m $(SRCS).tests
python -m coverage run -m $(PKG).tests
python -m coverage combine
python -m coverage report
python -m mypy --install-types --non-interactive -p $(SRCS)
python -m mypy --install-types --non-interactive -p $(PKG)

html: .venv README.rst docs/*.rst docs/conf.py
source .venv/bin/activate && sphinx-build -b html docs html
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["flit_core >=3,<4"]
requires = ["flit_core >=3.8,<4"]
build-backend = "flit_core.buildapi"

[project]
Expand Down Expand Up @@ -41,6 +41,7 @@ dev = [

"attribution==1.7.1",
"black==24.4.2",
"build>=1.2",
"coverage==7.5.3",
"flit==3.9.0",
"flake8==7.0.0",
Expand Down

0 comments on commit 7b8e351

Please sign in to comment.