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

Use pre-commit to check styles #152

Merged
merged 14 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
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: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/0_new_bigfunction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ body:
- type: markdown
attributes:
value: |
## 🙏 Thanks for taking the time to suggest a new BigFunction!
## 🙏 Thanks for taking the time to suggest a new BigFunction!

Please fill the below fields to submit your idea.
- type: checkboxes
id: idea_does_not_exist
attributes:
label: Check the idea has not already been suggested
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Anew-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Anew-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
options:
- label: I could not find my idea in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Anew-bigfunction)
required: true
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/1_bug_bigfunction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ body:
- type: markdown
attributes:
value: |
## 🙏 Thanks for taking the time to report a bug in a BigFunction!
## 🙏 Thanks for taking the time to report a bug in a BigFunction!

Please fill the below fields to submit it.
- type: checkboxes
id: idea_does_not_exist
attributes:
label: Check the bug has not already been reported
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
options:
- label: I could not find the bug in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction)
required: true
- type: checkboxes
id: title_is_ok
attributes:
label: Edit `function_name` and the short error description in title above
description: Edit the `function_name` and the short error description in the issue title above.
description: Edit the `function_name` and the short error description in the issue title above.
options:
- label: I wrote the correct function name and a short error description in the title above
required: true
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/2_improve_bigfunction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ body:
- type: markdown
attributes:
value: |
## 🙏 Thanks for taking the time to help us improve!
## 🙏 Thanks for taking the time to help us improve!

Please fill the below fields to submit it.
- type: checkboxes
id: idea_does_not_exist
attributes:
label: Check your idea has not already been reported
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
options:
- label: I could not find the idea in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfunction)
required: true
- type: checkboxes
id: title_is_ok
attributes:
label: Edit `function_name` and the short idea description in title above
description: Edit the `function_name` and the short idea description in the issue title above.
description: Edit the `function_name` and the short idea description in the issue title above.
options:
- label: I wrote the correct function name and a short idea description in the title above
required: true
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/3_bug_bigfun_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ body:
- type: markdown
attributes:
value: |
## 🙏 Thanks for taking the time to report a bug of `bigfun` Command-Line-Interface!
## 🙏 Thanks for taking the time to report a bug of `bigfun` Command-Line-Interface!

Please fill the below fields to submit it.
- type: checkboxes
id: idea_does_not_exist
attributes:
label: Check the bug has not already been reported
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfun-CLI) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfun-CLI) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
options:
- label: I could not find the bug in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Abug-bigfun-CLI)
required: true
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/4_improve_bigfun_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ body:
attributes:
value: |
## 🙏 Thanks for taking the time to help us improve!

Please fill the below fields to submit your idea.
- type: checkboxes
id: idea_does_not_exist
attributes:
label: Check your idea has not already been reported
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Aimprove-bigfun-CLI) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
description: Check in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Aimprove-bigfun-CLI) if your idea has not already been suggested. If it has, please don't create a new issue but add a comment on the existing one such as `+1` to upvote it.
options:
- label: I could not find the idea in [existing issues](https://github.com/unytics/bigfunctions/issues?q=is%3Aissue+is%3Aopen+label%3Aimprove-bigfun-CLI)
required: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install -e .
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: lint

on:
pull_request:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install -e .[dev]
- name: Run pre-commit
run: |
pre-commit run --all-files
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ tests/
site/

TEST
venv
venv
57 changes: 57 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: check-toml
- id: check-yaml
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies:
- types-PyYAML
files: "^logingress/.*"
unytics marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/rhysd/actionlint
rev: v1.7.1
hooks:
- id: actionlint-docker
- repo: https://github.com/shellcheck-py/shellcheck-py
unytics marked this conversation as resolved.
Show resolved Hide resolved
rev: v0.10.0.1
hooks:
- id: shellcheck
# TODO enable the hook
# - repo: https://github.com/PyCQA/bandit
# rev: 1.7.9
# hooks:
# - id: bandit
# name: bandit (python)
# args: [--configfile, bandit.yaml, --severity-level, all]
# additional_dependencies: [bandit]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [--strict, -c=.yamllint]
- repo: https://github.com/shellcheck-py/shellcheck-py
unytics marked this conversation as resolved.
Show resolved Hide resolved
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/pycqa/isort
unytics marked this conversation as resolved.
Show resolved Hide resolved
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
# TODO enable the hook
# - repo: https://github.com/hadolint/hadolint
# rev: v2.13.0-beta
# hooks:
# - id: hadolint-docker
10 changes: 10 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
rules:
trailing-spaces: disable
key-duplicates: {}
colons:
max-spaces-before: 0
max-spaces-after: 1
indentation:
spaces: 2
check-multi-line-strings: false
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Commands:

### 5.3 Create you first function 👷

Functions are defined as yaml files under `bigfunctions` folder. To create your first function locally, the easiest is to download an existing yaml file of unytics/bigfunctions Github repo.
Functions are defined as yaml files under `bigfunctions` folder. To create your first function locally, the easiest is to download an existing yaml file of unytics/bigfunctions Github repo.

For instance to download `is_email_valid.yaml` into bigfunctions folder, do:

Expand Down Expand Up @@ -229,4 +229,3 @@ BigFunctions is fully open-source. Any contribution is more than welcome 🤗!
<a href="https://github.com/unytics/bigfunctions/graphs/contributors">
<img src="https://contrib.rocks/image?repo=unytics/bigfunctions" />
</a>

6 changes: 6 additions & 0 deletions bandit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SEE https://bandit.readthedocs.io/en/latest/config.html
exclude_dirs:
- "tests"
skips:
# hardcoded_sql_expressions
- "B608"
14 changes: 8 additions & 6 deletions bigfun/bigfunctions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import tempfile
import re
import functools
import json
import os
import re
import shutil
import json
import functools
import tempfile

import yaml
import jinja2
import yaml

from .utils import BigQuery, CloudRun, handle_error, print_success, print_info, print_command, build_and_upload_npm_package, merge_dict
from .utils import (BigQuery, CloudRun, build_and_upload_npm_package,
handle_error, merge_dict, print_command, print_info,
print_success)

BIGFUNCTIONS_FOLDER = 'bigfunctions'
DEFAULT_CONFIG_FILENAME = './config.yaml'
Expand Down
Loading