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
86 changes: 86 additions & 0 deletions .github/workflows/bnf-jest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: bnf-jest
permissions:
contents: read

on:
- pull_request
- push

env:
NODE_LATEST_VERSION: '24'

jobs:
bnf-jest:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ['20', '22', '24']

steps:
- uses: actions/checkout@v6

- name: install antlr4
run: pip install antlr4-tools

- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: dependencies
working-directory: bnf
run: npm ci

- name: jest
working-directory: bnf
run: npm run all

npm:
runs-on: ubuntu-latest
needs: bnf-jest

if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')"

environment:
name: npm-bnf
url: https://www.npmjs.com/package/atsds-bnf
permissions:
id-token: write

steps:
- uses: actions/checkout@v6

- name: recovery tag information
run: git fetch --tags --force

- name: install antlr4
run: pip install antlr4-tools

- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_LATEST_VERSION }}
cache: 'npm'

- name: version
working-directory: bnf
run: npm version from-git --no-git-tag-version

- name: extract tag
run: |
GIT_TAG=${GITHUB_REF#refs/tags/}
TAG=$(echo $GIT_TAG | sed -E 's/^v//' | sed -E 's/[0-9\.-]//g' | sed -E 's/^$/latest/g')
echo TAG=$TAG >> $GITHUB_ENV

- name: dependencies
working-directory: bnf
run: npm ci

- name: build
working-directory: bnf
run: npm run build

- name: publish
working-directory: bnf
run: npm publish --tag $TAG
87 changes: 87 additions & 0 deletions .github/workflows/bnf-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: bnf-pytest
permissions:
contents: read

on:
- pull_request
- push

env:
PYTHON_LATEST_VERSION: '3.14'

jobs:
bnf-pytest:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v6

- name: install antlr4
run: pip install antlr4-tools

- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: dependencies
working-directory: bnf
run: uv sync --locked --extra dev

- name: pytest
working-directory: bnf
run: uv run pytest

build:
runs-on: ubuntu-latest
needs: bnf-pytest

if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')"

steps:
- uses: actions/checkout@v6

- name: recovery tag information
run: git fetch --tags --force

- name: install antlr4
run: pip install antlr4-tools

- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: build
working-directory: bnf
run: uv build

- uses: actions/upload-artifact@v5
with:
name: dist
path: bnf/dist/*.whl

upload:
runs-on: ubuntu-latest
needs: build

environment:
name: pypi-bnf
url: https://pypi.org/project/apyds-bnf
permissions:
id-token: write

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

- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
4 changes: 2 additions & 2 deletions bnf/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ version_scheme = "no-guess-dev"
fallback_version = "0.0.0"
root = ".."

[tool.setuptools.packages.find]
include = ["apyds_bnf"]
[tool.setuptools]
packages = ["apyds_bnf"]

[project.optional-dependencies]
dev = [
Expand Down
11 changes: 0 additions & 11 deletions bnf/setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
"""
Setup script for apyds-bnf package with ANTLR parser generation
"""

import subprocess
from pathlib import Path

from setuptools import setup
from setuptools.command.build_py import build_py


class BuildWithAntlr(build_py):
"""Custom build command that generates ANTLR parsers before building"""

def run(self):
"""Generate ANTLR parsers and then run the standard build"""
self.generate_antlr_parsers()
super().run()

def generate_antlr_parsers(self):
"""Generate Python parsers from ANTLR grammars"""
base_dir = Path(__file__).parent
grammars_dir = base_dir
output_dir = base_dir / "apyds_bnf"

# Generate parsers for both grammars
for grammar in ["Ds.g4", "Dsp.g4"]:
grammar_path = grammars_dir / grammar

Expand All @@ -44,7 +34,6 @@ def generate_antlr_parsers(self):
print(f"Successfully generated parser for {grammar}")


# Use pyproject.toml for configuration, but provide custom build command
if __name__ == "__main__":
setup(
cmdclass={
Expand Down