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
116 changes: 67 additions & 49 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,81 @@
name: Build

name: Test ShExJSG
env:
UV_VERSION: "0.7.13"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
update-requirements:
quality-checks:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: dschep/install-pipenv-action@v1
- name: Update requirements
run: |
python -m pip install --upgrade pip
pip install pipenv-to-requirements
pipenv lock
pipenv_to_requirements
git add requirements*.txt
if [[ -n $(git status -s requirements*.txt) ]]
then
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m 'Automatically generated requirements' requirements*.txt
git push
fi

- name: Update the ShExJ python module
run: |
pipenv install
NEWF=$(mktemp).py
pwd
ls -l ShExJSG/ShExJ.jsg
pipenv run generate_parser -nh -e -o $NEWF ShExJSG/ShExJ.jsg
echo DONE
if [[ `tail -n +4 ShExJSG/ShExJ.py | diff -w -q $NEWF -` ]]
then
mv $NEWF ShExJSG/ShExJ.py
echo "ShExJ.py was updated"
else
rm $NEWF
echo "ShExJ.py was not changed"
fi
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: 3.13
- name: Install tox
run: python -m pip install tox
- name: Run codespell
run: tox -e codespell

test:
needs: update-requirements
runs-on: ubuntu-latest
needs:
- quality-checks
strategy:
fail-fast: false
matrix:
python-version: [ 3.7, 3.8, 3.9, "3.10" ]
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
defaults:
run:
shell: bash

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
uv sync --group dev

- name: Verify uv.lock is up-to-date
run: uv lock --check

- name: Install pyshexc
run: uv pip install "pyshexc>=0.10.3"

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Generate coverage results
# Set bash shell to fail correctly on Windows https://github.com/actions/runner-images/issues/6668
shell: bash
run: |
uv run coverage run -m pytest
uv run coverage xml
uv run coverage report -m

- name: Run Tox
run: |
pip install tox
tox -e py
- name: Upload coverage report
uses: codecov/codecov-action@v6.0.0
with:
name: codecov-results-${{ matrix.os }}-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
fail_ci_if_error: false
82 changes: 69 additions & 13 deletions .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,76 @@ on:
types: [created]

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
build:
name: Build distributions 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install dependencies and build dist package
run: |
python -m pip install --upgrade pip
pip install wheel
python setup.py bdist_wheel sdist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- uses: actions/checkout@v6
with:
user: __token__
password: ${{ secrets.pypi_password }}
fetch-depth: 0
fetch-tags: true

- name: Fetch full git tags
run: git fetch --tags

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install Python 3.13
run: uv python install 3.13

- name: Build
run: uv build

- name: Upload dist artifact
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/


publish-testpypi:
name: Publish to TestPyPI
needs: build
if: github.event.release.prerelease == true
runs-on: ubuntu-latest

permissions:
id-token: write

environment: testpypi

steps:
- name: Download dist
uses: actions/download-artifact@v7
with:
name: dist
path: dist/

- name: Publish to TestPyPI 📦
uses: pypa/gh-action-pypi-publish@v1.14.0
with:
repository-url: https://test.pypi.org/legacy/


publish-pypi:
name: Publish to PyPI
needs: build
if: github.event.release.prerelease == false
runs-on: ubuntu-latest

permissions:
id-token: write

environment: pypi

steps:
- name: Download dist
uses: actions/download-artifact@v7
with:
name: dist
path: dist/

- name: Publish to PyPI 📦
uses: pypa/gh-action-pypi-publish@v1.14.0
14 changes: 0 additions & 14 deletions Pipfile

This file was deleted.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
This repository was originally developed by [Harold Solbrig](https://github.com/hsolbrig) and was kindly contributed
to the LinkML organization because of his retirement. All credit for the original development of this repository goes
to him.

# ShExJSG -
Python representation of the ShEx AST(ish) specification.

Expand Down Expand Up @@ -61,4 +65,14 @@ cd ShExJSG
generate_parser ShExJ.jsg
```

Then run all of the unit tests
Then run all tests:

`uv run pytest`

## Note for developers
The original way this library was developed created a circular dependency for the test environment, causing uv to fail
to resolve. The reason is that `ShExJSG` is a runtime dependency for `pyshexc`, while `pyshexc` is a dev dependency for
`ShExJSG`. The only way around this is to run the development install the following way after cloning:

1. `uv sync`
2. `uv pip install "pyshexc>=0.10.3"`
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://docs.codecov.com/docs/codecov-yaml
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
97 changes: 97 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

[project]
name = "ShExJSG"
description = "ShExJSG - Astract Syntax Tree Definition for the ShEx 2.0 language"
authors = [
{ name = "Harold Solbrig", email = "solbrig@jhu.edu" },
{ name = "Wouter-Michiel Vierdag", email = "michiel.vierdag@scverse.org" }
]
license = { text = "CC0 1.0 Universal" }
repository = "https://github.com/linkml/ShExJSG"
readme = "README.md"
keywords = [
"shex",
"jsg",
"rdf",
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Topic :: Software Development :: Compilers",
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
requires-python = ">=3.10"
dynamic = ["version"]
dependencies = [
"pyjsg>=0.12.3",
]

[tool.uv.sources]
shexjsg = { workspace = true }

[tool.uv-dynamic-versioning]
vcs = "git"
style = "pep440"
fallback-version = "0.0.0"

[tool.hatch.version]
source = "uv-dynamic-versioning"

[tool.hatch.build.targets.wheel]
packages = ["ShExJSG"]

[dependency-groups]
dev = [
"yadict_compare",
"pytest",
"pytest-forked",
# "pyshexc>=0.10.3", does not resolve due to circular dependency, e.g. pyshexc needs shexjsg, see README.md
"rdflib-shim",
"coverage",
"requests",
"jsonasobj>=1.2.1",
]

[tool.black]
line-length = 120
target-version = ["py310", "py311", "py312", "py313", "py314"]

[tool.codespell]
skip = [
".git",
"uv.lock",
"*.toml",
]

[tool.tox]
requires = ["tox>=4"]
env_list = ["lint", "py{310,311,312,313}"]

[tool.tox.env_run_base]
allowlist_externals = ["uv"]
deps = ["pytest"]
commands = [
["uv", "sync", "--all-extras", "--dev"],
["uv", "run", "pytest", "{posargs}"],
]

[tool.tox.env.codespell]
description = "Run spell checkers."
skip_install = true
deps = [
"codespell",
"tomli", # required for getting config from pyproject.toml
]
commands = [
["codespell", "{posargs}"]
]
17 changes: 0 additions & 17 deletions requirements-dev.txt

This file was deleted.

Loading
Loading