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

Fiddle: update dependencies and add targets to scripts #23

Merged
merged 4 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
json-file-path: ./lint-check-results.json
check-name: core-lint-check
check-name: lint-check
fail-on-error: false
- name: Run type-check
run: |
Expand All @@ -32,7 +32,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
json-file-path: ./type-check-results.json
check-name: core-type-check
check-name: type-check
fail-on-error: false
- name: Run security-check
run: |
Expand All @@ -43,5 +43,5 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
json-file-path: ./security-check-results.json
check-name: core-security-check
check-name: security-check
fail-on-error: false
11 changes: 5 additions & 6 deletions buildpy/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import List

import click
from pylint.lint import Run as run_pylint # type: ignore[import]
from pylint.reporters import CollectingReporter # type: ignore[import]
from pylint.lint import Run as run_pylint
from pylint.reporters import CollectingReporter

from buildpy.util import GitHubAnnotationsReporter
from buildpy.util import Message
Expand Down Expand Up @@ -40,16 +40,15 @@ def get_messages(self) -> List[Message]:


@click.command()
@click.option('-d', '--directory', 'directory', required=False, type=str)
@click.argument('targets', nargs=-1)
@click.option('-o', '--output-file', 'outputFilename', required=False, type=str)
@click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty')
@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str)
def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None:
def run(targets: List[str], outputFilename: str, outputFormat: str, configFilePath: str) -> None:
currentDirectory = os.path.dirname(os.path.realpath(__file__))
targetDirectory = os.path.abspath(directory or os.getcwd())
pylintConfigFilePath = configFilePath or f'{currentDirectory}/pylintrc'
pylintMessageParser = PylintMessageParser()
run_pylint([f'--rcfile={pylintConfigFilePath}', f'--jobs=0', targetDirectory], reporter=pylintMessageParser, exit=False)
run_pylint([f'--rcfile={pylintConfigFilePath}', f'--jobs=0'] + list(targets), reporter=pylintMessageParser, exit=False)
reporter = GitHubAnnotationsReporter() if outputFormat == 'annotations' else PrettyReporter()
output = reporter.create_output(messages=pylintMessageParser.get_messages())
if outputFilename:
Expand Down
9 changes: 4 additions & 5 deletions buildpy/security_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,18 @@ def parse_messages(self, rawMessages: List[str]) -> List[Message]:


@click.command()
@click.option('-d', '--directory', 'directory', required=False, type=str)
@click.argument('targets', nargs=-1)
@click.option('-o', '--output-file', 'outputFilename', required=False, type=str)
@click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty')
@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str)
def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None:
def run(targets: List[str], outputFilename: str, outputFormat: str, configFilePath: str) -> None:
currentDirectory = os.path.dirname(os.path.realpath(__file__))
targetDirectory = os.path.abspath(directory or os.getcwd())
messages = []
messages: List[str] = []
banditConfigFilePath = configFilePath or f'{currentDirectory}/bandit.yaml'
# TODO(krishan711): use test_name here once enabled https://github.com/PyCQA/bandit/issues/962
messageTemplate = '{abspath}\t{line}\t{col}\t{test_id}\t{msg}\t{severity}'
try:
subprocess.check_output(f'bandit --configfile {banditConfigFilePath} --silent --severity-level medium --confidence-level medium --format custom --msg-template \"{messageTemplate}\" --recursive {targetDirectory}', stderr=subprocess.STDOUT, shell=True) # nosec=subprocess_popen_with_shell_equals_true
subprocess.check_output(f'bandit --configfile {banditConfigFilePath} --silent --severity-level medium --confidence-level medium --format custom --msg-template \"{messageTemplate}\" --recursive {" ".join(targets)}', stderr=subprocess.STDOUT, shell=True) # nosec=subprocess_popen_with_shell_equals_true
except subprocess.CalledProcessError as exception:
messages = exception.output.decode().split('\n')
messageParser = BanditMessageParser()
Expand Down
9 changes: 4 additions & 5 deletions buildpy/type_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ def parse_messages(self, rawMessages: List[str]) -> List[Message]:


@click.command()
@click.option('-d', '--directory', 'directory', required=False, type=str)
@click.argument('targets', nargs=-1)
@click.option('-o', '--output-file', 'outputFilename', required=False, type=str)
@click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty')
@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str)
def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None:
def run(targets: List[str], outputFilename: str, outputFormat: str, configFilePath: str) -> None:
currentDirectory = os.path.dirname(os.path.realpath(__file__))
targetDirectory = os.path.abspath(directory or os.getcwd())
messages = []
mypyConfigFilePath = configFilePath or f'{currentDirectory}/mypy.ini'
messages: List[str] = []
try:
subprocess.check_output(f'mypy {targetDirectory} --config-file {mypyConfigFilePath} --no-color-output --hide-error-context --no-pretty --no-error-summary --show-error-codes --show-column-numbers', stderr=subprocess.STDOUT, shell=True) # nosec=subprocess_popen_with_shell_equals_true
subprocess.check_output(f'mypy {" ".join(targets)} --config-file {mypyConfigFilePath} --no-color-output --hide-error-context --no-pretty --no-error-summary --show-error-codes --show-column-numbers', stderr=subprocess.STDOUT, shell=True) # nosec=subprocess_popen_with_shell_equals_true
except subprocess.CalledProcessError as exception:
messages = exception.output.decode().split('\n')
messageParser = MypyMessageParser()
Expand Down
16 changes: 8 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ list-outdated: install
@ pip list -o

lint-check:
@ lint --directory ./buildpy
@ lint *.py ./buildpy

lint-check-ci:
@ lint --directory ./buildpy --output-file lint-check-results.json --output-format annotations
@ lint *.py ./buildpy --output-file lint-check-results.json --output-format annotations

lint-fix:
@ isort --sl -l 1000 ./buildpy
@ lint --directory ./buildpy
@ isort --sl -l 1000 *.py ./buildpy
@ lint *.py ./buildpy

type-check:
@ type-check --directory ./buildpy
@ type-check *.py ./buildpy

type-check-ci:
@ type-check --directory ./buildpy --output-file type-check-results.json --output-format annotations
@ type-check *.py ./buildpy --output-file type-check-results.json --output-format annotations

security-check:
@ security-check --directory ./buildpy
@ security-check *.py ./buildpy

security-check-ci:
@ security-check --directory ./buildpy --output-file security-check-results.json --output-format annotations
@ security-check *.py ./buildpy --output-file security-check-results.json --output-format annotations

build:
@ echo "Not Supported"
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
bump2version~=1.0.1
click~=8.1.7
asyncclick~=8.1.3.4
asyncclick~=8.1.7.2
simple_chalk~=0.1.0
pylint~=2.17.5
mypy~=1.5.1
wheel~=0.41.2
bandit~=1.7.5
twine~=4.0.1
pylint~=3.2.6
mypy~=1.11.1
wheel~=0.44.0
bandit~=1.7.9
twine~=5.1.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from setuptools import find_packages
from setuptools import find_packages # type: ignore[import-untyped]
from setuptools import setup

setupDirectory = os.path.dirname(os.path.realpath(__file__))
Expand Down
Loading