1- .PHONY : help clean% check% format% docs% lint test pyright playwright% install% testrail% coverage release
1+ # https://www.gnu.org/software/make/manual/make.html#Phony-Targets
2+ # Prerequisites of .PHONY are always interpreted as literal target names, never as patterns (even if they contain ‘%’ characters).
3+ # # .PHONY: help clean% check% format% docs% lint test pyright playwright% install% testrail% coverage release js-*
4+ # Using `FORCE` as prerequisite to _force_ the target to always run; https://www.gnu.org/software/make/manual/make.html#index-FORCE
5+ FORCE : ;
6+
27.DEFAULT_GOAL := help
38
49define BROWSER_PYSCRIPT
@@ -23,114 +28,157 @@ export PRINT_HELP_PYSCRIPT
2328
2429BROWSER := python -c "$$BROWSER_PYSCRIPT"
2530
26- help :
31+ help : FORCE
2732 @python -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
2833
2934clean : clean-build clean-pyc clean-test # # remove all build, test, coverage and Python artifacts
3035
31- clean-build : # # remove build artifacts
36+ # Remove build artifacts
37+ clean-build : FORCE
3238 rm -fr build/
3339 rm -fr dist/
3440 rm -fr .eggs/
3541 find . -name ' *.egg-info' -exec rm -fr {} +
3642 find . -name ' *.egg' -exec rm -f {} +
3743
38- clean-pyc : # # remove Python file artifacts
44+ # Remove Python file artifacts
45+ clean-pyc : FORCE
3946 find . -name ' *.pyc' -exec rm -f {} +
4047 find . -name ' *.pyo' -exec rm -f {} +
4148 find . -name ' *~' -exec rm -f {} +
4249 find . -name ' __pycache__' -exec rm -fr {} +
4350
44- clean-test : # # remove test and coverage artifacts
51+ # Remove test and coverage artifacts
52+ clean-test : FORCE
4553 rm -fr .tox/
4654 rm -f .coverage
4755 rm -fr htmlcov/
4856 rm -fr .pytest_cache
4957 rm -rf typings/
5058
59+ typings/appdirs :
60+ echo " Creating appdirs stubs"
61+ pyright --createstub appdirs
62+ typings/folium :
63+ echo " Creating folium stubs"
64+ pyright --createstub folium
5165typings/uvicorn :
66+ echo " Creating uvicorn stubs"
5267 pyright --createstub uvicorn
68+ typings/seaborn :
69+ echo " Creating seaborn stubs"
70+ pyright --createstub seaborn
5371
54- typings/matplotlib/__init__.pyi : # # grab type stubs from GitHub
72+ typings/matplotlib/__init__.pyi :
73+ echo " Creating matplotlib stubs"
5574 mkdir -p typings
5675 git clone --depth 1 https://github.com/microsoft/python-type-stubs typings/python-type-stubs
5776 mv typings/python-type-stubs/stubs/matplotlib typings/
5877 rm -rf typings/python-type-stubs
5978
60- typings/seaborn :
61- pyright --createstub seaborn
79+ pyright-typings : typings/appdirs typings/folium typings/uvicorn typings/seaborn typings/matplotlib/__init__.pyi
6280
6381check : check-format check-lint check-types check-tests # # check code, style, types, and test (basic CI)
6482check-fix : format check-lint check-types check-tests # # check and format code, style, types, and test
6583check-format : check-black check-isort
66- check-lint :
67- @echo " -------- Checking style with flake8 --------"
84+ check-lint : check-flake8
85+ check-types : check-pyright
86+ check-tests : check-pytest
87+
88+ check-flake8 : FORCE
89+ @echo " -------- Checking style with flake8 ---------"
6890 flake8 --show-source .
69- check-black :
70- @echo " -------- Checking code with black --------"
91+ check-black : FORCE
92+ @echo " -------- Checking code with black ----------- "
7193 black --check .
72- check-isort :
73- @echo " -------- Sorting imports with isort --------"
94+ check-isort : FORCE
95+ @echo " -------- Sorting imports with isort --------- "
7496 isort --check-only --diff .
75- check-types : typings/uvicorn typings/matplotlib/__init__.pyi typings/seaborn
97+ check-pyright : pyright- typings
7698 @echo " -------- Checking types with pyright --------"
7799 pyright
78- check-tests :
79- @echo " -------- Running tests with pytest --------"
100+ check-pytest : FORCE
101+ @echo " -------- Running tests with pytest ---------- "
80102 python3 tests/pytest/asyncio_prevent.py
81103 pytest
82104
83- pyright : check-types # # check types with pyright
84- lint : check-lint # # check style with flake8
105+ # Check types with pyright
106+ pyright : check-types
107+ # Check style with flake8
108+ lint : check-lint
85109test : check-tests # # check tests quickly with the default Python
86110
87111format : format-black format-isort # # format code with black and isort
88- format-black :
112+ format-black : FORCE
89113 @echo " -------- Formatting code with black --------"
90114 black .
91- format-isort :
115+ format-isort : FORCE
92116 @echo " -------- Sorting imports with isort --------"
93117 isort .
94118
95- docs : # # docs: build docs with quartodoc
96- @echo " -------- Building docs with quartodoc -------- "
119+ docs : FORCE # # docs: build docs with quartodoc
120+ @echo " -------- Building docs with quartodoc ------"
97121 @cd docs && make quartodoc
98122
99- docs-preview : # # docs: preview docs in browser
123+ docs-preview : FORCE # # docs: preview docs in browser
100124 @echo " -------- Previewing docs in browser --------"
101125 @cd docs && make serve
102126
127+
128+ install-npm : FORCE
129+ $(if $(shell which npm) , @echo -n, $(error Please install node.js and npm first. See https://nodejs.org/en/download/ for instructions.) )
130+ js/node_modules : install-npm
131+ @echo " -------- Installing node_modules -----------"
132+ @cd js && npm install
133+ js-build : js/node_modules # # Build JS assets
134+ @echo " -------- Building JS assets ----------------"
135+ @cd js && npm run build
136+ js-watch : js/node_modules
137+ @echo " -------- Continuously building JS assets ---"
138+ @cd js && npm run watch
139+ js-watch-fast : js/node_modules # # Continuously build JS assets (development)
140+ @echo " -------- Previewing docs in browser --------"
141+ @cd js && npm run watch-fast
142+ clean-js : FORCE
143+ @echo " -------- Removing js/node_modules ----------"
144+ rm -rf js/node_modules
145+
103146# Default `SUB_FILE` to empty
104147SUB_FILE: =
105148
106- install-playwright :
149+ install-playwright : FORCE
107150 playwright install --with-deps
108151
109- install-trcli :
110- which trcli || pip install trcli
152+ install-trcli : FORCE
153+ $( if $( shell which trcli) , @echo -n, $( shell pip install trcli) )
111154
112- install-rsconnect : # # install the main version of rsconnect till pypi version supports shiny express
155+ # Installs the main version of rsconnect till pypi version supports shiny express
156+ install-rsconnect : FORCE
113157 pip install git+https://github.com/rstudio/rsconnect-python.git#egg=rsconnect-python
114158
115- playwright-shiny : install-playwright # # end-to-end tests with playwright
159+ # end-to-end tests with playwright; (SUB_FILE="" within tests/playwright/shiny/)
160+ playwright-shiny : install-playwright
116161 pytest tests/playwright/shiny/$(SUB_FILE )
117162
118- playwright-deploys : install-playwright install-rsconnect # # end-to-end tests on examples with playwright
163+ # end-to-end tests on deployed apps with playwright; (SUB_FILE="" within tests/playwright/deploys/)
164+ playwright-deploys : install-playwright install-rsconnect
119165 pytest tests/playwright/deploys/$(SUB_FILE )
120166
121- playwright-examples : install-playwright # # end-to-end tests on examples with playwright
167+ # end-to-end tests on all py-shiny examples with playwright; (SUB_FILE="" within tests/playwright/examples/)
168+ playwright-examples : install-playwright
122169 pytest tests/playwright/examples/$(SUB_FILE )
123170
124- playwright-debug : install-playwright # # All end-to-end tests, chrome only, headed
171+ playwright-debug : install-playwright # # All end-to-end tests, chrome only, headed; (SUB_FILE="" within tests/playwright/)
125172 pytest -c tests/playwright/playwright-pytest.ini tests/playwright/$(SUB_FILE )
126173
127174playwright-show-trace : # # Show trace of failed tests
128175 npx playwright show-trace test-results/* /trace.zip
129176
130- testrail-junit : install-playwright install-trcli # # end-to-end tests with playwright and generate junit report
177+ # end-to-end tests with playwright and generate junit report
178+ testrail-junit : install-playwright install-trcli
131179 pytest tests/playwright/shiny/$(SUB_FILE ) --junitxml=report.xml
132180
133- coverage : # # check combined code coverage (must run e2e last)
181+ coverage : FORCE # # check combined code coverage (must run e2e last)
134182 pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE )
135183 coverage html
136184 $(BROWSER ) htmlcov/index.html
@@ -151,9 +199,9 @@ install: dist
151199 pip uninstall -y shiny
152200 python3 -m pip install dist/shiny* .whl
153201
154- install-deps : # # install dependencies
202+ install-deps : FORCE # # install dependencies
155203 pip install -e " .[dev,test]" --upgrade
156204
157205# ## If caching is ever used, we could run:
158- # install-deps: ## install latest dependencies
206+ # install-deps: FORCE ## install latest dependencies
159207# pip install --editable ".[dev,test]" --upgrade --upgrade-strategy eager
0 commit comments