Skip to content

Commit aef3916

Browse files
authored
improve Makefile target support (#297)
1 parent 83040e9 commit aef3916

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CI := $(if $(CI),yes,no)
22
SHELL := /bin/bash
33

44
ifeq ($(CI), yes)
5-
POETRY_OPTS = "-v"
5+
POETRY_OPTS = --ansi -v
66
PRE_COMMIT_OPTS = --show-diff-on-failure --verbose
77
endif
88

@@ -43,15 +43,15 @@ run-pre-commit: ## run pre-commit for all files
4343
--all-files \
4444
--color always
4545

46-
setup: setup-poetry setup-pre-commit setup-npm ## setup local dev environment
46+
setup: setup.poetry setup.pre-commit setup-npm ## setup local dev environment
4747

4848
setup-npm: ## install node dependencies
4949
@npm ci
5050

51-
setup-poetry: ## setup python virtual environment
52-
@poetry install $(POETRY_OPTS) --sync
51+
setup.poetry: ## setup python virtual environment
52+
@poetry sync $(POETRY_OPTS)
5353

54-
setup-pre-commit: ## install pre-commit git hooks
54+
setup.pre-commit: ## install pre-commit git hooks
5555
@poetry run pre-commit install
5656

5757
spellcheck: ## run cspell

action.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,17 @@ runs:
130130
POETRY_INSTALL_ARGS: ${{ inputs.poetry-install-args }}
131131
POETRY_INSTALL_CMD: ${{ inputs.poetry-install-cmd }}
132132
run: |
133-
if [[ -f "Makefile" ]] && grep -q 'setup-poetry:' Makefile; then
134-
echo "installing project using Makefile...";
133+
MAKEFILE_LIST=();
134+
if [[ -f "Makefile" ]]; then
135+
MAKEFILE_LIST="$(make -rpn | sed -n -e '/^$/ { n ; /^[^ .#][^ ]*:/ { s/:.*$// ; p ; } ; }')"
136+
fi
137+
138+
if [[ " ${MAKEFILE_LIST[*]} " =~ setup-poetry ]]; then
135139
make setup-poetry;
140+
elif [[ " ${MAKEFILE_LIST[*]} " =~ setup.poetry ]]; then
141+
make setup.poetry;
136142
else
143+
echo "installing python dependencies using default command...";
137144
${POETRY_INSTALL_CMD} ${POETRY_INSTALL_ARGS};
138145
fi
139146
shell: bash

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ overrides.project.first = ["name", "version"]
1717

1818
[build-system]
1919
build-backend = "poetry.core.masonry.api"
20-
requires = ["poetry-core>=2.1.1"]
20+
requires = ["poetry-core>=2"]

0 commit comments

Comments
 (0)