From 7b62a54d320a6a4a9b7c5ea70795a1490a08733e Mon Sep 17 00:00:00 2001 From: Hans Then Date: Sun, 16 Mar 2025 18:58:31 +0100 Subject: [PATCH 1/4] Run streamlit-folium tests as part of our CI --- .github/workflows/test_streamlit_folium.yml | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/test_streamlit_folium.yml diff --git a/.github/workflows/test_streamlit_folium.yml b/.github/workflows/test_streamlit_folium.yml new file mode 100644 index 000000000..d7b871bbb --- /dev/null +++ b/.github/workflows/test_streamlit_folium.yml @@ -0,0 +1,52 @@ +name: Run Streamlit Folium Tests + +on: + pull_request: + push: + branches: + - main + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - name: Checkout Folium + uses: actions/checkout@v4 + + - name: Setup Micromamba env + uses: mamba-org/setup-micromamba@v2 + with: + environment-name: TEST + create-args: >- + python=3 + --file requirements.txt + + - name: Checkout Streamlit Folium + uses: actions/checkout@v4 + with: + repository: randyzwitch/streamlit-folium + ref: master + path: streamlit_folium # Checkout into a subdirectory + + - name: Install streamlit_folium dev dependencies + run: | + pip install -r streamlit_folium/tests/requirements.txt + + - name: Install folium from source + shell: bash -l {0} + run: | + python -m pip install -e . --no-deps --force-reinstall + + - name: Install playwright dependencies + run: | + playwright install --with-deps + + - name: Install annotate-failures-plugin + run: pip install pytest-github-actions-annotate-failures + + - name: Test with pytest and retry flaky tests up to 3 times + run: | + cd streamlit_folium + pip install streamlit-folium + pytest tests/test_frontend.py --browser chromium -s --reruns 3 --junit-xml=test-results.xml From dd73e6e248397fb418bdb955ddfdfdc408625d44 Mon Sep 17 00:00:00 2001 From: Hans Then Date: Sat, 22 Mar 2025 10:06:34 +0100 Subject: [PATCH 2/4] Bogus commit to break the tests --- .github/workflows/test_streamlit_folium.yml | 31 +++++++++++++++++---- folium/plugins/draw.py | 2 ++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_streamlit_folium.yml b/.github/workflows/test_streamlit_folium.yml index d7b871bbb..ccbfb1048 100644 --- a/.github/workflows/test_streamlit_folium.yml +++ b/.github/workflows/test_streamlit_folium.yml @@ -29,14 +29,23 @@ jobs: ref: master path: streamlit_folium # Checkout into a subdirectory - - name: Install streamlit_folium dev dependencies + - name: Build streamlit_folium javascript + shell: bash -l {0} run: | - pip install -r streamlit_folium/tests/requirements.txt + cd streamlit_folium/streamlit_folium/frontend/ + npm install + npm run build - - name: Install folium from source + - name: Install streamlit-folium shell: bash -l {0} run: | - python -m pip install -e . --no-deps --force-reinstall + cd streamlit_folium + pip install -e . + + - name: Install streamlit_folium dev dependencies + shell: bash -l {0} + run: | + pip install -r streamlit_folium/tests/requirements.txt - name: Install playwright dependencies run: | @@ -45,8 +54,20 @@ jobs: - name: Install annotate-failures-plugin run: pip install pytest-github-actions-annotate-failures + - name: Install folium from source + shell: bash -l {0} + run: | + python -m pip install -e . --no-deps --force-reinstall + - name: Test with pytest and retry flaky tests up to 3 times + shell: bash -l {0} run: | cd streamlit_folium - pip install streamlit-folium pytest tests/test_frontend.py --browser chromium -s --reruns 3 --junit-xml=test-results.xml + + - name: Surface failing tests + if: always() + uses: pmeier/pytest-results-action@main + with: + path: streamlit_folium/test-results.xml + fail-on-empty: false diff --git a/folium/plugins/draw.py b/folium/plugins/draw.py index b00311e08..f44d6b16e 100644 --- a/folium/plugins/draw.py +++ b/folium/plugins/draw.py @@ -121,6 +121,7 @@ class Draw(JSCSSMixin, MacroElement): """ ) + """ default_js = [ ( "leaflet_draw_js", @@ -133,6 +134,7 @@ class Draw(JSCSSMixin, MacroElement): "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css", ) ] + """ def __init__( self, From 3404d3c54e36f6976fe374d0333cd47e8ceecd72 Mon Sep 17 00:00:00 2001 From: Hans Then Date: Sat, 22 Mar 2025 14:24:07 +0100 Subject: [PATCH 3/4] Also install playwright in the shell --- .github/workflows/test_streamlit_folium.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_streamlit_folium.yml b/.github/workflows/test_streamlit_folium.yml index ccbfb1048..59a4f88d6 100644 --- a/.github/workflows/test_streamlit_folium.yml +++ b/.github/workflows/test_streamlit_folium.yml @@ -48,6 +48,7 @@ jobs: pip install -r streamlit_folium/tests/requirements.txt - name: Install playwright dependencies + shell: bash -l {0} run: | playwright install --with-deps From 922f8dee1b570994730518ded754bab38703fee9 Mon Sep 17 00:00:00 2001 From: Hans Then Date: Sat, 22 Mar 2025 14:30:03 +0100 Subject: [PATCH 4/4] Unbreak the tests --- folium/plugins/draw.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/folium/plugins/draw.py b/folium/plugins/draw.py index f44d6b16e..b00311e08 100644 --- a/folium/plugins/draw.py +++ b/folium/plugins/draw.py @@ -121,7 +121,6 @@ class Draw(JSCSSMixin, MacroElement): """ ) - """ default_js = [ ( "leaflet_draw_js", @@ -134,7 +133,6 @@ class Draw(JSCSSMixin, MacroElement): "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css", ) ] - """ def __init__( self,