Skip to content

Commit

Permalink
Merge pull request #21 from dpalmasan/github_actions
Browse files Browse the repository at this point in the history
Migrating from travis CI to github actions.
  • Loading branch information
dpalmasan authored Apr 11, 2021
2 parents b7a23a2 + f1d8643 commit 4296fad
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 37 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on: [push, pull_request]

jobs:
build:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Unit tests
run: |
tox -e py
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on: [push, pull_request]

jobs:
build:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
python -m pip install -e '.'
- name: Lint
run: pre-commit run --all-files --show-diff-on-failure
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ wheels/
.installed.cfg
*.egg
MANIFEST
pip-wheel-metadata/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ repos:
hooks:
- id: black
stages: [commit]
language_version: python3.6
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
Expand All @@ -17,7 +16,6 @@ repos:
rev: v2.1.0
hooks:
- id: reorder-python-imports
language_version: python3.6
- repo: git://github.com/chewse/pre-commit-mirrors-pydocstyle
rev: 'v2.1.1'
hooks:
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ repos:
hooks:
- id: black
stages: [commit]
language_version: python3.7
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
Expand All @@ -15,7 +14,6 @@ repos:
rev: v2.1.0
hooks:
- id: reorder-python-imports
language_version: python3.7
- repo: git://github.com/chewse/pre-commit-mirrors-pydocstyle
rev: v2.1.1
hooks:
Expand Down
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pre-commit
pytest >= 6.1.1
pytest-cov >= 2.10.1
mock >= 3.0.5
spacy
tox
25 changes: 19 additions & 6 deletions tests/surface_proxies_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

from TRUNAJOD import surface_proxies

Token = namedtuple("Token", "word pos_ lower_ lemma_")
Token = namedtuple("Token", ["word", "pos_", "lower_", "lemma_", "tag_"])
doc = [
Token("El", "", "el", "El"),
Token("perro", "NOUN", "perro", "perro"),
Token("es", "", "es", "es"),
Token("extraordinario", "ADJ", "extraordinario", "extraordinario"),
Token(".", "PUNCT", ".", "."),
Token("El", "", "el", "El", "Person=1"),
Token("perro", "NOUN", "perro", "perro", "tag"),
Token("es", "", "es", "es", "tag"),
Token("extraordinario", "ADJ", "extraordinario", "extraordinario", "tag"),
Token(".", "PUNCT", ".", ".", "tag"),
]


Expand All @@ -36,3 +36,16 @@ def test_negation_density():
def test_noun_count():
"""Test noun_count."""
assert surface_proxies.noun_count(doc) == 1


def test_first_second_person_density():
"""Test first_second_person_density."""
assert surface_proxies.first_second_person_count(doc) == 1


def test_infinitive():
"""Test infinitive."""
assert surface_proxies.infinitve("comiendo", {}) is None
assert (
surface_proxies.infinitve("comiendo", {"comiendo": "comer"}) == "comer"
)
16 changes: 6 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
[tox]
envlist = py37

[pytest]
norecursedirs = docs *.egg-info .git appdir .tox
envlist = py{36,37,38,39}

[testenv]
setenv = PYTHONPATH = {toxinidir}/src
skip_install = True
deps =
-r{toxinidir}/requirements-test.txt
commands =
pip install -e .
pytest
coverage
pytest-cov
mock
spacy

commands = pytest

0 comments on commit 4296fad

Please sign in to comment.