-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: justfile, bandit, cleanup, version const, drop py37
- Loading branch information
1 parent
1c769cc
commit b688c14
Showing
10 changed files
with
137 additions
and
108 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[report] | ||
exclude_lines = | ||
if __name__ == '__main__': | ||
[run] | ||
omit = project_name/_version.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 |
---|---|---|
@@ -1,40 +1,52 @@ | ||
name: build | ||
|
||
on: [push, pull_request] | ||
on: | ||
push: | ||
paths: | ||
- '.github/workflows/build.yml' | ||
- '**/*.py' | ||
branches: | ||
- '**' | ||
tags: | ||
- '!**' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/build.yml' | ||
- '**/*.py' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
- uses: actions/checkout@v3 | ||
- uses: extractions/setup-just@v1 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install Dependencies | ||
run: make install | ||
- name: Check format | ||
run: make format-check | ||
python-version: '3.11' | ||
- run: just install lint | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
pythonversion: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
pythonversion: ['3.8', '3.9', '3.10', '3.11'] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
- uses: actions/checkout@v3 | ||
- uses: extractions/setup-just@v1 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.pythonversion }} | ||
- name: Install Dependencies | ||
run: make install | ||
- name: Run tests | ||
run: make coverage | ||
- name: Coveralls | ||
if: github.ref == 'refs/heads/main' | ||
uses: coverallsapp/github-action@master | ||
- run: just install coverage | ||
coverage: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: extractions/setup-just@v1 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
- run: just install coverage | ||
- uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
path-to-lcov: "./coverage.lcov" | ||
path-to-lcov: './coverage.lcov' |
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
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
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 @@ | ||
PYTHON_BINARY := "python3" | ||
VIRTUAL_ENV := "venv" | ||
VIRTUAL_BIN := VIRTUAL_ENV / "bin" | ||
PROJECT_NAME := "project_name" | ||
TEST_DIR := "test" | ||
|
||
# Scans the project for security vulnerabilities | ||
bandit: | ||
{{VIRTUAL_BIN}}/bandit -r {{PROJECT_NAME}}/ | ||
|
||
# Builds the project in preparation for release | ||
build: | ||
{{VIRTUAL_BIN}}/python -m build | ||
|
||
# Runs the Black Python formatter against the project | ||
black: | ||
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/ | ||
|
||
# Checks if the project is formatted correctly against the Black rules | ||
black-check: | ||
{{VIRTUAL_BIN}}/black {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check | ||
|
||
# Test the project and generate an HTML coverage report | ||
coverage: | ||
{{VIRTUAL_BIN}}/pytest --cov={{PROJECT_NAME}} --cov-branch --cov-report=html --cov-report=lcov --cov-report=term-missing --cov-fail-under=90 | ||
|
||
# Cleans the project | ||
clean: | ||
rm -rf {{VIRTUAL_ENV}} dist *.egg-info .coverage htmlcov .*cache | ||
find . -name '*.pyc' -delete | ||
|
||
# Run flake8 checks against the project | ||
flake8: | ||
{{VIRTUAL_BIN}}/flake8 {{PROJECT_NAME}}/ {{TEST_DIR}}/ | ||
|
||
# Lints the project | ||
lint: black-check isort-check flake8 mypy bandit | ||
|
||
# Runs all formatting tools against the project | ||
lint-fix: black isort | ||
|
||
# Install the project locally | ||
install: | ||
{{PYTHON_BINARY}} -m venv {{VIRTUAL_ENV}} | ||
{{VIRTUAL_BIN}}/pip install -e ."[dev]" | ||
|
||
# Sorts imports throughout the project | ||
isort: | ||
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/ | ||
|
||
# Checks that imports throughout the project are sorted correctly | ||
isort-check: | ||
{{VIRTUAL_BIN}}/isort {{PROJECT_NAME}}/ {{TEST_DIR}}/ --check-only | ||
|
||
# Run mypy type checking on the project | ||
mypy: | ||
{{VIRTUAL_BIN}}/mypy {{PROJECT_NAME}}/ {{TEST_DIR}}/ | ||
|
||
# Test the project | ||
test: | ||
{{VIRTUAL_BIN}}/pytest |
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 @@ | ||
__version__ = '0.1.0' |
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