-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--⚠️ This is an open-source repository. Do not share sensitive information. -->
- Loading branch information
Showing
17 changed files
with
14,587 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# GitHub syntax highlighting | ||
pixi.lock linguist-language=YAML linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: "weekly" | ||
interval: monthly | ||
reviewers: | ||
- "quantco/ci" | ||
- quantco/ci | ||
groups: | ||
gh-actions: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,61 +2,73 @@ name: CI | |
on: [push] | ||
|
||
jobs: | ||
|
||
pre-commit-checks: | ||
name: "Linux - pre-commit checks - Python 3.8" | ||
name: "Pre-commit checks" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v4 | ||
- name: Set up pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Install Python 3.8 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
- name: Run pre-commit checks | ||
uses: pre-commit/[email protected] | ||
|
||
environments: default lint | ||
- name: pre-commit | ||
run: pixi run pre-commit-run --color=always --show-diff-on-failure | ||
|
||
unit-tests: | ||
name: "Unit tests - ${{ matrix.OS }} - Python ${{ matrix.PYTHON_VERSION }}" | ||
runs-on: ubuntu-latest | ||
name: "Unit tests" | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
CI: True | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
PYTHON_VERSION: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||
OS: ['ubuntu-latest', 'windows-latest'] | ||
env: | ||
- py39 | ||
- py310 | ||
- py311 | ||
- py312 | ||
- py313 | ||
- antlr410 | ||
- antlr411 | ||
- antlr412 | ||
- antlr413 | ||
os: ['ubuntu-latest', 'windows-latest', 'macos-latest'] | ||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
fetch-depth: 0 | ||
- name: Set up pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
python-version: ${{ matrix.PYTHON_VERSION }} | ||
miniforge-variant: Mambaforge | ||
miniforge-version: 4.11.0-2 | ||
use-mamba: true | ||
environment-file: environment.yml | ||
activate-environment: pytsql | ||
- name: Run Unit Tests | ||
shell: bash -l {0} | ||
environments: ${{ matrix.env }} | ||
- name: Run unit tests | ||
run: | | ||
pip install . --no-build-isolation --no-deps --disable-pip-version-check | ||
pytest tests/unit | ||
pixi run -e ${{ matrix.env }} postinstall | ||
pixi run -e ${{ matrix.env }} pytest tests/unit | ||
linux-integration_tests-sqlserver: | ||
name: "Linux - integration tests - Python ${{ matrix.PYTHON_VERSION }} - mssql" | ||
name: "Integration tests" | ||
runs-on: ubuntu-latest | ||
env: | ||
CI: True | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
PYTHON_VERSION: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||
env: | ||
- py39 | ||
- py310 | ||
- py311 | ||
- py312 | ||
- py313 | ||
- antlr410 | ||
- antlr411 | ||
- antlr412 | ||
- antlr413 | ||
- sa1 | ||
- sa2 | ||
services: | ||
DB: | ||
image: mcr.microsoft.com/mssql/server:2019-latest | ||
|
@@ -69,27 +81,19 @@ jobs: | |
- name: Checkout branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Fetch full git history | ||
run: git fetch --prune --unshallow | ||
- uses: conda-incubator/setup-miniconda@v3 | ||
fetch-depth: 0 | ||
- name: Set up pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
python-version: ${{ matrix.PYTHON_VERSION }} | ||
miniforge-variant: Mambaforge | ||
miniforge-version: 4.11.0-2 | ||
use-mamba: true | ||
environment-file: environment.yml | ||
activate-environment: pytsql | ||
environments: ${{ matrix.env }} | ||
- name: Install msodbcsql17 driver | ||
shell: bash -l {0} | ||
run: | | ||
wget https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/msodbcsql17/msodbcsql17_17.10.1.1-1_amd64.deb | ||
ACCEPT_EULA=Y sudo apt install ./msodbcsql17_17.10.1.1-1_amd64.deb --allow-downgrades | ||
- name: Wait for SQL Server | ||
timeout-minutes: 1 | ||
run: until docker logs "${{ job.services.db.id }}" 2>&1 | grep -q "SQL Server is now ready"; do sleep 10; done | ||
- name: Run Unit Tests | ||
shell: bash -l {0} | ||
- name: Run integration tests | ||
run: | | ||
pip install . --no-build-isolation --no-deps --disable-pip-version-check | ||
pytest --backend=mssql tests/integration | ||
pixi run -e ${{ matrix.env }} postinstall | ||
pixi run -e ${{ matrix.env }} pytest --backend=mssql tests/integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,31 +9,23 @@ jobs: | |
update-grammar: | ||
name: Update TSQL grammar based on antlr4's grammar | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -el {0} | ||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- name: Set up Miniconda | ||
uses: conda-incubator/setup-miniconda@v3 | ||
fetch-depth: 0 | ||
- name: Set up pixi | ||
uses: prefix-dev/setup-[email protected] | ||
with: | ||
python-version: 3.11 | ||
miniforge-variant: Mambaforge | ||
miniforge-version: 4.11.0-2 | ||
use-mamba: true | ||
environment-file: environment.yml | ||
environments: grammar | ||
- name: Download ANTLR | ||
working-directory: src/pytsql/grammar | ||
run: wget https://repo1.maven.org/maven2/org/antlr/antlr4/4.13.1/antlr4-4.13.1-complete.jar | ||
- name: Download latest grammar definition and re-generate grammar targets | ||
working-directory: src/pytsql/grammar | ||
run: | | ||
bash helper_generate_grammar_targets.sh antlr4-4.13.1-complete.jar -d | ||
- name: Install package | ||
run: pip install . | ||
run: pixi run update-grammar | ||
- name: Install package (test compilation) | ||
run: | ||
pixi run -e grammar pip install . | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,61 @@ | ||
exclude: (^\.pixi)|(^src\/pytsql\/grammar\/) | ||
repos: | ||
- repo: https://github.com/Quantco/pre-commit-mirrors-black | ||
rev: 24.4.2 | ||
hooks: | ||
- id: black-conda | ||
args: | ||
- --safe | ||
- --target-version=py38 | ||
exclude: ^src/pytsql/grammar/ | ||
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff | ||
rev: 0.6.2 | ||
hooks: | ||
- id: ruff-conda | ||
exclude: ^src/pytsql/grammar/ | ||
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy | ||
rev: "1.10.1" | ||
hooks: | ||
- id: mypy-conda | ||
additional_dependencies: [ -c, conda-forge, types-setuptools ] | ||
exclude: ^src/pytsql/grammar/ | ||
- repo: local | ||
hooks: | ||
# ensure pixi environments are up to date | ||
# workaround for https://github.com/prefix-dev/pixi/issues/1482 | ||
- id: pixi-install | ||
name: pixi-install | ||
entry: pixi install -e default -e lint | ||
language: system | ||
always_run: true | ||
require_serial: true | ||
pass_filenames: false | ||
- id: ruff | ||
name: ruff | ||
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude | ||
language: system | ||
types_or: [python, pyi] | ||
require_serial: true | ||
- id: ruff-format | ||
name: ruff-format | ||
entry: pixi run -e lint ruff format --force-exclude | ||
language: system | ||
types_or: [python, pyi] | ||
require_serial: true | ||
- id: mypy | ||
name: mypy | ||
entry: pixi run -e default mypy | ||
language: system | ||
types: [python] | ||
args: ["--ignore-missing-imports", "--scripts-are-modules"] | ||
require_serial: true | ||
# taplo | ||
- id: taplo | ||
name: taplo | ||
entry: pixi run -e lint taplo format | ||
language: system | ||
types: [toml] | ||
# pre-commit-hooks | ||
- id: trailing-whitespace-fixer | ||
name: trailing-whitespace-fixer | ||
entry: pixi run -e lint trailing-whitespace-fixer | ||
language: system | ||
types: [text] | ||
- id: end-of-file-fixer | ||
name: end-of-file-fixer | ||
entry: pixi run -e lint end-of-file-fixer | ||
language: system | ||
types: [text] | ||
- id: check-merge-conflict | ||
name: check-merge-conflict | ||
entry: pixi run -e lint check-merge-conflict --assume-in-merge | ||
language: system | ||
types: [text] | ||
# typos | ||
- id: typos | ||
name: typos | ||
entry: pixi run -e lint typos --force-exclude | ||
language: system | ||
types: [text] | ||
require_serial: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,21 @@ Development | |
=========== | ||
|
||
|
||
The repository comes with a development environment file. We suggest to use ``conda`` | ||
and ``mamba``. | ||
The repository relies on ``pixi`` to manage dependencies. Please make sure you have a running version of `pixi <https://pixi.sh/latest/>`_. | ||
|
||
In order to get going, you can run | ||
In order to get going, you can run the following | ||
|
||
:: | ||
.. code-block:: bash | ||
# Clone the repository | ||
git clone [email protected]:Quantco/pytsql.git | ||
cd pytsql | ||
|
||
# Set up a conda environment with name "pytsql" and activate it. | ||
mamba env create | ||
conda activate pytsql | ||
$ git clone [email protected]:Quantco/pytsql.git | ||
$ cd pytsql | ||
# Set up our pre-commit hooks for black, mypy, isort and flake8. | ||
pre-commit install | ||
# Set up our pre-commit hooks for e.g. black, mypy and ruff. | ||
$ pixi run pre-commit-install | ||
# Install this package in editable mode. | ||
pip install --no-build-isolation -e . | ||
$ pixi run postinstall | ||
Unit tests | ||
|
@@ -30,11 +25,9 @@ Unit tests | |
``pytsql`` comes with some unit tests. Provided that the environment has been set | ||
up as illustrated in the previous step, they can be run as such: | ||
|
||
:: | ||
.. code-block:: bash | ||
conda activate pytsql | ||
cd pytsql | ||
pytest tests/unit/ | ||
$ pixi run pytest tests/unit/ | ||
Integration tests | ||
|
@@ -46,18 +39,17 @@ just execute the ``start_mssql.sql`` script provided. | |
|
||
Once the docker container is up and running, you can run the tests: | ||
|
||
:: | ||
.. code-block:: bash | ||
$ pixi run pytest tests/integration/ | ||
conda activate pytsql | ||
cd pytsql | ||
pytest tests/integration/ | ||
Add the option ``--backend=mssql-freetds`` to the test command to run the tests using | ||
the ``freetds`` driver. | ||
|
||
|
||
Grammar | ||
------------------ | ||
------- | ||
|
||
``pytsql`` relies on parsing the sql script at hand. In order to do so, it uses | ||
`antlr <https://www.antlr.org>`_, a parser generator. ``antlr`` expects grammar files | ||
|
@@ -71,7 +63,7 @@ To keep the package structure lean, ``pytql`` aims to be in sync with the refere | |
Therefore, if you want to extend or modify the grammar please consider contributing to the external repository instead. | ||
|
||
Update targets | ||
^^^^^^^^^^^^^^^^^ | ||
^^^^^^^^^^^^^^ | ||
|
||
All files in ``pytsql/src/pytsql/grammar/cpp_src/antlr4-cpp-runtime`` are taken directly from | ||
the `ANTLR repository release 4.11.1 | ||
|
Oops, something went wrong.