Skip to content

Commit

Permalink
refactor: decrease makefile verbosity (#212)
Browse files Browse the repository at this point in the history
Auto-created
  • Loading branch information
MartinBernstorff authored Nov 19, 2023
1 parent 5680ad9 commit 464453b
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SRC_PATH = personal_mnemonic_medium
MAKEFLAGS = --no-print-directory

# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/205 Decrease makefile verbosity
# E.g. entering/leaving directory
Expand All @@ -8,53 +9,63 @@ deploy:
./docker_cmd.sh

install-test:
pip install --upgrade .[dev,tests]
@pip install --upgrade .[dev,tests]

install-dev:
pip install --upgrade .[dev]
@pip install --upgrade .[dev]

install:
make install-dev
pip install -e .
@make install-dev
@pip install -e .

test: ## Run tests
pytest personal_mnemonic_medium
@echo "––– Testing –––"
@pytest personal_mnemonic_medium

test-cov: ## Run tests with coverage
# TODO: https://github.com/MartinBernstorff/personal-mnemonic-medium/issues/209 Fix coverage and add it to make pr
pytest --cov=personal_mnemonic_medium --cov-report=term-missing personal_mnemonic_medium
@pytest --cov=personal_mnemonic_medium --cov-report=term-missing personal_mnemonic_medium

lint: ## Format code
ruff format .
ruff . --fix \
@echo "––– Linting –––"
@ruff format .
@ruff . --fix \
--extend-select F401 \
--extend-select F841

types: ## Type-check code
pyright $(SRC_PATH)
@echo "––– Type-checking –––"
@pyright $(SRC_PATH)

validate: ## Run all checks
make lint
make types
make test
@echo "––– Running all checks –––"
@make lint
@make types
@make test

merge-main:
git fetch
git merge --no-edit origin/main
@echo "––– Merging main –––"
@git fetch
@git merge --no-edit origin/main

mm:
@make merge-main

push:
git push --set-upstream origin HEAD
git push
@echo "––– Pushing to origin/main –––"
@git push --set-upstream origin HEAD
@git push

create-pr:
gh pr create --title "$$(git log -1 --pretty=%B)" --body "Auto-created" || true
@echo "––– Creating PR –––"
@gh pr create --title "$$(git log -1 --pretty=%B)" --body "Auto-created" || true

enable-automerge:
gh pr merge --auto --squash --delete-branch
@gh pr merge --auto --squash --delete-branch

squash-from-parent:
git fetch
git reset $$(git merge-base origin/main $$(git rev-parse --abbrev-ref HEAD)) ; git add -A ; git commit -m "Squash changes from parent branch"
@git fetch
@git reset $$(git merge-base origin/main $$(git rev-parse --abbrev-ref HEAD)) ; git add -A ; git commit -m "Squash changes from parent branch"

create-random-branch:
@git checkout -b "$$(date +'%d_%H_%M')_$(shell cat /dev/urandom | env LC_ALL=C tr -dc 'a-z' | fold -w 5 | head -n 1)"
Expand All @@ -64,16 +75,16 @@ pr-status:
@gh pr view | cat | grep "url"

pr: ## Run relevant tests before PR
@make merge-main
@make push
@make create-pr
@make merge-main
@make validate
@make enable-automerge
@echo "––– 🎉🎉🎉 All tests succeeded! 🎉🎉🎉 –––"
@echo "––– 🎉🎉🎉 All validation succeeded! 🎉🎉🎉 –––"
@make pr-status

grow:
make pr
@make pr
@echo "––– Growing into a new branch 🌳 –––"
make create-random-branch
make squash-from-parent
@make create-random-branch
@make squash-from-parent

0 comments on commit 464453b

Please sign in to comment.