Skip to content

Commit 2c61eab

Browse files
Merge pull request #31 from brandonwillard/use-github-actions
2 parents bacc7eb + 96bede1 commit 2c61eab

30 files changed

+462
-230
lines changed

.github/workflows/pypi.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: PyPI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- auto-release
7+
pull_request:
8+
branches: [master]
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
build:
14+
name: Build source distribution
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- uses: actions/setup-python@v2
21+
with:
22+
python-version: "3.8"
23+
- name: Build the sdist
24+
run: |
25+
python setup.py sdist
26+
- name: Check the sdist installs and imports
27+
run: |
28+
mkdir -p test-sdist
29+
cd test-sdist
30+
python -m venv venv-sdist
31+
venv-sdist/bin/python -m pip install ../dist/miniKanren-*.tar.gz
32+
- uses: actions/upload-artifact@v2
33+
with:
34+
name: artifact
35+
path: dist/*
36+
37+
upload_pypi:
38+
name: Upload to PyPI on release
39+
needs: [build]
40+
runs-on: ubuntu-latest
41+
if: github.event_name == 'release' && github.event.action == 'published'
42+
steps:
43+
- uses: actions/download-artifact@v2
44+
with:
45+
name: artifact
46+
path: dist
47+
- uses: pypa/gh-action-pypi-publish@master
48+
with:
49+
user: __token__
50+
password: ${{ secrets.pypi_secret }}

.github/workflows/tests.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
changes:
13+
name: "Check for changes"
14+
runs-on: ubuntu-latest
15+
outputs:
16+
changes: ${{ steps.changes.outputs.src }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0
21+
- uses: dorny/paths-filter@v2
22+
id: changes
23+
with:
24+
filters: |
25+
python: &python
26+
- 'kanren/**/*.py'
27+
- 'tests/**/*.py'
28+
- '*.py'
29+
src:
30+
- *python
31+
- '.github/**/*.yml'
32+
- 'setup.cfg'
33+
- 'requirements.txt'
34+
- '.coveragerc'
35+
- '.pre-commit-config.yaml'
36+
37+
style:
38+
name: Check code style
39+
needs: changes
40+
runs-on: ubuntu-latest
41+
if: ${{ needs.changes.outputs.changes == 'true' }}
42+
steps:
43+
- uses: actions/checkout@v2
44+
- uses: actions/setup-python@v2
45+
with:
46+
python-version: 3.8
47+
- uses: pre-commit/[email protected]
48+
49+
test:
50+
needs:
51+
- changes
52+
- style
53+
runs-on: ubuntu-latest
54+
if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }}
55+
strategy:
56+
matrix:
57+
python-version:
58+
- 3.6
59+
- 3.7
60+
- 3.8
61+
- pypy3
62+
steps:
63+
- uses: actions/checkout@v2
64+
- uses: actions/setup-python@v2
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
71+
- name: Test with pytest
72+
run: |
73+
pytest -v tests/ --cov=kanren --cov-report=xml:./coverage.xml
74+
- name: Coveralls
75+
uses: AndreMiras/coveralls-python-action@develop
76+
with:
77+
parallel: true
78+
flag-name: run-${{ matrix.python-version }}
79+
80+
all-checks:
81+
if: ${{ always() }}
82+
runs-on: ubuntu-latest
83+
name: "All tests"
84+
needs: [changes, style, test]
85+
steps:
86+
- name: Check build matrix status
87+
if: ${{ needs.changes.outputs.changes == 'true' && (needs.style.result != 'success' || needs.test.result != 'success') }}
88+
run: exit 1
89+
90+
upload-coverage:
91+
name: "Upload coverage"
92+
needs: [changes, all-checks]
93+
if: ${{ needs.changes.outputs.changes == 'true' && needs.all-checks.result == 'success' }}
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Coveralls Finished
97+
uses: AndreMiras/coveralls-python-action@develop
98+
with:
99+
parallel-finished: true

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 20.8b1
4+
hooks:
5+
- id: black
6+
language_version: python3
7+
exclude: |
8+
(?x)^(
9+
versioneer\.py|
10+
kanren/_version\.py|
11+
doc/.*|
12+
bin/.*
13+
)$
14+
- repo: https://gitlab.com/pycqa/flake8
15+
rev: 3.8.4
16+
hooks:
17+
- id: flake8
18+
exclude: |
19+
(?x)^(
20+
versioneer\.py|
21+
kanren/_version\.py|
22+
doc/.*|
23+
bin/.*
24+
)$
25+
- repo: https://github.com/pycqa/isort
26+
rev: 5.5.2
27+
hooks:
28+
- id: isort
29+
exclude: |
30+
(?x)^(
31+
versioneer\.py|
32+
kanren/_version\.py|
33+
doc/.*|
34+
bin/.*
35+
)$

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,24 @@ Using `pip`:
1111
pip install miniKanren
1212
```
1313

14-
To install from source:
14+
## Development
15+
16+
First obtain the project source:
1517
```bash
1618
git clone [email protected]:pythological/kanren.git
1719
cd kanren
18-
pip install -r requirements.txt
20+
```
21+
22+
Install the development dependencies:
23+
24+
```bash
25+
$ pip install -r requirements.txt
26+
```
27+
28+
Set up `pre-commit` hooks:
29+
30+
```bash
31+
$ pre-commit install --install-hooks
1932
```
2033

2134
Tests can be run with the provided `Makefile`:

examples/commutative.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from kanren import run, var, fact
1+
from kanren import fact, run, var
2+
from kanren.assoccomm import associative, commutative
23
from kanren.assoccomm import eq_assoccomm as eq
3-
from kanren.assoccomm import commutative, associative
4-
54

65
# Define some dummy Operationss
76
add = "add"

examples/corleone.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

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

10-
1110
father = Relation()
1211
mother = Relation()
1312

examples/states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
coastal = Relation()
1313

1414

15-
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(
16-
","
15+
coastal_states = (
16+
"WA,OR,CA,TX,LA,MS,AL,GA,FL,SC,NC,VA,MD,DE,NJ,NY,CT,RI,MA,ME,NH,AK,HI".split(",")
1717
)
1818

1919
# ['NY', 'NJ', 'CT', ...]

examples/user_classes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from operator import add, gt, sub
2+
13
from account import Account
24

35
from kanren import membero, run, unifiable, var
46
from kanren.core import lall
5-
from kanren.term import term
6-
7+
from kanren.term import term # noqa: F401
78

89
unifiable(Account) # Register Account class
910

@@ -27,7 +28,9 @@
2728
theorists = ("Adam", "Carl")
2829
# Give $10 to theorists
2930
theorist_bonus = lall(
30-
membero(source, accounts), membero(first, theorists), add(10, balance, newbalance),
31+
membero(source, accounts),
32+
membero(first, theorists),
33+
add(10, balance, newbalance),
3134
)
3235

3336
# Take $10 from anyone with more than $100

kanren/__init__.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
# flake8: noqa
22
"""kanren is a Python library for logic and relational programming."""
3-
from unification import unify, reify, unifiable, var, isvar, vars, variables, Var
3+
from unification import Var, isvar, reify, unifiable, unify, var, variables, vars
44

5-
from .core import run, eq, conde, lall, lany
5+
from ._version import get_versions
6+
from .core import conde, eq, lall, lany, run
7+
from .facts import Relation, fact, facts
68
from .goals import (
7-
heado,
8-
tailo,
9+
appendo,
910
conso,
10-
nullo,
11+
heado,
1112
itero,
12-
appendo,
13-
rembero,
13+
membero,
14+
nullo,
1415
permuteo,
1516
permuteq,
16-
membero,
17+
rembero,
18+
tailo,
1719
)
18-
from .facts import Relation, fact, facts
1920
from .term import arguments, operator, term, unifiable_with_term
2021

21-
from ._version import get_versions
22-
2322
__version__ = get_versions()["version"]
2423
del get_versions

0 commit comments

Comments
 (0)