Skip to content

Commit

Permalink
Add linting GitHub action (#33)
Browse files Browse the repository at this point in the history
* Added git workflow for precommit checks.

* add black pipeline

* LINT

* Added pull_request.yml and renamed pre-commit-checks.yml.

* Add mypy to pre-commit checks in git workflows.

* Added setup.cfg file.

* Changed the package directory in setup.cfg.

* Updated setup.cfg to include correct dev tools. Removed __init__.py at top level. Bumped version number.

* Updated pull_request.yml.

* move version to __init__.py file

* move setup parameters to setup.cfg

* fix package definition

* add pull-request code-checks

* cleanup requirements

* update setup.py

* remove mypy code check

* remove old linting workflow

* minor improvements

Co-authored-by: swanderz <[email protected]>
Co-authored-by: Stepan Burlakov <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2022
1 parent e66b88d commit 7ce74f2
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 57 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Python code checks

on:
workflow_call:
push:
branches: [ main ]

jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
- name: Run pre-commit checks
uses: pre-commit/[email protected]
with:
extra_args: --all-files
16 changes: 16 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pull request

on:
pull_request:
branches: [ main ]

jobs:
code-checkers:
uses: firebolt-db/dbt-firebolt/.github/workflows/code-check.yml@main
check-title:
runs-on: ubuntu-latest
steps:
- name: Check title name convention
uses: jef/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v.0.21.8

### Under the hood

- Updated pre-commit linting and added pull request linting.

## v.0.21.7

### Changes
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.21.6'
__version__ = '0.21.8'
2 changes: 2 additions & 0 deletions dbt/adapters/firebolt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from dbt.adapters.firebolt.impl import FireboltAdapter
from dbt.include import firebolt

__version__ = '0.21.8'

Plugin = AdapterPlugin(
adapter=FireboltAdapter,
credentials=FireboltCredentials,
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/firebolt/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.21.7'
from dbt.adapters.firebolt import __version__ as version # noqa
2 changes: 1 addition & 1 deletion dbt/adapters/firebolt/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dbt.dataclass_schema import ValidationError, dbtClassMixin

from dbt.adapters.firebolt.connections import FireboltConnectionManager
from dbt.adapters.firebolt.relation import FireboltRelation
from dbt.adapters.firebolt.relation import FireboltRelation


@dataclass
Expand Down
51 changes: 51 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[metadata]
name = dbt_firebolt
version = attr: dbt.adapters.firebolt.__version__
description = The Firebolt adapter plugin for dbt (data build tool)
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/firebolt-db/dbt-firebolt
author = Firebolt
author_email = [email protected]
license = Apache-2.0
license_file = LICENSE
classifiers =
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
project_urls =
Bug Tracker = https://github.com/firebolt-db/dbt-firebolt/issues

[options]
packages = find_namespace:
install_requires =
jaydebeapi
python_requires = >=3.7
include_package_data = True
package_dir =
= dbt

[options.packages.find]
where = dbt

[options.extras_require]
dev =
mypy>=0.910
pre-commit==2.15.0
pytest==6.2.5
pytest-dbt-adapter==0.6.0

[mypy]
disallow_untyped_defs = True
show_error_codes = True

[flake8]
max-line-length = 88
per-file-ignores = __init__.py:F401
ignore = E203, W503
ban-relative-imports = True
inline-quotes = '
61 changes: 7 additions & 54 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,10 @@
#!/usr/bin/env python
import os
import re
from setuptools import setup
from setuptools.config import read_configuration

from setuptools import find_namespace_packages, setup
config = read_configuration('setup.cfg')
version = config['metadata']['version']
dbt_version = version.rsplit('.', 1)[0]
install_requires = [f'dbt-core~={dbt_version}', config['options']['install_requires']]

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md')) as f:
long_description = f.read()


def _dbt_synapse_version():
"""
get version from __version__.py so that version is accessible via:
- `dbt --version` and
- dbt debug
"""
_version_path = os.path.join(
this_directory, 'dbt', 'adapters', 'firebolt', '__version__.py'
)
_version_pattern = r"""version\s*=\s*["'](.+)["']"""
with open(_version_path) as f:
match = re.search(_version_pattern, f.read().strip())
if match is None:
raise ValueError(f'invalid version at {_version_path}')
return match.group(1)


package_name = 'dbt-firebolt'
package_version = _dbt_synapse_version()
description = 'The Firebolt adapter plugin for dbt (data build tool)'
dbt_version = '0.21'

# the package version should be the dbt version, with maybe some things on the
# ends of it. (0.18.1 vs 0.18.1a1, 0.18.1.1, ...)
if not package_version.startswith(dbt_version):
raise ValueError(
f'Invalid setup.py: package_version={package_version} must start with '
f'dbt_version={dbt_version}'
)

setup(
name=package_name,
version=package_version,
description=description,
long_description=description,
long_description_content_type='text/markdown',
author='Shahar Shalev, Eric Ford, and Anders Swanson',
author_email='[email protected]',
url='https://github.com/firebolt-db/dbt-firebolt',
packages=find_namespace_packages(include=['dbt', 'dbt.*']),
include_package_data=True,
install_requires=[
'dbt-core~={}'.format(dbt_version),
'jaydebeapi',
],
)
setup(install_requires=install_requires)

0 comments on commit 7ce74f2

Please sign in to comment.