From bac659a584f208ed6cf9998af8cd57c4757adf0c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 23 Jul 2024 12:19:53 -0400 Subject: [PATCH] Move commands into make files; Remove remaining merge queue commands --- .github/py-shiny/pytest-browsers/action.yaml | 4 +- .github/py-shiny/setup/action.yaml | 29 +----- .github/workflows/build-docs.yaml | 8 +- .github/workflows/deploy-tests.yaml | 2 +- .github/workflows/pytest.yaml | 1 - .github/workflows/verify-js-built.yaml | 1 - Makefile | 34 +++++++- docs/Makefile | 92 ++++++++------------ 8 files changed, 73 insertions(+), 98 deletions(-) diff --git a/.github/py-shiny/pytest-browsers/action.yaml b/.github/py-shiny/pytest-browsers/action.yaml index 69f6b56ce..4d3eaa393 100644 --- a/.github/py-shiny/pytest-browsers/action.yaml +++ b/.github/py-shiny/pytest-browsers/action.yaml @@ -1,5 +1,5 @@ -name: 'Custom merge queue browsers' -description: 'Trim down pytest browsers for any github event other than merge_group.' +name: 'Trim down pytest browsers' +description: 'Trim down pytest browsers so the browser tabs are not shut down between tests, speeding up testing.' inputs: browser: description: 'Browser to use for testing' diff --git a/.github/py-shiny/setup/action.yaml b/.github/py-shiny/setup/action.yaml index 9f73baf99..dfa398f9f 100644 --- a/.github/py-shiny/setup/action.yaml +++ b/.github/py-shiny/setup/action.yaml @@ -12,12 +12,8 @@ runs: uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} - # # Caching with pip only saves ~15 seconds. Not work risks of confusion. - # cache: 'pip' - # cache-dependency-path: | - # setup.cfg - - name: Upgrade pip + - name: Upgrade `pip` shell: bash run: | python -m pip install --upgrade pip @@ -33,34 +29,15 @@ runs: run: | echo "UV_SYSTEM_PYTHON=1" >> $GITHUB_ENV - # - name: Create virtual environment - # shell: bash - # run: | - # uv venv venv - - name: Install dependencies shell: bash run: | - # make install-deps - uv pip install "htmltools @ git+https://github.com/posit-dev/py-htmltools.git" - uv pip install -e ".[dev,test]" + make ci-install-deps - name: Install shell: bash run: | - # make install - - # make clean - - # make dist - uv pip install setuptools - python setup.py sdist - python setup.py bdist_wheel - ls -l dist - - # make install - uv pip uninstall shiny - uv pip install dist/shiny*.whl + make ci-install-wheel - name: Install backports.tarfile if: ${{ startsWith(inputs.python-version, '3.8') }} diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index cb6b6d9d8..6a45560cc 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -5,7 +5,6 @@ on: push: branches: ["main"] pull_request: - merge_group: jobs: build-docs: @@ -33,10 +32,7 @@ jobs: - name: Install dependencies run: | - # install docs dependencies - uv pip install -e ".[dev,test,doc]" - uv pip install "htmltools @ git+https://github.com/posit-dev/py-htmltools.git" \ - "shinylive @ git+https://github.com/posit-dev/py-shinylive.git" + make ci-install-docs - name: Run quartodoc run: | @@ -77,7 +73,7 @@ jobs: # ===================================================== - name: Build site - if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'merge_group' || startsWith(github.head_ref, 'docs') }} + if: ${{ github.ref == 'refs/heads/main' || (!github.event.pull_request.draft) || startsWith(github.head_ref, 'docs') }} run: | cd docs make site diff --git a/.github/workflows/deploy-tests.yaml b/.github/workflows/deploy-tests.yaml index 10932fa11..d0e17f727 100644 --- a/.github/workflows/deploy-tests.yaml +++ b/.github/workflows/deploy-tests.yaml @@ -27,7 +27,7 @@ jobs: - name: Install rsconnect run: | - uv pip install "rsconnect_python @ git+https://github.com/rstudio/rsconnect-python.git" + make ci-install-rsconnect - name: Test that deployable example apps work timeout-minutes: 5 # ~10s locally diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 29039ee3f..6f0205d99 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -6,7 +6,6 @@ on: branches: ["main", "rc-*"] pull_request: types: [opened, synchronize, reopened, ready_for_review] - merge_group: release: types: [published] schedule: diff --git a/.github/workflows/verify-js-built.yaml b/.github/workflows/verify-js-built.yaml index d38cd1a7d..02127f3b0 100644 --- a/.github/workflows/verify-js-built.yaml +++ b/.github/workflows/verify-js-built.yaml @@ -4,7 +4,6 @@ on: push: branches: ["main", "rc-*"] pull_request: - merge_group: jobs: verify_js_built: diff --git a/Makefile b/Makefile index 01e1d1d88..25d391826 100644 --- a/Makefile +++ b/Makefile @@ -26,10 +26,10 @@ for line in sys.stdin: endef export PRINT_HELP_PYSCRIPT -BROWSER := python -c "$$BROWSER_PYSCRIPT" +BROWSER := python3 -c "$$BROWSER_PYSCRIPT" help: FORCE - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts @@ -98,7 +98,7 @@ check-pyright: pyright-typings pyright check-pytest: FORCE @echo "-------- Running tests with pytest ----------" - python3 tests/pytest/asyncio_prevent.py + python tests/pytest/asyncio_prevent.py pytest # Check types with pyright @@ -192,6 +192,13 @@ dist: clean ## builds source and wheel package python3 setup.py sdist python3 setup.py bdist_wheel ls -l dist +ci-dist: FORCE + $(MAKE) clean + pip install setuptools + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + ## install the package to the active Python's site-packages # Note that instead of --force-reinstall, we uninstall and then install, because @@ -200,9 +207,30 @@ dist: clean ## builds source and wheel package install: dist pip uninstall -y shiny python3 -m pip install dist/shiny*.whl +ci-install-wheel: FORCE + $(MAKE) ci-dist + # make install + uv pip uninstall shiny + uv pip install dist/shiny*.whl install-deps: FORCE ## install dependencies pip install -e ".[dev,test]" --upgrade +ci-install-deps: FORCE + uv pip install "htmltools @ git+https://github.com/posit-dev/py-htmltools.git" + uv pip install -e ".[dev,test]" + +install-docs: FORCE + pip install -e ".[dev,test,doc]" + pip install https://github.com/posit-dev/py-htmltools/tarball/main + pip install https://github.com/posit-dev/py-shinylive/tarball/main +ci-install-docs: FORCE + uv pip install -e ".[dev,test,doc]" + uv pip install "htmltools @ git+https://github.com/posit-dev/py-htmltools.git" \ + "shinylive @ git+https://github.com/posit-dev/py-shinylive.git" + +ci-install-rsconnect: FORCE + uv pip install "rsconnect-python @ git+https://github.com/rstudio/rsconnect-python.git" + # ## If caching is ever used, we could run: # install-deps: FORCE ## install latest dependencies diff --git a/docs/Makefile b/docs/Makefile index 84a47d432..a7a9c0547 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,4 +1,7 @@ -.PHONY: help Makefile +# Using `FORCE` as prerequisite to _force_ the target to always run; https://www.gnu.org/software/make/manual/make.html#index-FORCE +FORCE: ; + +.PHONY: Makefile .DEFAULT_GOAL := help define BROWSER_PYSCRIPT @@ -21,86 +24,59 @@ for line in sys.stdin: endef export PRINT_HELP_PYSCRIPT -BROWSER := python -c "$$BROWSER_PYSCRIPT" - -# Use venv from parent -VENV = ../venv -PYBIN = $(VENV)/bin - -# Any targets that depend on $(VENV) or $(PYBIN) will cause the venv to be -# created. To use the venv, python scripts should run with the prefix $(PYBIN), -# as in `$(PYBIN)/pip`. -$(VENV): - python3 -m venv $(VENV) - -$(PYBIN): $(VENV) - - -help: - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) - -dev-htmltools: $(PYBIN) ## Install development version of htmltools - $(PYBIN)/pip install https://github.com/posit-dev/py-htmltools/tarball/main +BROWSER := python3 -c "$$BROWSER_PYSCRIPT" -dev-shinylive: $(PYBIN) ## Install development version of shinylive - $(PYBIN)/pip install https://github.com/posit-dev/py-shinylive/tarball/main +help: FORCE + @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) -deps: $(PYBIN) dev-htmltools dev-shinylive ## Install build dependencies - $(PYBIN)/pip install pip --upgrade - $(PYBIN)/pip install ..[doc] +deps: FORCE ## Install build dependencies + cd .. && $(MAKE) install- -quartodoc: quartodoc_build_core quartodoc_build_express quartodoc_build_test quartodoc_post ## Build quartodocs for express and core +quartodoc: quartodoc_build_core quartodoc_build_express quartodoc_build_test quartodoc_post ## Build quartodocs for express, core, and testing ## Build interlinks for API docs -quartodoc_interlinks: $(PYBIN) - . $(PYBIN)/activate \ - && quartodoc interlinks +quartodoc_interlinks: FORCE + quartodoc interlinks ## Build core API docs -quartodoc_build_core: $(PYBIN) quartodoc_interlinks +quartodoc_build_core: quartodoc_interlinks FORCE $(eval export SHINY_ADD_EXAMPLES=true) $(eval export IN_QUARTODOC=true) $(eval export SHINY_MODE=core) - . $(PYBIN)/activate \ - && echo "::group::quartodoc build core docs" \ - && quartodoc build --config _quartodoc-core.yml --verbose \ - && mv objects.json _objects_core.json \ - && echo "::endgroup::" + @echo "::group::quartodoc build core docs" + quartodoc build --config _quartodoc-core.yml --verbose \ + && mv objects.json _objects_core.json + @echo "::endgroup::" ## Build express API docs -quartodoc_build_express: $(PYBIN) quartodoc_interlinks +quartodoc_build_express: quartodoc_interlinks FORCE $(eval export SHINY_ADD_EXAMPLES=true) $(eval export IN_QUARTODOC=true) $(eval export SHINY_MODE=express) - . $(PYBIN)/activate \ - && echo "::group::quartodoc build express docs" \ - && quartodoc build --config _quartodoc-express.yml --verbose \ - && mv objects.json _objects_express.json \ - && echo "::endgroup::" + @echo "::group::quartodoc build express docs" + quartodoc build --config _quartodoc-express.yml --verbose \ + && mv objects.json _objects_express.json + @echo "::endgroup::" ## Build test API docs -quartodoc_build_test: $(PYBIN) quartodoc_interlinks +quartodoc_build_test: quartodoc_interlinks FORCE $(eval export SHINY_ADD_EXAMPLES=true) $(eval export IN_QUARTODOC=true) $(eval export SHINY_MODE=express) - . $(PYBIN)/activate \ - && echo "::group::quartodoc build testing docs" \ - && quartodoc build --config _quartodoc-testing.yml --verbose \ - && mv objects.json _objects_test.json \ - && echo "::endgroup::" + @echo "::group::quartodoc build testing docs" + quartodoc build --config _quartodoc-testing.yml --verbose \ + && mv objects.json _objects_test.json + @echo "::endgroup::" ## Clean up after quartodoc build -quartodoc_post: $(PYBIN) - . $(PYBIN)/activate \ - && python _combine_objects_json.py +quartodoc_post: FORCE + python _combine_objects_json.py -site: ## Build website - . $(PYBIN)/activate \ - && quarto render +site: FORCE ## Build website (quarto render) + quarto render -serve: ## Build website and serve - . $(PYBIN)/activate \ - && quarto preview --port 8080 +serve: FORCE ## Build website and serve (quarto preview) + && quarto preview --port 8080 -clean: ## Clean build artifacts +clean: FORCE ## Clean build artifacts rm -rf _inv api _site .quarto