Skip to content

Commit

Permalink
Merge pull request #31 from brandonwillard/use-github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonwillard committed Jan 8, 2021
2 parents bacc7eb + 96bede1 commit 2c61eab
Show file tree
Hide file tree
Showing 30 changed files with 462 additions and 230 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PyPI
on:
push:
branches:
- master
- auto-release
pull_request:
branches: [master]
release:
types: [published]

jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Build the sdist
run: |
python setup.py sdist
- name: Check the sdist installs and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/miniKanren-*.tar.gz
- uses: actions/upload-artifact@v2
with:
name: artifact
path: dist/*

upload_pypi:
name: Upload to PyPI on release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_secret }}
99 changes: 99 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
changes:
name: "Check for changes"
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
python: &python
- 'kanren/**/*.py'
- 'tests/**/*.py'
- '*.py'
src:
- *python
- '.github/**/*.yml'
- 'setup.cfg'
- 'requirements.txt'
- '.coveragerc'
- '.pre-commit-config.yaml'
style:
name: Check code style
needs: changes
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.changes == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0

test:
needs:
- changes
- style
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
strategy:
matrix:
python-version:
- 3.6
- 3.7
- 3.8
- pypy3
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest -v tests/ --cov=kanren --cov-report=xml:./coverage.xml
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: run-${{ matrix.python-version }}

all-checks:
if: ${{ always() }}
runs-on: ubuntu-latest
name: "All tests"
needs: [changes, style, test]
steps:
- name: Check build matrix status
if: ${{ needs.changes.outputs.changes == 'true' && (needs.style.result != 'success' || needs.test.result != 'success') }}
run: exit 1

upload-coverage:
name: "Upload coverage"
needs: [changes, all-checks]
if: ${{ needs.changes.outputs.changes == 'true' && needs.all-checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
language_version: python3
exclude: |
(?x)^(
versioneer\.py|
kanren/_version\.py|
doc/.*|
bin/.*
)$
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
exclude: |
(?x)^(
versioneer\.py|
kanren/_version\.py|
doc/.*|
bin/.*
)$
- repo: https://github.com/pycqa/isort
rev: 5.5.2
hooks:
- id: isort
exclude: |
(?x)^(
versioneer\.py|
kanren/_version\.py|
doc/.*|
bin/.*
)$
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@ Using `pip`:
pip install miniKanren
```

To install from source:
## Development

First obtain the project source:
```bash
git clone git@github.com:pythological/kanren.git
cd kanren
pip install -r requirements.txt
```

Install the development dependencies:

```bash
$ pip install -r requirements.txt
```

Set up `pre-commit` hooks:

```bash
$ pre-commit install --install-hooks
```

Tests can be run with the provided `Makefile`:
Expand Down
5 changes: 2 additions & 3 deletions examples/commutative.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from kanren import run, var, fact
from kanren import fact, run, var
from kanren.assoccomm import associative, commutative
from kanren.assoccomm import eq_assoccomm as eq
from kanren.assoccomm import commutative, associative


# Define some dummy Operationss
add = "add"
Expand Down
1 change: 0 additions & 1 deletion examples/corleone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from kanren import Relation, conde, facts, run, var


father = Relation()
mother = Relation()

Expand Down
4 changes: 2 additions & 2 deletions examples/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
coastal = Relation()


coastal_states = "WA,OR,CA,TX,LA,MS,AL,GA,FL,SC,NC,VA,MD,DE,NJ,NY,CT,RI,MA,ME,NH,AK,HI".split(
","
coastal_states = (
"WA,OR,CA,TX,LA,MS,AL,GA,FL,SC,NC,VA,MD,DE,NJ,NY,CT,RI,MA,ME,NH,AK,HI".split(",")
)

# ['NY', 'NJ', 'CT', ...]
Expand Down
9 changes: 6 additions & 3 deletions examples/user_classes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from operator import add, gt, sub

from account import Account

from kanren import membero, run, unifiable, var
from kanren.core import lall
from kanren.term import term

from kanren.term import term # noqa: F401

unifiable(Account) # Register Account class

Expand All @@ -27,7 +28,9 @@
theorists = ("Adam", "Carl")
# Give $10 to theorists
theorist_bonus = lall(
membero(source, accounts), membero(first, theorists), add(10, balance, newbalance),
membero(source, accounts),
membero(first, theorists),
add(10, balance, newbalance),
)

# Take $10 from anyone with more than $100
Expand Down
21 changes: 10 additions & 11 deletions kanren/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# flake8: noqa
"""kanren is a Python library for logic and relational programming."""
from unification import unify, reify, unifiable, var, isvar, vars, variables, Var
from unification import Var, isvar, reify, unifiable, unify, var, variables, vars

from .core import run, eq, conde, lall, lany
from ._version import get_versions
from .core import conde, eq, lall, lany, run
from .facts import Relation, fact, facts
from .goals import (
heado,
tailo,
appendo,
conso,
nullo,
heado,
itero,
appendo,
rembero,
membero,
nullo,
permuteo,
permuteq,
membero,
rembero,
tailo,
)
from .facts import Relation, fact, facts
from .term import arguments, operator, term, unifiable_with_term

from ._version import get_versions

__version__ = get_versions()["version"]
del get_versions
18 changes: 8 additions & 10 deletions kanren/assoccomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@
>>> print(run(0, (x,y), eq(pattern, expr)))
((3, 2),)
"""
from functools import partial
from operator import length_hint, eq as equal
from collections.abc import Sequence

from toolz import sliding_window

from unification import reify, unify, var
from functools import partial
from operator import eq as equal
from operator import length_hint

from cons.core import ConsPair, car, cdr

from etuples import etuple
from toolz import sliding_window
from unification import reify, unify, var

from .core import conde, eq, ground_order, lall, succeed
from .goals import itero, permuteo
from .facts import Relation
from .goals import itero, permuteo
from .graph import term_walko
from .term import term

Expand All @@ -68,7 +66,7 @@ def assoc_args(rator, rands, n, ctor=None):
>>> from kanren.assoccomm import assoc_args
>>> list(assoc_args('op', [1, 2, 3], 2))
[[['op', 1, 2], 3], [1, ['op', 2, 3]]]
"""
""" # noqa: E501
assert n > 0

rands_l = list(rands)
Expand Down Expand Up @@ -96,7 +94,7 @@ def eq_assoc_args(
This is a non-relational utility goal. It does assumes that the op and at
least one set of arguments are ground under the state in which it is
evaluated.
"""
""" # noqa: E501
u_args, v_args = var(), var()

def eq_assoc_args_goal(S):
Expand Down
Loading

0 comments on commit 2c61eab

Please sign in to comment.