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

Add static check #231

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ jobs:
venv/bin/python3 -m pip install tox-gh-actions
env:
SLUGIFY_USES_TEXT_UNIDECODE: yes
- name: Check formatting with black
run: make fmt-check
- name: Lint with pylint
run: make lint
- name: Test with tox
run: make test
- name: Upload coverage to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: test

on:
push: # Run on pushes to the default branch
branches: [main, pre-commit]
tatiana marked this conversation as resolved.
Show resolved Hide resolved
pull_request_target: # Also run on pull requests originated from forks
branches: [main, pre-commit]
tatiana marked this conversation as resolved.
Show resolved Hide resolved

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Authorize:
environment: ${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true

Static-Check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- uses: actions/setup-python@v3
with:
python-version: "3.12"
architecture: "x64"

- run: pip3 install hatch
- run: hatch run tests.py3.12-2.10:static-check
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args:
- --fix

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
args:
- --unsafe
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: pretty-format-json
args: [ "--autofix" ]
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: [ "--config", "./pyproject.toml" ]
16 changes: 1 addition & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ clean: ## Removes build and test artifacts
@find . -name '*~' -exec rm -f {} +
@find . -name '__pycache__' -exec rm -rf {} +

.PHONY: fmt
fmt: venv ## Formats all files with black
@echo "==> Formatting with Black"
@${PYTHON} -m black dagfactory

.PHONY: fmt-check
fmt-check: venv ## Checks files were formatted with black
@echo "==> Formatting with Black"
@${PYTHON} -m black --check dagfactory

.PHONY: lint
lint: venv ## Lint code with pylint
@${PYTHON} -m pylint dagfactory

.PHONY: test
test: venv ## Runs unit tests
@${PYTHON} -m tox
Expand All @@ -57,4 +43,4 @@ docker-run: docker-build ## Runs local Airflow for testing

.PHONY: docker-stop
docker-stop: ## Stop Docker container
@docker stop dag_factory; docker rm dag_factory
@docker stop dag_factory; docker rm dag_factory
5 changes: 5 additions & 0 deletions dagfactory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""Modules and methods to export for easier access"""

from .dagfactory import DagFactory, load_yaml_dags

__all__ = [
"DagFactory",
"load_yaml_dags",
]
Loading
Loading