forked from dbt-labs/dbt-athena
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add linting, pre-commit and github actions (dbt-labs#24)
* chore: add linting, pre-commit and github actions Closes dbt-labs#8 * chore: add autoflake and pyupgrade, improve makefile * chore improve README.md on contributing
- Loading branch information
Showing
20 changed files
with
281 additions
and
165 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,16 @@ | ||
name: ci | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
pre-commit: | ||
name: 'Pre-commit checks' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
- uses: pre-commit/[email protected] |
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 |
---|---|---|
|
@@ -141,4 +141,4 @@ cython_debug/ | |
.idea/ | ||
|
||
# Project specific | ||
test.py | ||
test.py |
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,61 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
# Identify invalid files | ||
- id: check-ast | ||
- id: check-yaml | ||
- id: check-json | ||
- id: check-toml | ||
|
||
# git checks | ||
- id: check-merge-conflict | ||
- id: check-added-large-files | ||
- id: detect-private-key | ||
- id: check-case-conflict | ||
|
||
# Python checks | ||
- id: check-docstring-first | ||
- id: debug-statements | ||
- id: requirements-txt-fixer | ||
- id: fix-byte-order-marker | ||
|
||
# General quality checks | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
args: [ --markdown-linebreak-ext=md ] | ||
- id: end-of-file-fixer | ||
|
||
- repo: https://github.com/PyCQA/autoflake | ||
rev: v1.7.7 | ||
hooks: | ||
- id: autoflake | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.2.2 | ||
hooks: | ||
- id: pyupgrade | ||
args: | ||
- '--py37-plus' | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
name: isort | ||
args: | ||
- '.' | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- "Flake8-pyproject~=1.1" | ||
args: | ||
- '.' |
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,10 +1,31 @@ | ||
include dev.env | ||
export | ||
|
||
install_deps: | ||
pip install -r dev_requirements.txt | ||
CHANGED_FILES := $(shell git ls-files --modified --other --exclude-standard) | ||
CHANGED_FILES_IN_BRANCH := $(shell git diff --name-only $(shell git merge-base origin/main HEAD)) | ||
|
||
.PHONY : install_deps setup pre-commit pre-commit-in-branch pre-commit-all run_tests help | ||
|
||
install_deps: ## Install all dependencies. | ||
pip install -r dev-requirements.txt | ||
pip install -r requirements.txt | ||
pip install -e . | ||
|
||
run_tests: | ||
pytest test/integration/athena.dbtspec | ||
setup: ## Install all dependencies and setup pre-commit | ||
make install_deps | ||
pre-commit install | ||
|
||
pre-commit: ## check modified and added files (compared to last commit!) with pre-commit. | ||
pre-commit run --files $(CHANGED_FILES) | ||
|
||
pre-commit-in-branch: ## check changed since origin/main files with pre-commit. | ||
pre-commit run --files $(CHANGED_FILES_IN_BRANCH) | ||
|
||
pre-commit-all: ## Check all files in working directory with pre-commit. | ||
pre-commit run --all-files | ||
|
||
run_tests: ## Run tests. | ||
pytest test/integration/athena.dbtspec | ||
|
||
help: ## Show this help. | ||
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}' |
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,14 +1,7 @@ | ||
from dbt.adapters.athena.connections import AthenaConnectionManager | ||
from dbt.adapters.base import AdapterPlugin | ||
|
||
from dbt.adapters.athena.connections import AthenaCredentials | ||
from dbt.adapters.athena.impl import AthenaAdapter | ||
import dbt.adapters.athena.query_headers | ||
|
||
from dbt.adapters.base import AdapterPlugin | ||
from dbt.include import athena | ||
|
||
|
||
Plugin = AdapterPlugin( | ||
adapter=AthenaAdapter, | ||
credentials=AthenaCredentials, | ||
include_path=athena.PACKAGE_PATH | ||
) | ||
Plugin = AdapterPlugin(adapter=AthenaAdapter, credentials=AthenaCredentials, include_path=athena.PACKAGE_PATH) |
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
Oops, something went wrong.