-
-
Notifications
You must be signed in to change notification settings - Fork 673
Update makefile #2897
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
Merged
Merged
Update makefile #2897
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,56 +1,68 @@ | ||
| help: | ||
| @echo "Call a specific subcommand:" | ||
| @echo | ||
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | ||
| | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
| @echo | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| default: help | ||
| help: ## Display this help text | ||
| @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
|
||
| # ============================================================================= | ||
| # Docker State | ||
| # ============================================================================= | ||
|
|
||
| .state/docker-build-web: Dockerfile pyproject.toml | ||
| # Build web container for this project | ||
| docker compose build --force-rm web | ||
|
|
||
| # Mark the state so we don't rebuild this needlessly. | ||
| mkdir -p .state && touch .state/docker-build-web | ||
|
|
||
| .state/db-migrated: | ||
| # Call migrate target | ||
| make migrate | ||
|
|
||
| # Mark the state so we don't rebuild this needlessly. | ||
| make migrate | ||
| mkdir -p .state && touch .state/db-migrated | ||
|
|
||
| .state/db-initialized: .state/docker-build-web .state/db-migrated | ||
| # Load all fixtures | ||
| docker compose run --rm web ./manage.py loaddata fixtures/*.json | ||
|
|
||
| # Mark the state so we don't rebuild this needlessly. | ||
| mkdir -p .state && touch .state/db-initialized | ||
|
|
||
| # ============================================================================= | ||
| # Development | ||
| # ============================================================================= | ||
|
|
||
| ##@ Development | ||
|
|
||
| serve: .state/db-initialized ## Start the application | ||
| docker compose up --remove-orphans | ||
|
|
||
| migrations: .state/db-initialized ## Generate migrations from models | ||
| docker compose run --rm web ./manage.py makemigrations | ||
| docker compose run --rm web ./manage.py makemigrations | ||
|
|
||
| migrate: .state/docker-build-web ## Run Django migrate | ||
| docker compose run --rm web ./manage.py migrate | ||
| docker compose run --rm web ./manage.py migrate | ||
|
|
||
| manage: .state/db-initialized ## Run Django manage to accept arbitrary arguments | ||
| manage: .state/db-initialized ## Run arbitrary manage.py commands | ||
| docker compose run --rm web ./manage.py $(filter-out $@,$(MAKECMDGOALS)) | ||
|
|
||
| shell: .state/db-initialized ## Open Django interactive shell | ||
| docker compose run --rm web ./manage.py shell | ||
|
|
||
| docker_shell: .state/db-initialized ## Open bash in web container | ||
| docker compose run --rm web /bin/bash | ||
|
|
||
| clean: ## Clean up the environment | ||
| docker compose down -v | ||
| rm -f .state/docker-build-web .state/db-initialized .state/db-migrated | ||
| rm -f .state/docker-build-web .state/db-initialized .state/db-migrated | ||
|
|
||
| # ============================================================================= | ||
| # Code Quality | ||
| # ============================================================================= | ||
|
|
||
| ##@ Code Quality | ||
|
|
||
| test: .state/db-initialized ## Run tests | ||
| lint: ## Run ruff linter (--fix enabled) | ||
| @if command -v ruff >/dev/null 2>&1; then ruff check --fix .; else docker compose run --rm web ruff check --fix .; fi | ||
|
|
||
| fmt: ## Run ruff formatter | ||
| @if command -v ruff >/dev/null 2>&1; then ruff format .; else docker compose run --rm web ruff format .; fi | ||
|
|
||
| test: .state/db-initialized ## Run test suite | ||
| docker compose run --rm web ./manage.py test | ||
|
|
||
| docker_shell: .state/db-initialized ## Open a bash shell in the web container | ||
| docker compose run --rm web /bin/bash | ||
| ci: lint fmt test ## Run lint, fmt, then tests | ||
|
JacobCoffee marked this conversation as resolved.
|
||
|
|
||
| .PHONY: help serve migrations migrate manage shell clean test docker_shell | ||
| .PHONY: help serve migrations migrate manage shell docker_shell clean | ||
| .PHONY: lint fmt test ci | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.