generated from nogibjj/python-template
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jay
authored and
Jay
committed
Nov 11, 2024
1 parent
6399d72
commit 15a1a7f
Showing
1 changed file
with
22 additions
and
31 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,46 +1,37 @@ | ||
# Install required Python packages | ||
install: | ||
pip install --upgrade pip &&\ | ||
pip install -r requirements.txt | ||
pip install --upgrade pip &&\ | ||
pip install -r requirements.txt | ||
|
||
# Run tests with pytest, show verbose output, and check code coverage | ||
test: | ||
python -m pytest -vv --cov=mylib test_*.py | ||
python -m pytest -vv --cov=mylib test_*.py | ||
|
||
# Format code with Black | ||
format: | ||
black *.py | ||
format: | ||
black *.py | ||
|
||
# Lint code using ruff (uncomment pylint for alternative linting) | ||
lint: | ||
# Uncomment below to test with pylint | ||
# pylint --disable=R,C --ignore-patterns=test_.*?py *.py mylib/*.py | ||
# ruff linting is 10-100X faster than pylint | ||
ruff check *.py mylib/*.py | ||
# Uncomment below to test with pylint | ||
# pylint --disable=R,C --ignore-patterns=test_.*?py *.py mylib/*.py | ||
# ruff linting is 10-100X faster than pylint | ||
ruff check *.py mylib/*.py | ||
|
||
# Lint Dockerfile using hadolint | ||
container-lint: | ||
docker run --rm -i hadolint/hadolint < Dockerfile | ||
docker run --rm -i hadolint/hadolint < Dockerfile | ||
|
||
# Refactor code by running format and lint sequentially | ||
refactor: format lint | ||
|
||
# Placeholder for deploy commands | ||
deploy: | ||
# Deploy commands go here | ||
|
||
# Run install, lint, test, format, and deploy in sequence | ||
# Deploy commands go here | ||
|
||
all: install lint test format deploy | ||
|
||
# Add, commit, and push generated files to GitHub (useful in CI/CD) | ||
generate_and_push: | ||
# Add, commit, and push the generated files to GitHub | ||
@if [ -n "$$(git status --porcelain)" ]; then \ | ||
git config --local user.email "action@github.com"; \ | ||
git config --local user.name "GitHub Action"; \ | ||
git add .; \ | ||
git commit -m "Add output log"; \ | ||
git push; \ | ||
else \ | ||
echo "No changes to commit. Skipping commit and push."; \ | ||
fi | ||
# Add, commit, and push the generated files to GitHub | ||
@if [ -n "$$(git status --porcelain)" ]; then \ | ||
git config --local user.email "action@github.com"; \ | ||
git config --local user.name "GitHub Action"; \ | ||
git add .; \ | ||
git commit -m "Add output log"; \ | ||
git push; \ | ||
else \ | ||
echo "No changes to commit. Skipping commit and push."; \ | ||
fi |