Skip to content

Commit

Permalink
feat: finish init adapter implementation (#1)
Browse files Browse the repository at this point in the history
* feat: finish init adapter implementation

* fix: precommit

* fix: stop docker in ci
  • Loading branch information
TylerHillery authored Feb 24, 2024
1 parent d683cd2 commit 8a43507
Show file tree
Hide file tree
Showing 18 changed files with 738 additions and 218 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Integration

on:
push:
branches: [ main ]
pull_request:

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
test:
name: ${{ matrix.os }} - ${{ matrix.py }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu
py:
- "3.9"
steps:
- name: Check out Repo
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Start FlightSQL and Postgres Server
shell: bash -l {0}
run: |
docker-compose up -d
- name: Set up Python ${{ matrix.py }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Load cached Poetry installation
id: cached-poetry-install
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Poetry
if: steps.cached-poetry-install.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: 1.4.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --with dev --sync --no-interaction --all-extras
- name: Run tests
run: |
source .venv/bin/activate
pytest
- name: Store snapshot report on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: Snapshot Report ${{ matrix.os }} ${{ matrix.py }}
path: ./snapshot_report.html
- name: Stop FlightSQL and Postgres Server
shell: bash -l {0}
run: |
docker-compose down
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Publish Package

on:
pull_request:
branches:
- main
types:
- closed

jobs:
publish-package:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }}
runs-on: ubuntu-latest

steps:
- name: Check out harlequin-adbc main branch
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
- name: Configure poetry
run: poetry config --no-interaction pypi-token.pypi ${{ secrets.HARLEQUIN_ADBC_PYPI_TOKEN }}
- name: Get harlequin-adbc Version
id: harlequin_adbc_version
run: echo "harlequin_adbc_version=$(poetry version --short)" >> $GITHUB_OUTPUT
- name: Build package
run: poetry build --no-interaction
- name: Publish package to PyPI
run: poetry publish --no-interaction
- name: Create a Github Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.harlequin_adbc_version.outputs.harlequin_adbc_version }}
target_commitish: main
token: ${{ secrets.HARLEQUIN_ADBC_RELEASE_TOKEN }}
body_path: CHANGELOG.md
files: |
LICENSE
dist/*harlequin*.whl
dist/*harlequin*.tar.gz
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create Release Branch

on:
workflow_dispatch:
inputs:
newVersion:
description: A version number for this release (e.g., "0.1.0")
required: true

jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Check out harlequin-adbc main branch
uses: actions/checkout@v4
with:
ref: main
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
- name: Create release branch
run: |
git checkout -b release/v${{ github.event.inputs.newVersion }}
git push --set-upstream origin release/v${{ github.event.inputs.newVersion }}
- name: Bump version
run: poetry version ${{ github.event.inputs.newVersion }} --no-interaction
- name: Ensure package can be built
run: poetry build --no-interaction
- name: Update CHANGELOG
uses: thomaseizinger/keep-a-changelog-new-release@v1
with:
version: ${{ github.event.inputs.newVersion }}
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Bumps version to ${{ github.event.inputs.newVersion }}
- name: Create pull request into main
uses: thomaseizinger/create-pull-request@1.3.1
env:
GITHUB_TOKEN: ${{ secrets.HARLEQUIN_ADBC_RELEASE_TOKEN }}
with:
head: release/v${{ github.event.inputs.newVersion }}
base: main
title: v${{ github.event.inputs.newVersion }}
body: >
This PR was automatically generated. It bumps the version number
in pyproject.toml and updates CHANGELOG.md. You may have to close
this PR and reopen it to get the required checks to run.
21 changes: 21 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Perform Static Analysis"

on:
push:
branches: [ main ]
pull_request:

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- uses: pre-commit/action@v3.0.1
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: name-tests-test
args: [--pytest-test-first]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
- harlequin
- types-pygments
- importlib_metadata
- pytest
args:
- "--disallow-untyped-calls"
- "--disallow-untyped-defs"
- "--disallow-incomplete-defs"
- "--strict-optional"
- "--warn-return-any"
- "--warn-no-return"
- "--warn-redundant-casts"
- "--no-warn-unused-ignores"
- "--allow-untyped-decorators"
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11
3.9
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Harlequin-Trino CHANGELOG

All notable changes to this project will be documented in this file.

## [Unreleased]

### Features

- Implement first working version of adapter
21 changes: 5 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
.PHONY: check
check:
ruff format .
ruff . --fix
mypy
pytest

.PHONY: init
init:
docker-compose up -d

.PHONY: clean
clean:
docker-compose down
pre-commit run --all-files

.PHONY: serve-postgres
serve-postgres:
Expand All @@ -23,8 +12,8 @@ serve-flightsql:

.PHONY: serve-snowflake
serve-snowflake:
harlequin -P None -a adbc "$$SNOWFLAKE_URI" --driver-type snowflake
harlequin -P None -a adbc "$SNOWFLAKE_URI" --driver-type snowflake

.PHONY: serve-config-error
serve-config-error:
harlequin -P None -a adbc --driver-type snowflake
.PHONY: serve-sqlite
serve-sqlite:
harlequin -P None -a adbc ":memory:" --driver-type sqlite
Loading

0 comments on commit 8a43507

Please sign in to comment.