From f5189646c669e3b09001e1a463d6f47eb7a19aca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 03:55:45 +0000 Subject: [PATCH 1/8] Initial plan From cc591d142d4f2ee44494adfde53398b4acee5b7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 03:59:11 +0000 Subject: [PATCH 2/8] Add bnf-pytest.yml and bnf-jest.yml workflows with pypi-bnf and npm-bnf environments Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com> --- .github/workflows/bnf-jest.yml | 82 +++++++++++++++++++++++++++++ .github/workflows/bnf-pytest.yml | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 .github/workflows/bnf-jest.yml create mode 100644 .github/workflows/bnf-pytest.yml diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml new file mode 100644 index 0000000..c83558f --- /dev/null +++ b/.github/workflows/bnf-jest.yml @@ -0,0 +1,82 @@ +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 + + - uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + cache-dependency-path: bnf/package-lock.json + + - 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 + + - uses: actions/setup-node@v6 + with: + node-version: ${{ env.NODE_LATEST_VERSION }} + cache: 'npm' + cache-dependency-path: bnf/package-lock.json + + - 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..1e47045 --- /dev/null +++ b/.github/workflows/bnf-pytest.yml @@ -0,0 +1,90 @@ +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 + + - 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 + + wheels: + runs-on: ${{ matrix.os }} + needs: bnf-pytest + + if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')" + + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v6 + + - name: recovery tag information + run: git fetch --tags --force + + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_LATEST_VERSION }} + cache: 'pip' + + - name: install cibuildwheel + run: pip install cibuildwheel + + - name: build wheels + working-directory: bnf + run: python -m cibuildwheel + + - uses: actions/upload-artifact@v5 + with: + name: wheels-${{ matrix.os }} + path: bnf/wheelhouse/*.whl + + upload: + runs-on: ubuntu-latest + needs: wheels + + environment: + name: pypi-bnf + url: https://pypi.org/project/apyds-bnf + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v6 + with: + pattern: wheels-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist From c37810743e8a076906071020482f182645306ac0 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 9 Dec 2025 13:06:45 +0800 Subject: [PATCH 3/8] Update caching policy. --- .github/workflows/bnf-jest.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml index c83558f..763fe55 100644 --- a/.github/workflows/bnf-jest.yml +++ b/.github/workflows/bnf-jest.yml @@ -25,7 +25,6 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - cache-dependency-path: bnf/package-lock.json - name: dependencies working-directory: bnf @@ -57,7 +56,6 @@ jobs: with: node-version: ${{ env.NODE_LATEST_VERSION }} cache: 'npm' - cache-dependency-path: bnf/package-lock.json - name: version working-directory: bnf From bc8622c0b35dda56b04562a4f2eee896241c6422 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 05:21:18 +0000 Subject: [PATCH 4/8] Add ANTLR4 setup and simplify Python build to use python -m build Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com> --- .github/workflows/bnf-jest.yml | 6 ++++++ .github/workflows/bnf-pytest.yml | 32 ++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml index 763fe55..3790171 100644 --- a/.github/workflows/bnf-jest.yml +++ b/.github/workflows/bnf-jest.yml @@ -21,10 +21,13 @@ jobs: steps: - uses: actions/checkout@v6 + - uses: StoneMoe/setup-antlr4@v4 + - uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: 'npm' + cache-dependency-path: bnf/package-lock.json - name: dependencies working-directory: bnf @@ -52,10 +55,13 @@ jobs: - name: recovery tag information run: git fetch --tags --force + - uses: StoneMoe/setup-antlr4@v4 + - uses: actions/setup-node@v6 with: node-version: ${{ env.NODE_LATEST_VERSION }} cache: 'npm' + cache-dependency-path: bnf/package-lock.json - name: version working-directory: bnf diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml index 1e47045..29d5613 100644 --- a/.github/workflows/bnf-pytest.yml +++ b/.github/workflows/bnf-pytest.yml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v6 + - uses: StoneMoe/setup-antlr4@v4 + - uses: astral-sh/setup-uv@v7 with: python-version: ${{ matrix.python-version }} @@ -34,43 +36,38 @@ jobs: working-directory: bnf run: uv run pytest - wheels: - runs-on: ${{ matrix.os }} + build: + runs-on: ubuntu-latest needs: bnf-pytest if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')" - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - steps: - uses: actions/checkout@v6 - name: recovery tag information run: git fetch --tags --force + - uses: StoneMoe/setup-antlr4@v4 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_LATEST_VERSION }} - cache: 'pip' - - - name: install cibuildwheel - run: pip install cibuildwheel - - name: build wheels + - name: build working-directory: bnf - run: python -m cibuildwheel + run: | + pip install build + python -m build - uses: actions/upload-artifact@v5 with: - name: wheels-${{ matrix.os }} - path: bnf/wheelhouse/*.whl + name: dist + path: bnf/dist/* upload: runs-on: ubuntu-latest - needs: wheels + needs: build environment: name: pypi-bnf @@ -81,9 +78,8 @@ jobs: steps: - uses: actions/download-artifact@v6 with: - pattern: wheels-* + name: dist path: dist - merge-multiple: true - uses: pypa/gh-action-pypi-publish@release/v1 with: From 31fe543813b895d590d025660400b7f6ede68ecb Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 9 Dec 2025 13:28:12 +0800 Subject: [PATCH 5/8] Update cache policy. --- .github/workflows/bnf-jest.yml | 2 -- .github/workflows/bnf-pytest.yml | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml index 3790171..d8df331 100644 --- a/.github/workflows/bnf-jest.yml +++ b/.github/workflows/bnf-jest.yml @@ -27,7 +27,6 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - cache-dependency-path: bnf/package-lock.json - name: dependencies working-directory: bnf @@ -61,7 +60,6 @@ jobs: with: node-version: ${{ env.NODE_LATEST_VERSION }} cache: 'npm' - cache-dependency-path: bnf/package-lock.json - name: version working-directory: bnf diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml index 29d5613..10061bb 100644 --- a/.github/workflows/bnf-pytest.yml +++ b/.github/workflows/bnf-pytest.yml @@ -50,20 +50,19 @@ jobs: - uses: StoneMoe/setup-antlr4@v4 - - uses: actions/setup-python@v6 + - uses: astral-sh/setup-uv@v7 with: - python-version: ${{ env.PYTHON_LATEST_VERSION }} + python-version: ${{ matrix.python-version }} + enable-cache: true - name: build working-directory: bnf - run: | - pip install build - python -m build + run: uv build - uses: actions/upload-artifact@v5 with: name: dist - path: bnf/dist/* + path: bnf/dist/*.whl upload: runs-on: ubuntu-latest From 2c1cc93579cfffb81606303e1398cd021c835ebc Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 9 Dec 2025 13:34:31 +0800 Subject: [PATCH 6/8] Update version of setup-antlr4. --- .github/workflows/bnf-jest.yml | 4 ++-- .github/workflows/bnf-pytest.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml index d8df331..27c0ae5 100644 --- a/.github/workflows/bnf-jest.yml +++ b/.github/workflows/bnf-jest.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: StoneMoe/setup-antlr4@v4 + - uses: StoneMoe/setup-antlr4@v4.13.2 - uses: actions/setup-node@v6 with: @@ -54,7 +54,7 @@ jobs: - name: recovery tag information run: git fetch --tags --force - - uses: StoneMoe/setup-antlr4@v4 + - uses: StoneMoe/setup-antlr4@v4.13.2 - uses: actions/setup-node@v6 with: diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml index 10061bb..867929f 100644 --- a/.github/workflows/bnf-pytest.yml +++ b/.github/workflows/bnf-pytest.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: StoneMoe/setup-antlr4@v4 + - uses: StoneMoe/setup-antlr4@v4.13.2 - uses: astral-sh/setup-uv@v7 with: @@ -48,7 +48,7 @@ jobs: - name: recovery tag information run: git fetch --tags --force - - uses: StoneMoe/setup-antlr4@v4 + - uses: StoneMoe/setup-antlr4@v4.13.2 - uses: astral-sh/setup-uv@v7 with: From fdf56e1091a7fd4fff616425ebfc1abd96c768ce Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 9 Dec 2025 13:46:30 +0800 Subject: [PATCH 7/8] Update setup.py for apyds_bnf. --- bnf/pyproject.toml | 4 ++-- bnf/setup.py | 11 ----------- 2 files changed, 2 insertions(+), 13 deletions(-) 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={ From 28ccc47cdda6e2a92c4dcd5df7cd5b7053a31b32 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Tue, 9 Dec 2025 16:10:24 +0800 Subject: [PATCH 8/8] Use pip to install antlr4. --- .github/workflows/bnf-jest.yml | 6 ++++-- .github/workflows/bnf-pytest.yml | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bnf-jest.yml b/.github/workflows/bnf-jest.yml index 27c0ae5..a370e79 100644 --- a/.github/workflows/bnf-jest.yml +++ b/.github/workflows/bnf-jest.yml @@ -21,7 +21,8 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: StoneMoe/setup-antlr4@v4.13.2 + - name: install antlr4 + run: pip install antlr4-tools - uses: actions/setup-node@v6 with: @@ -54,7 +55,8 @@ jobs: - name: recovery tag information run: git fetch --tags --force - - uses: StoneMoe/setup-antlr4@v4.13.2 + - name: install antlr4 + run: pip install antlr4-tools - uses: actions/setup-node@v6 with: diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml index 867929f..3c16903 100644 --- a/.github/workflows/bnf-pytest.yml +++ b/.github/workflows/bnf-pytest.yml @@ -21,7 +21,8 @@ jobs: steps: - uses: actions/checkout@v6 - - uses: StoneMoe/setup-antlr4@v4.13.2 + - name: install antlr4 + run: pip install antlr4-tools - uses: astral-sh/setup-uv@v7 with: @@ -48,7 +49,8 @@ jobs: - name: recovery tag information run: git fetch --tags --force - - uses: StoneMoe/setup-antlr4@v4.13.2 + - name: install antlr4 + run: pip install antlr4-tools - uses: astral-sh/setup-uv@v7 with: