diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml new file mode 100644 index 0000000..a370e79 --- /dev/null +++ b/.github/workflows/bnf-jest.yml @@ -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 diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml new file mode 100644 index 0000000..3c16903 --- /dev/null +++ b/.github/workflows/bnf-pytest.yml @@ -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 diff --git a/bnf/pyproject.toml b/bnf/pyproject.toml index 314543a..eccdb15 100644 --- a/bnf/pyproject.toml +++ b/bnf/pyproject.toml @@ -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 = [ diff --git a/bnf/setup.py b/bnf/setup.py index ec4019a..24d41c4 100644 --- a/bnf/setup.py +++ b/bnf/setup.py @@ -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 @@ -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={