diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index b5b8cb784..008476ba5 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -119,7 +119,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Run example app tests + - name: Run tests for deploys env: DEPLOY_CONNECT_SERVER_URL: "https://rsc.radixu.com/" DEPLOY_CONNECT_SERVER_API_KEY: "${{ secrets.DEPLOY_CONNECT_SERVER_API_KEY }}" diff --git a/.gitignore b/.gitignore index 5560ec767..be2b67dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -113,3 +113,4 @@ docs/source/reference/ # Developer scratch area _dev/ +tests/playwright/deploys/apps/*/requirements.txt diff --git a/tests/playwright/deploys/apps/plotly_app/requirements.txt b/tests/playwright/deploys/apps/plotly_app/app_requirements.txt similarity index 72% rename from tests/playwright/deploys/apps/plotly_app/requirements.txt rename to tests/playwright/deploys/apps/plotly_app/app_requirements.txt index 5bc72438e..5ad561067 100644 --- a/tests/playwright/deploys/apps/plotly_app/requirements.txt +++ b/tests/playwright/deploys/apps/plotly_app/app_requirements.txt @@ -1,5 +1,4 @@ pandas plotly -git+https://github.com/posit-dev/py-shiny.git#egg=shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools git+https://github.com/posit-dev/py-shinywidgets.git#egg=shinywidgets diff --git a/tests/playwright/deploys/apps/shiny-express-page-default/requirements.txt b/tests/playwright/deploys/apps/shiny-express-accordion/app_requirements.txt similarity index 60% rename from tests/playwright/deploys/apps/shiny-express-page-default/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-accordion/app_requirements.txt index 066ce0faf..87a253e09 100644 --- a/tests/playwright/deploys/apps/shiny-express-page-default/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-accordion/app_requirements.txt @@ -1,2 +1 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/apps/shiny-express-dataframe/requirements.txt b/tests/playwright/deploys/apps/shiny-express-dataframe/app_requirements.txt similarity index 62% rename from tests/playwright/deploys/apps/shiny-express-dataframe/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-dataframe/app_requirements.txt index c87d9ef1b..720b713c0 100644 --- a/tests/playwright/deploys/apps/shiny-express-dataframe/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-dataframe/app_requirements.txt @@ -1,3 +1,2 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools pandas diff --git a/tests/playwright/deploys/apps/shiny-express-folium/requirements.txt b/tests/playwright/deploys/apps/shiny-express-folium/app_requirements.txt similarity index 62% rename from tests/playwright/deploys/apps/shiny-express-folium/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-folium/app_requirements.txt index d7dad04f9..a64e03b44 100644 --- a/tests/playwright/deploys/apps/shiny-express-folium/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-folium/app_requirements.txt @@ -1,3 +1,2 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools folium diff --git a/tests/playwright/deploys/apps/shiny-express-accordion/requirements.txt b/tests/playwright/deploys/apps/shiny-express-page-default/app_requirements.txt similarity index 60% rename from tests/playwright/deploys/apps/shiny-express-accordion/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-page-default/app_requirements.txt index 066ce0faf..87a253e09 100644 --- a/tests/playwright/deploys/apps/shiny-express-accordion/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-page-default/app_requirements.txt @@ -1,2 +1 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/apps/shiny-express-page-fillable/requirements.txt b/tests/playwright/deploys/apps/shiny-express-page-fillable/app_requirements.txt similarity index 60% rename from tests/playwright/deploys/apps/shiny-express-page-fillable/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-page-fillable/app_requirements.txt index 066ce0faf..87a253e09 100644 --- a/tests/playwright/deploys/apps/shiny-express-page-fillable/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-page-fillable/app_requirements.txt @@ -1,2 +1 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/apps/shiny-express-page-fluid/requirements.txt b/tests/playwright/deploys/apps/shiny-express-page-fluid/app_requirements.txt similarity index 60% rename from tests/playwright/deploys/apps/shiny-express-page-fluid/requirements.txt rename to tests/playwright/deploys/apps/shiny-express-page-fluid/app_requirements.txt index 066ce0faf..87a253e09 100644 --- a/tests/playwright/deploys/apps/shiny-express-page-fluid/requirements.txt +++ b/tests/playwright/deploys/apps/shiny-express-page-fluid/app_requirements.txt @@ -1,2 +1 @@ -git+https://github.com/posit-dev/py-shiny git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/apps/shiny-express-page-sidebar/app_requirements.txt b/tests/playwright/deploys/apps/shiny-express-page-sidebar/app_requirements.txt new file mode 100644 index 000000000..87a253e09 --- /dev/null +++ b/tests/playwright/deploys/apps/shiny-express-page-sidebar/app_requirements.txt @@ -0,0 +1 @@ +git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/apps/shiny-express-page-sidebar/requirements.txt b/tests/playwright/deploys/apps/shiny-express-page-sidebar/requirements.txt deleted file mode 100644 index 066ce0faf..000000000 --- a/tests/playwright/deploys/apps/shiny-express-page-sidebar/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -git+https://github.com/posit-dev/py-shiny -git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools diff --git a/tests/playwright/deploys/tests/test_accordion.py b/tests/playwright/deploys/tests/test_accordion.py index cf4c7a689..dcfcde2d5 100644 --- a/tests/playwright/deploys/tests/test_accordion.py +++ b/tests/playwright/deploys/tests/test_accordion.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_accordion APP_DIR = "shiny-express-accordion" @@ -17,6 +17,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_accordion(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_accordion(page) diff --git a/tests/playwright/deploys/tests/test_dataframe.py b/tests/playwright/deploys/tests/test_dataframe.py index eccd8d4b1..93bd32500 100644 --- a/tests/playwright/deploys/tests/test_dataframe.py +++ b/tests/playwright/deploys/tests/test_dataframe.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_dataframe APP_DIR = "shiny-express-dataframe" @@ -17,6 +17,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_dataframe(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_dataframe(page) diff --git a/tests/playwright/deploys/tests/test_folium.py b/tests/playwright/deploys/tests/test_folium.py index 4b25565c2..ba5e7d04c 100644 --- a/tests/playwright/deploys/tests/test_folium.py +++ b/tests/playwright/deploys/tests/test_folium.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_folium_render APP_DIR = "shiny-express-folium" @@ -17,6 +17,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_folium_map(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_folium_render(page) diff --git a/tests/playwright/deploys/tests/test_page_default.py b/tests/playwright/deploys/tests/test_page_default.py index 20beae0c4..925a1a815 100644 --- a/tests/playwright/deploys/tests/test_page_default.py +++ b/tests/playwright/deploys/tests/test_page_default.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_page_default APP_DIR = "shiny-express-page-default" @@ -20,6 +20,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_page_default(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_page_default(page) diff --git a/tests/playwright/deploys/tests/test_page_fillable.py b/tests/playwright/deploys/tests/test_page_fillable.py index a87b9fa85..30854c8a0 100644 --- a/tests/playwright/deploys/tests/test_page_fillable.py +++ b/tests/playwright/deploys/tests/test_page_fillable.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_page_fillable APP_DIR = "shiny-express-page-fillable" @@ -20,6 +20,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_page_fillable(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_page_fillable(page) diff --git a/tests/playwright/deploys/tests/test_page_fluid.py b/tests/playwright/deploys/tests/test_page_fluid.py index 8f0cb1a96..2da0a94c5 100644 --- a/tests/playwright/deploys/tests/test_page_fluid.py +++ b/tests/playwright/deploys/tests/test_page_fluid.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_page_fluid APP_DIR = "shiny-express-page-fluid" @@ -20,6 +20,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_page_fluid(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_page_fluid(page) diff --git a/tests/playwright/deploys/tests/test_page_sidebar.py b/tests/playwright/deploys/tests/test_page_sidebar.py index b8a967bbf..f8a72b6a8 100644 --- a/tests/playwright/deploys/tests/test_page_sidebar.py +++ b/tests/playwright/deploys/tests/test_page_sidebar.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt from utils.express_utils import verify_express_page_sidebar APP_DIR = "shiny-express-page-sidebar" @@ -20,6 +20,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_express_page_sidebar(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) verify_express_page_sidebar(page) diff --git a/tests/playwright/deploys/tests/test_plotly_app.py b/tests/playwright/deploys/tests/test_plotly_app.py index fc242701d..b2c130da9 100644 --- a/tests/playwright/deploys/tests/test_plotly_app.py +++ b/tests/playwright/deploys/tests/test_plotly_app.py @@ -2,7 +2,7 @@ import pytest from playwright.sync_api import Page, expect -from utils.deploy_utils import deploy +from utils.deploy_utils import deploy, write_requirements_txt COUNTRY = "Afghanistan" APP_DIR = "plotly_app" @@ -20,6 +20,7 @@ @pytest.mark.only_browser("chromium") @pytest.mark.parametrize("location", ["connect", "shinyapps"]) def test_deploys(page: Page, location: str) -> None: + write_requirements_txt(app_file_path) page_url = deploy(location, APP_NAME, app_file_path) page.goto(page_url, timeout=PAGE_TIMEOUT) diff --git a/tests/playwright/utils/deploy_utils.py b/tests/playwright/utils/deploy_utils.py index 928cece68..f416757ae 100644 --- a/tests/playwright/utils/deploy_utils.py +++ b/tests/playwright/utils/deploy_utils.py @@ -100,3 +100,16 @@ def deploy(location: str, app_name: str, app_file_path: str) -> str: else: raise ValueError("Unknown deploy location. Cannot deploy.") return url + + +# Since connect parses python packages, we need to get latest version of shiny on HEAD +def write_requirements_txt(app_file_path: str) -> None: + app_requirements_file_path = os.path.join(app_file_path, "app_requirements.txt") + requirements_file_path = os.path.join(app_file_path, "requirements.txt") + git_cmd = subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE) + git_hash = git_cmd.stdout.decode("utf-8").strip() + with open(app_requirements_file_path) as f: + requirements = f.read() + with open(requirements_file_path, "a") as f: + f.write(f"{requirements}\n") + f.write(f"git+https://github.com/posit-dev/py-shiny.git@{git_hash}\n")