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
5 changes: 3 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/runtimeverification/python-project-template.git",
"commit": "70e5fe42fbddd7b0f89c56219ac9012c75028b84",
"commit": "7a095b4dd0a51916da0a728b8fdd9adf7e469a68",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -11,7 +11,8 @@
"description": "kup is a tool for managing installations of the K framework along with the different available semantics",
"author_name": "Runtime Verification, Inc.",
"author_email": "contact@runtimeverification.com",
"_template": "https://github.com/runtimeverification/python-project-template.git"
"_template": "https://github.com/runtimeverification/python-project-template.git",
"_commit": "7a095b4dd0a51916da0a728b8fdd9adf7e469a68"
}
},
"directory": null
Expand Down
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[flake8]
max-line-length = 120
extend-select = B9
extend-select = B9, TC1
extend-ignore = B950,E,W1,W2,W3,W4,W5
per-file-ignores =
*/__init__.py: F401
type-checking-strict = true
26 changes: 17 additions & 9 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,30 @@ jobs:
install_url: https://releases.nixos.org/nix/nix-2.32.0/install
extra_nix_config:
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

- uses: cachix/cachix-action@v12
with:
name: k-framework
signingKey: '${{ secrets.CACHIX_PUBLIC_TOKEN }}'
skipPush: true
- uses: actions/setup-python@v4
- name: 'Install Python'
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: 'Install Poetry'
python-version: '3.10'
- name: 'Get uv release'
id: uv_release
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry --version
- name: 'Formatting and Type Checking'
run: make
echo uv_version=$(cat deps/uv_release) >> "${GITHUB_OUTPUT}"
- name: 'Install uv'
uses: astral-sh/setup-uv@v7
with:
version: ${{ steps.uv_release.outputs.uv_version }}
- name: 'Run code quality checks'
run: make check
- name: 'Run pyupgrade'
run: make pyupgrade
- name: 'Run unit tests'
run: make cov-unit
- name: 'Kup list works'
run: poetry run kup list
run: uv run kup list
- name: 'Build via Nix'
run: nix build
37 changes: 32 additions & 5 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- '_update-deps/runtimeverification/rv-nix-tools'
- '_update-deps-cron/uv2nix'
- '_update-deps-cron/pyproject-build-systems'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -23,22 +25,47 @@ jobs:
run: |
git config user.name devops
git config user.email devops@runtimeverification.com
- name: 'Install Poetry'
uses: Gr1N/setup-poetry@v9
- name: 'Install Python'
uses: actions/setup-python@v6
with:
python-version: '3.10'
# note: we install the same version of `uv` as used by `uv2nix` in order to match the nix derivation
- name: 'Update uv release tag'
id: uv_release
run: |
UV2NIX_VERSION=$(cat deps/uv2nix)
UV_VERSION=$(curl -s https://raw.githubusercontent.com/pyproject-nix/uv2nix/$(cat deps/uv2nix)/pkgs/uv-bin/srcs.json | jq -r .version)
[[ "$UV_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
echo $UV_VERSION > deps/uv_release
git add deps/uv_release && git commit -m "Sync uv version: uv ${UV_VERSION}" || true
echo uv_version=$UV_VERSION >> "${GITHUB_OUTPUT}"
- name: 'Install uv'
uses: astral-sh/setup-uv@v7
with:
version: ${{ steps.uv_release.outputs.uv_version }}
- name: 'Install Nix'
uses: cachix/install-nix-action@v31.7.0
with:
install_url: https://releases.nixos.org/nix/nix-2.32.0/install
extra_nix_config: |
substituters = http://cache.nixos.org https://hydra.iohk.io
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
- name: 'Update Poetry files'
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v16
with:
name: k-framework
authToken: ${{ secrets.CACHIX_PUBLIC_TOKEN }}
- name: 'Update uv files'
run: |
poetry update
git add . && git commit -m "Sync Poetry files" || true
uv lock --upgrade
git add uv.lock && git commit -m "Sync uv lock file" || true
- name: 'Update Nix flake inputs'
run: |
UV2NIX_VERSION=$(cat deps/uv2nix)
PYPROJECT_BUILD_SYSTEMS_VERSION=$(cat deps/pyproject-build-systems)
RV_NIX_TOOLS_VERSION=$(cat deps/rv-nix-tools)
sed -i 's! uv2nix.url = "github:pyproject-nix/uv2nix/[a-z0-9\.]*"! uv2nix.url = "github:pyproject-nix/uv2nix/'"${UV2NIX_VERSION}"'"!' flake.nix
sed -i 's! pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/[a-z0-9\.]*"! pyproject-build-systems.url = "github:pyproject-nix/build-system-pkgs/'"${PYPROJECT_BUILD_SYSTEMS_VERSION}"'"!' flake.nix
sed -i 's! rv-nix-tools.url = "github:runtimeverification/rv-nix-tools/[a-z0-9\.]*"! rv-nix-tools.url = "github:runtimeverification/rv-nix-tools/'"${RV_NIX_TOOLS_VERSION}"'"!' flake.nix
nix flake update
git add flake.nix flake.lock && git commit -m 'flake.{nix,lock}: update Nix derivations' || true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/dist/
__pycache__/
.coverage
103 changes: 73 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,100 @@
.PHONY: default all clean build install \
poetry-install \
test test-unit \
format isort autoflake black \
check check-isort check-autoflake check-black check-flake8 check-mypy
UV := uv
UV_RUN := $(UV) run --


default: check test-unit

all: check cov

.PHONY: clean
clean:
rm -rf dist .mypy_cache
rm -rf dist .coverage cov-* .mypy_cache .pytest_cache
find -type d -name __pycache__ -prune -exec rm -rf {} \;

.PHONY: build
build:
poetry build
$(UV) build

poetry-install:
poetry install

POETRY_RUN := poetry run
# Tests

TEST_ARGS :=

# Tests
test: test-all

.PHONY: test-all
test-all:
$(UV_RUN) pytest src/tests --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)

.PHONY: test-unit
test-unit:
$(UV_RUN) pytest src/tests/unit --maxfail=1 --verbose $(TEST_ARGS)

.PHONY: test-integration
test-integration:
$(UV_RUN) pytest src/tests/integration --maxfail=1 --verbose --durations=0 --numprocesses=4 --dist=worksteal $(TEST_ARGS)


# Coverage

test: test-unit
COV_ARGS :=

test-unit: poetry-install
$(POETRY_RUN) python -m unittest discover tests --failfast --verbose
cov: cov-all

cov-%: TEST_ARGS += --cov=kup --no-cov-on-fail --cov-branch --cov-report=term

cov-all: TEST_ARGS += --cov-report=html:cov-all-html $(COV_ARGS)
cov-all: test-all

cov-unit: TEST_ARGS += --cov-report=html:cov-unit-html $(COV_ARGS)
cov-unit: test-unit

cov-integration: TEST_ARGS += --cov-report=html:cov-integration-html $(COV_ARGS)
cov-integration: test-integration


# Checks and formatting

format: autoflake isort black
check: check-flake8 check-mypy check-autoflake check-isort check-black

check-flake8: poetry-install
$(POETRY_RUN) flake8 src
.PHONY: check-flake8
check-flake8:
$(UV_RUN) flake8 src

.PHONY: check-mypy
check-mypy:
$(UV_RUN) mypy src

.PHONY: autoflake
autoflake:
$(UV_RUN) autoflake --quiet --in-place src

.PHONY: check-autoflake
check-autoflake:
$(UV_RUN) autoflake --quiet --check src

.PHONY: isort
isort:
$(UV_RUN) isort src

check-mypy: poetry-install
$(POETRY_RUN) mypy src
.PHONY: check-isort
check-isort:
$(UV_RUN) isort --check src

autoflake: poetry-install
$(POETRY_RUN) autoflake --quiet --in-place src
.PHONY: black
black:
$(UV_RUN) black src

check-autoflake: poetry-install
$(POETRY_RUN) autoflake --quiet --check src
.PHONY: check-black
check-black:
$(UV_RUN) black --check src

isort: poetry-install
$(POETRY_RUN) isort src

check-isort: poetry-install
$(POETRY_RUN) isort --check src
# Optional tools

black: poetry-install
$(POETRY_RUN) black src
SRC_FILES := $(shell find src -type f -name '*.py')

check-black: poetry-install
$(POETRY_RUN) black --check src
.PHONY: pyupgrade
pyupgrade:
$(UV_RUN) pyupgrade --py310-plus $(SRC_FILES)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ etc.

## For Developers

Prerequsites: `python >= 3.10`, [`uv`](https://docs.astral.sh/uv/).

Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list of available targets).

* `make build`: Build wheel
* `make check`: Check code style
* `make format`: Format code
* `make test-unit`: Run unit tests
* `make test-integration`: Run integration tests

For interactive use, spawn a shell with `poetry shell` (after `poetry install`), then run an interpreter.
1 change: 1 addition & 0 deletions deps/uv2nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c8cf711802cb00b2e05d5c54d3486fce7bfc8f7c
1 change: 1 addition & 0 deletions deps/uv_release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.9.9
Loading