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
22 changes: 7 additions & 15 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
name: JavaScript Tests

on:
pull_request: ~
pull_request:
branches: [ main ]
paths:
- cratedb_sqlparse_js
push:
branches: [ main ]
paths:
- cratedb_sqlparse_js

# Allow job to be triggered manually.
workflow_dispatch:
Expand All @@ -24,30 +28,18 @@ defaults:
working-directory: cratedb_sqlparse_js

jobs:

tests:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
node-version: ["18", "20", "22"]
node-version: ["20", "22", "23"]

env:
OS: ${{ matrix.os }}
NODEJS: ${{ matrix.node-version }}

# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
services:
cratedb:
image: crate/crate:nightly
ports:
- 4200:4200
- 5432:5432
env:
CRATE_HEAP_SIZE: 4g

name: Node.js ${{ matrix.node-version }} on OS ${{ matrix.os }}
steps:

Expand Down
38 changes: 13 additions & 25 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
name: Python Tests

on:
pull_request: ~
pull_request:
branches: [ main ]
paths:
- cratedb_sqlparse_py
push:
branches: [ main ]
paths:
- cratedb_sqlparse_py


# Allow job to be triggered manually.
workflow_dispatch:
Expand All @@ -24,30 +29,18 @@ defaults:
working-directory: cratedb_sqlparse_py

jobs:

tests:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

# https://docs.github.com/en/actions/using-containerized-services/about-service-containers
services:
cratedb:
image: crate/crate:nightly
ports:
- 4200:4200
- 5432:5432
env:
CRATE_HEAP_SIZE: 4g

name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }}
steps:

Expand All @@ -59,22 +52,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

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

- name: Set up project
run: |

# `setuptools 0.64.0` adds support for editable install hooks (PEP 660).
# https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400
pip install "setuptools>=64" --upgrade

# Install package in editable mode.
pip install --use-pep517 --prefer-binary --editable='.[develop,generate,test]'
uv sync --all-groups

- name: Run linter and software tests
run: |
poe check
uv run poe check

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
41 changes: 7 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
---
name: Release

on: push
on:
release:
types: [published]

jobs:
pypi:
name: Build and publish package to PyPI
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Generate grammar
run: |
python -m pip install -r requirements.txt
poe generate
- name: Build package
run: |
python -m pip install build twine
cd cratedb_sqlparse_py
python -m build
twine check dist/{*.tar.gz,*.whl}
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: cratedb_sqlparse_py/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
release_javascript:
uses: ./.github/workflows/release_javascript.yml
release_python:
uses: ./.github/workflows/release_python.yml
Comment on lines +6 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

38 changes: 38 additions & 0 deletions .github/workflows/release_javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Package to npmjs

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Generate grammar
run: |
python -m pip install -r requirements.txt
python setup_grammar.py javascript

- name: Set VERSION from tag
run: |
npm version ${GITHUB_REF#refs/*/v}

- run: npm build

- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish python parser to pypi

on:
workflow_call:

jobs:
build:
name: Build and publish package to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Generate grammar
run: |
python -m pip install -r requirements.txt
python setup_grammar.py python
- name: Build package
run: |
python -m pip install build twine
cd cratedb_sqlparse_py
python -m build
twine check dist/{*.tar.gz,*.whl}
Comment on lines +25 to +28
Copy link
Member

@amotl amotl Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you like it, a variant of those incantations could be:

cd cratedb_sqlparse_py
python -m pip install '.[release]'
poe release

release = [
"build<2",
"twine<7",
]

release = [
{ cmd = "python -m build" },
{ cmd = "twine upload dist/*" },
]

In this spirit, CI and manual procedures will be synchronized, through the canonical poe release command.

cratedb-sqlparse/DEVELOP.md

Lines 109 to 113 in 6542f48

#### Manual release.
Optionally, build the package and upload to PyPI manually.
```shell
uv run poe release
```

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: cratedb_sqlparse_py/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,11 @@ cython_debug/
*.tokens
*.interp
*.g4

node_modules
**/cratedb_sqlparse/**/SqlBaseParserVisitor.*
**/cratedb_sqlparse/**/SqlBaseParserListener.*

node_modules
**/cratedb_sqlparse/**/SqlBaseParserVisitor.*
**/cratedb_sqlparse/**/SqlBaseParserListener.*
Loading