Skip to content
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
10 changes: 3 additions & 7 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
- name: Lint with flake8, black, isort
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
scripts/lint.sh
- name: Test with pytest
run: |
pytest
scripts/test.sh
49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,45 @@ First, a local project environment needs to be created, then the project's modul
deactivate
```

3. Make your changes, increment the version in `pyproject.toml`, and **build** the application.
3. Make your changes, increment the version in `pyproject.toml`, and open a **Pull Request**.

```sh
# Build a Python package distribution
scripts/build.sh
# Create a branch to isolate your changes
git branch my-new-feature

# Publish a distribution to PyPi (testpypi)
scripts/release.sh
# Hop onto the branch to add your changes
git checkout my-new-feature

# Install the Python package locally, from testpypi.
scripts/install.sh "<VERSION>"
# Make your changes and commit them
git add .
git commit -m "Added My New Feature"

# Execute Unit Tests
scripts/test.sh
# Push the changes to your branch (first push)
git push --set-upstream origin my-new-feature

# Execute Code Samples
scripts/examples.sh
# All future pushes
git push

# Lint Code Base
scripts/lint.sh
```
# Create a pull request using the provided link after pushing
remote:
remote: Create a pull request for 'my-new-feature' on GitHub by visiting:
remote: https://github.com/bellanov/pythonic-programming/pull/new/my-new-feature

# Rev the version in pyproject.toml and tag the changes
git tag -a "0.1.0" -m "Version 0.1.0"

# Push the tags
git push --follow-tags
```

## Testing, Linting, and Formatting

Be sure to constantly *test*, *lint*, and *format* the code base while developing.

```sh
# Execute Unit Tests
scripts/test.sh

# Lint Code Base
scripts/lint.sh
```
1 change: 1 addition & 0 deletions python_template/calc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Simple Python Program.
"""

import logging

# Configure string format for consumption into logging platforms.
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
black
coverage
flake8
isort
pytest
16 changes: 16 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Format Code Base.

# Format Imports
echo "Formatting imports..."
isort python_template
isort tests

# Format Code
echo "Formatting code base..."
black python_template

# Format Tests
echo "Formatting tests..."
black tests
8 changes: 7 additions & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ echo "Linting code base..."
flake8 python_template --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 python_template --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# Check for code formatting issues
black --check python_template
isort --check python_template

# Lint Tests
echo "Linting tests..."

# stop the build if there are Python syntax errors or undefined names
flake8 tests --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# Check test formatting issues
black --check tests
isort --check tests
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ echo "Generating Report..."
coverage report -m

echo "Build HTML Report..."
coverage html
coverage html