-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
4 changed files
with
58 additions
and
106 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
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,5 +1,9 @@ | ||
name: Auto Publish | ||
name: Version and Coverage | ||
on: | ||
workflow_run: | ||
workflows: ["Continuous Integration"] | ||
types: | ||
- completed | ||
push: | ||
branches: | ||
- main | ||
|
@@ -12,7 +16,7 @@ jobs: | |
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
|
||
- name: Install poetry | ||
run: make setup | ||
|
@@ -23,6 +27,10 @@ jobs: | |
- name: Bump version | ||
run: | | ||
poetry version prerelease | ||
- name: Update the coverage badge | ||
run: | | ||
make coverage | ||
- name: Commit changes | ||
run: | | ||
|
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,127 +1,71 @@ | ||
#* Variables | ||
### Variables | ||
# Define shell and Python environment variables | ||
SHELL := /usr/bin/env bash | ||
PYTHON := python | ||
PYTHONPATH := `pwd` | ||
#* Docker variables | ||
IMAGE := lighter | ||
VERSION := latest | ||
|
||
|
||
#* Poetry | ||
|
||
#* Fix for issue with poetry | ||
### Poetry Setup | ||
# Install Poetry and configure environment | ||
.PHONY: setup | ||
setup: poetry-download | ||
@echo export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring >> ~/.bashrc | ||
@echo export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring >> ~/.profile | ||
source ~/.bashrc | ||
source ~/.profile | ||
poetry self add poetry-bumpversion@latest | ||
poetry self add poetry-plugin-export@latest | ||
|
||
|
||
.PHONY: poetry-download | ||
poetry-download: | ||
setup: | ||
curl -sSL https://install.python-poetry.org | $(PYTHON) - | ||
@echo "export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring" >> ~/.bashrc | ||
@echo "export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring" >> ~/.profile | ||
poetry self add poetry-bumpversion@latest poetry-plugin-export@latest | ||
|
||
.PHONY: poetry-remove | ||
poetry-remove: | ||
curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall | ||
|
||
#* Installation | ||
### Installation | ||
# Install project dependencies | ||
.PHONY: install | ||
install: | ||
poetry install -n | ||
|
||
# Install pre-commit hooks | ||
.PHONY: pre-commit-install | ||
pre-commit-install: | ||
poetry run pre-commit install | ||
|
||
#* Formatters | ||
.PHONY: codestyle | ||
codestyle: | ||
poetry run pyupgrade --exit-zero-even-if-changed --py37-plus **/*.py | ||
poetry run isort --settings-path pyproject.toml ./ | ||
poetry run black --config pyproject.toml ./ | ||
|
||
.PHONY: formatting | ||
formatting: codestyle | ||
|
||
#* Linting | ||
.PHONY: test | ||
test: | ||
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=lighter tests/ | ||
poetry run coverage-badge -o assets/images/coverage.svg -f | ||
|
||
### Linting & Testing | ||
# Check code formatting and style | ||
.PHONY: check-codestyle | ||
check-codestyle: | ||
poetry run isort --diff --check-only --settings-path pyproject.toml ./ | ||
poetry run black --diff --check --config pyproject.toml ./ | ||
poetry run pylint lighter | ||
|
||
.PHONY: mypy | ||
mypy: | ||
poetry run mypy --config-file pyproject.toml ./ | ||
|
||
# Run security checks | ||
.PHONY: check-safety | ||
check-safety: | ||
poetry check | ||
poetry export | poetry run safety check --stdin | ||
poetry run bandit -ll --recursive lighter tests | ||
|
||
.PHONY: lint | ||
lint: test check-codestyle mypy check-safety | ||
# Run tests with coverage report | ||
.PHONY: test | ||
test: | ||
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=lighter tests/ | ||
|
||
# Generate coverage badge | ||
.PHONY: coverage | ||
coverage: | ||
poetry run coverage-badge -o assets/images/coverage.svg -f | ||
|
||
### Dependency Management | ||
# Update development dependencies | ||
.PHONY: update-dev-deps | ||
update-dev-deps: | ||
poetry add -G dev bandit@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-html@latest pytest-cov@latest | ||
poetry add -G dev bandit@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest \ | ||
pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest \ | ||
pytest-html@latest pytest-cov@latest | ||
poetry add -G dev --allow-prereleases black@latest | ||
|
||
#* Docker | ||
# Example: make docker-build VERSION=latest | ||
# Example: make docker-build IMAGE=some_name VERSION=0.0.1 | ||
.PHONY: docker-build | ||
docker-build: | ||
@echo Building docker $(IMAGE):$(VERSION) ... | ||
docker build \ | ||
-t $(IMAGE):$(VERSION) . \ | ||
-f ./docker/Dockerfile --no-cache | ||
|
||
# Example: make docker-remove VERSION=latest | ||
# Example: make docker-remove IMAGE=some_name VERSION=0.0.1 | ||
.PHONY: docker-remove | ||
docker-remove: | ||
@echo Removing docker $(IMAGE):$(VERSION) ... | ||
docker rmi -f $(IMAGE):$(VERSION) | ||
|
||
#* Cleaning | ||
.PHONY: pycache-remove | ||
pycache-remove: | ||
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf | ||
# Update main project dependencies | ||
.PHONY: update-deps | ||
update-deps: | ||
poetry add torch@latest torchvision@latest pytorch_lightning@latest torchmetrics@latest monai@latest | ||
|
||
.PHONY: dsstore-remove | ||
dsstore-remove: | ||
find . | grep -E ".DS_Store" | xargs rm -rf | ||
|
||
.PHONY: mypycache-remove | ||
mypycache-remove: | ||
find . | grep -E ".mypy_cache" | xargs rm -rf | ||
|
||
.PHONY: ipynbcheckpoints-remove | ||
ipynbcheckpoints-remove: | ||
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf | ||
|
||
.PHONY: pytestcache-remove | ||
pytestcache-remove: | ||
find . | grep -E ".pytest_cache" | xargs rm -rf | ||
|
||
.PHONY: build-remove | ||
build-remove: | ||
### Cleaning | ||
# Remove temporary files and build artifacts | ||
.PHONY: clean | ||
clean: | ||
find . | grep -E "(__pycache__|\.pyc|\.pyo$|.DS_Store|.mypy_cache|.pytest_cache|.ipynb_checkpoints)" | xargs rm -rf | ||
rm -rf build/ | ||
|
||
.PHONY: cleanup | ||
cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove | ||
|
||
.PHONY: get-latest-deps | ||
get-latest-deps: | ||
poetry add torch@latest torchvision@latest pytorch_lightning@latest torchmetrics@latest monai@latest |
This file was deleted.
Oops, something went wrong.