Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in CI #4

Merged
merged 16 commits into from
Jan 7, 2024
Merged
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit tests

on: [pull_request, push, workflow_dispatch]

jobs:
test:
name: Unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
# Issue: https://github.com/actions/checkout/issues/211#issuecomment-1368283898
# - name: Chown user
# run: |
# sudo chown -R $USER:$USER $GITHUB_WORKSPACE

- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install

- name: Test
shell: bash
run: poetry run j ci

# Report only changed files because the result is too large
- name: Pytest Coverage Comment
uses: MishaKav/pytest-coverage-comment@main
id: coverage_comment
with:
pytest-coverage-path: tests/coverage/pytest-coverage.txt
junitxml-path: tests/coverage/pytest.xml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ cython_debug/

.python-version
.flakeheaven_cache
tests/coverage/
-tests/coverage/.gitkeep
25 changes: 24 additions & 1 deletion jeeves.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
from sh import git
import os

from sh import git, pytest, tee


def update_submodule():
"""Update the `specification` submodule from GitHub."""
git.submodule.update('--remote', '--init', '--recursive')


def ci():
"""Run CI."""
env = {
**os.environ,
'PYTEST_RUN_PATH': 'tests',
}

tee(
'tests/coverage/pytest-coverage.txt',
_in=pytest(
'tests',
junitxml='tests/coverage/pytest.xml',
cov='yaml_ld',
_piped=True,
_ok_code={0, 1},
_env=env,
),
_env=env,
)
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jeeves-yeti-pyproject = { version = "^0.2.20", markers = "python_version >= '3.1
[tool.poetry.group.dev.dependencies]
types-pyyaml = "^6.0.12.11"
rdflib-pyld-compat = "^0.1.0"
lambdas = "^0.2.0"

[build-system]
requires = ["poetry-core"]
Expand Down
Empty file added tests/coverage/.gitkeep
Empty file.
7 changes: 2 additions & 5 deletions tests/test_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tests.common import load_tests
from tests.errors import FailureToFail
from yaml_ld.errors import YAMLLDError
from lambdas import _

tests = Namespace('https://w3c.github.io/json-ld-api/tests/vocab#')

Expand All @@ -34,11 +35,7 @@ def test_to_rdf(test_case: TestCase):
assert actual_graph.isomorphic(expected_graph)


@pytest.mark.parametrize(
'test_case',
load_tests(tests.ExpandTest),
ids=operator.attrgetter('test'),
)
@pytest.mark.parametrize('test_case', load_tests(tests.ExpandTest), ids=_.test)
def test_expand(test_case: TestCase):
raw_document = test_case.input.read_bytes()

Expand Down