Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite for py-tree-sitter 0.22 #65

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80
indent_size = 4

[*.rst]
indent_size = 3

[*.md]
indent_size = 2

[*.{yml,json}]
indent_size = 2
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributing guidelines

## Adding a new language

- Add the language data to _languages.json_.
- Add the language repo and license to _README.rst_.
- Add the language name to _tests/test_tree_sitter_languages.py_.
- Submit a pull request.
111 changes: 61 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,85 @@
name: release
name: Release

on:
push:
tags:
- v*
pull_request:
tags: ["*"]

jobs:
builds:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

build-sdist:
name: Build source dist
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
submodules: true

- uses: actions/setup-python@v5
cache: pip
python-version: "3.9"
- name: Build sources
run: |-
pip install build wheel
python -mbuild -n -s
- name: Upload sources
uses: actions/upload-artifact@v4
with:
python-version: "3.11"
name: dist-sources
path: dist/*.tar.gz
retention-days: 2

build-wheels:
name: Build wheel on ${{runner.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.9"
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2

platforms: arm64
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
uses: pypa/cibuildwheel@v2.16
with:
output-dir: dist
env:
CIBW_BEFORE_BUILD: pip install cython==3.0.8 && pip install -e . && python build.py
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest --showlocals {package}/tests
CIBW_SKIP: "{cp36**,pp*}"
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_LINUX: auto aarch64
CIBW_BUILD_VERBOSITY: 3

- uses: actions/upload-artifact@v4
CIBW_TEST_SKIP: "*arm64 *aarch64"
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheelhouse-${{ matrix.os }}
path: dist
path: dist/*.whl
name: dist-wheels-${{matrix.os}}
retention-days: 2

upload:
# Skip this step on pull requests. Run only when pushing a version tag.
if: startsWith(github.ref, 'refs/tags/v')
needs: builds
package:
name: Publish Python package
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/project/tree-sitter-languages/
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Stage wheels
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: wheelhouse-*
merge-multiple: true
path: dist
- run: |
ls -l dist/

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
pattern: dist-*
merge-multiple: true
- name: Check build artifacts
run: ls -l dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{secrets.PYPI_API_TOKEN}}
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
push:
branches: ["*"]
paths:
- setup.py
- languages.json
- tests/
- tree_sitter_languages/
pull_request:
paths:
- setup.py
- languages.json
- tests/
- tree_sitter_languages/

jobs:
test:
name: Build & test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.9"
- name: Set up tree-sitter CLI
uses: tree-sitter/setup-action/cli/@v1
- name: Install package
run: pip install -v -e .
env:
TS_REGENERATE: "1"
- name: Run tests
run: python -munittest discover -v tests
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*.pyc
*.so
*.dll
*.c

env*/
.venv/

vendor/
build/
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include languages.json

prune vendor
Loading