Skip to content

Commit

Permalink
Merge branch 'main' into build_tools_uv
Browse files Browse the repository at this point in the history
* main:
  test(CI): Add merge queue support for faster PR testing (#1265)
  fix(panel_conditional): Include `.shiny-panel-conditional` class (#1257)
  feat: Create `Session.set_message_handler(name, handler)` (#1253)
  Fix input name
  Enable error console when running locally. (#1060)
  test: Update test to use variable, not capture stdout (#1236)
  test: Fix deploys for shinyapps.io and connect (#1224)
  chore(test): Playwright test refactors and clean up (#1204)
  • Loading branch information
schloerke committed Mar 28, 2024
2 parents 1e7228e + 6b1dcfb commit c3c2120
Show file tree
Hide file tree
Showing 29 changed files with 399 additions and 414 deletions.
30 changes: 30 additions & 0 deletions .github/py-shiny/pytest-browsers/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Custom merge queue browsers'
description: 'Trim down pytest browsers for any github event other than merge_group.'
inputs:
all-browsers:
description: 'Force all pytest browsers to used when testing'
required: false
default: 'false'
outputs:
browsers:
description: 'pytest browsers to use'
value: ${{ steps.browsers.outputs.browsers }}
runs:
using: "composite"
steps:
- name: Determine browsers to use
shell: bash
id: browsers
run: |
if [ "${{ inputs.all-browsers }}" == "true" ]; then
echo "Using all browsers!"
exit 0
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Using chrome browser only!"
echo 'browsers=PYTEST_BROWSERS="--browser chromium"' >> "$GITHUB_OUTPUT"
fi
echo "No custom pytest browsers!"
exit 0
8 changes: 5 additions & 3 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ on:
push:
branches: ["main"]
pull_request:
merge_group:

jobs:
build:
build-docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -28,6 +29,7 @@ jobs:
version: 1.3.340

- name: Build site
if: ${{ github.event_name != 'pull_request' || startsWith(github.head_ref, 'docs') }}
run: |
make docs-site
Expand All @@ -39,7 +41,7 @@ jobs:

deploy:
if: github.ref == 'refs/heads/main'
needs: build
needs: build-docs

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
Expand Down
46 changes: 30 additions & 16 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ on:
push:
branches: ["main", "rc-*"]
pull_request:
merge_group:
release:
types: [published]
schedule:
- cron: "0 8 * * *"

jobs:
build:
check:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -21,7 +22,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
id: install
uses: ./.github/py-shiny/setup
Expand Down Expand Up @@ -58,16 +59,24 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
uses: ./.github/py-shiny/setup
with:
python-version: ${{ matrix.python-version }}

- name: Determine browsers for testing
uses: ./.github/py-shiny/pytest-browsers
id: browsers
with:
all-browsers: ${{ startsWith(github.head_ref, 'playwright') }}
- name: Display browser
shell: bash
run: echo '${{ steps.browsers.outputs.browsers }}'
- name: Run End-to-End tests
timeout-minutes: 20
run: |
make playwright-shiny SUB_FILE=". -vv"
make playwright-shiny SUB_FILE=". -vv" ${{ steps.browsers.outputs.browsers }}
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand All @@ -85,14 +94,14 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
uses: ./.github/py-shiny/setup
with:
python-version: ${{ matrix.python-version }}

- name: Install node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
cache: npm
Expand All @@ -102,10 +111,15 @@ jobs:
run: |
npm ci
- name: Determine browsers for testing
uses: ./.github/py-shiny/pytest-browsers
id: browsers
with:
all-browsers: ${{ startsWith(github.head_ref, 'playwright') }}
- name: Run example app tests
timeout-minutes: 20
run: |
make playwright-examples SUB_FILE=". -vv"
make playwright-examples SUB_FILE=". -vv" ${{ steps.browsers.outputs.browsers }}
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand All @@ -124,7 +138,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
uses: ./.github/py-shiny/setup
with:
Expand All @@ -146,7 +160,7 @@ jobs:

playwright-deploys:
needs: [playwright-deploys-precheck]
if: github.event_name != 'release' && (github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'deploy')))
if: github.event_name != 'release' && (github.event_name == 'push' || startsWith(github.head_ref, 'deploy'))
# Only allow one `playwright-deploys` job to run at a time. (Independent of branch / PR)
# Only one is allowed to run at a time because it is deploying to the same server location.
concurrency: playwright-deploys
Expand All @@ -159,7 +173,7 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
uses: ./.github/py-shiny/setup
with:
Expand All @@ -172,7 +186,7 @@ jobs:
run: |
make playwright-deploys SUB_FILE=". -vv"
- name: Deploy apps and run tests (on `push` or on `pull_request` w/ `deploy**` branch)
- name: Deploy apps and run tests (on `push` or `deploy**` branches)
env:
DEPLOY_APPS: "true"
DEPLOY_CONNECT_SERVER_URL: "https://rsc.radixu.com/"
Expand All @@ -197,9 +211,9 @@ jobs:
name: "Deploy to PyPI"
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [build]
needs: [check]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Set up Python 3.10"
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -231,7 +245,7 @@ jobs:

testrail-reporting-nightly:
runs-on: ${{ matrix.os }}
if: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'testrail')) }}
if: ${{ github.event_name == 'schedule' || startsWith(github.head_ref, 'testrail') }}
strategy:
matrix:
python-version:
Expand All @@ -244,14 +258,14 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup py-shiny
uses: ./.github/py-shiny/setup
with:
python-version: ${{ matrix.python-version }}

- name: Install node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
cache: npm
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/verify-js-built.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Build
name: Verify built assets

on:
push:
branches: ["main", "rc-*"]
pull_request:
merge_group:

jobs:
verify_js_built:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### New features

* `Session` objects now have a `set_message_handler(name, fn)` method that allows you to register a message handler function that will be called when a request message with the given name is received from the client (via `Shiny.shinyapp.makeRequest()` (JS)). (#1253)

* Experimental: `@render.data_frame` return values of `DataTable` and `DataGrid` support `mode="edit"` to enable editing of the data table cells. (#1198)

* `ui.card()` and `ui.value_box()` now take an `id` argument that, when provided, is used to report the full screen state of the card or value box to the server. For example, when using `ui.card(id = "my_card", full_screen = TRUE)` you can determine if the card is currently in full screen mode by reading the boolean value of `input.my_card()["full_screen"]`. (#1215)
Expand All @@ -23,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `ui.value_box()`, `ui.layout_columns()` and `ui.layout_column_wrap()` now all have `min_height` and `max_height` arguments. These are useful in filling layouts, like `ui.page_fillable()`, `ui.page_sidebar(fillable=True)` or `ui.page_navbar(fillable=True)`. For example, you can use `ui.layout_columns(min_height=300, max_height=500)` to ensure that a set of items (likely arranged in a row of columns) are always between 300 and 500 pixels tall. (#1223)

* Added an error console which displays errors in the browser's UI. This is enabled by default when running applications locally, and can be disabled with `shiny run --no-dev-mode`. It is not enabled for applications that are deployed to a server. (#1060)

### Bug fixes

* On Windows, Shiny Express app files are now read in as UTF-8. (#1203)
Expand All @@ -35,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `ui.layout_columns()` now correctly applies the `row_heights` at the `xs` breakpoint, if supplied. (#1222)

* `ui.panel_conditional()` now adds the `.shiny-panel-conditional` class to the `<div>` element wrapping the conditional panel contents. (#1257)

### Other changes

* The fill CSS used by fillable containers (i.e. when `fillable=True`) now uses a [CSS cascade layer](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_layers) named `htmltools` to reduce the precedence order of the fill CSS. (#1228)
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ clean-js: FORCE

# Default `SUB_FILE` to empty
SUB_FILE:=
PYTEST_BROWSERS:= --browser webkit --browser firefox --browser chromium

install-playwright: $(PLAYWRIGHT) FORCE
@echo "-------- Installing playwright browsers --------"
Expand All @@ -305,15 +306,15 @@ install-playwright: $(PLAYWRIGHT) FORCE

playwright-shiny: install-playwright $(PYTEST) FORCE ## end-to-end tests with playwright; (SUB_FILE="" within tests/playwright/shiny/)
. $(PYBIN)/activate && \
pytest tests/playwright/shiny/$(SUB_FILE)
pytest tests/playwright/shiny/$(SUB_FILE) $(PYTEST_BROWSERS)

playwright-deploys: install-playwright $(RSCONNECT) $(PYTEST) FORCE ## end-to-end tests on deployed apps with playwright; (SUB_FILE="" within tests/playwright/deploys/)
. $(PYBIN)/activate && \
pytest tests/playwright/deploys/$(SUB_FILE)
pytest tests/playwright/deploys/$(SUB_FILE) $(PYTEST_BROWSERS)

playwright-examples: install-playwright $(PYTEST) FORCE ## end-to-end tests on all py-shiny examples with playwright; (SUB_FILE="" within tests/playwright/examples/)
. $(PYBIN)/activate && \
pytest tests/playwright/examples/$(SUB_FILE)
pytest tests/playwright/examples/$(SUB_FILE) $(PYTEST_BROWSERS)

playwright-debug: install-playwright $(PYTEST) FORCE ## All end-to-end tests, chrome only, headed; (SUB_FILE="" within tests/playwright/)
. $(PYBIN)/activate && \
Expand All @@ -325,11 +326,11 @@ playwright-show-trace: FORCE ## Show trace of failed tests
# end-to-end tests with playwright and generate junit report
testrail-junit: install-playwright $(TRCLI) $(PYTEST) FORCE
. $(PYBIN)/activate && \
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml $(PYTEST_BROWSERS)

coverage: $(PYTEST) $(COVERAGE) FORCE ## check combined code coverage (must run e2e last)
. $(PYBIN)/activate && \
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE) && \
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE) $(PYTEST_BROWSERS) && \
coverage html && \
$(BROWSER) htmlcov/index.html

Expand Down
7 changes: 6 additions & 1 deletion js/dataframe/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getCellEditMapValue,
} from "./cell-edit-map";
import { updateCellsData } from "./data-update";
import type { PatchInfo } from "./types";

// States
// # √ Ready
Expand Down Expand Up @@ -50,6 +51,7 @@ export type CellState = keyof typeof CellStateEnum;
interface TableBodyCellProps {
id: string | null;
cell: Cell<unknown[], unknown>;
patchInfo: PatchInfo;
columns: readonly string[];
editCellsIsAllowed: boolean;
editRowIndex: number | null;
Expand All @@ -66,6 +68,7 @@ interface TableBodyCellProps {
export const TableBodyCell: FC<TableBodyCellProps> = ({
id,
cell,
patchInfo,
columns,
editCellsIsAllowed,
editRowIndex,
Expand Down Expand Up @@ -137,7 +140,7 @@ export const TableBodyCell: FC<TableBodyCellProps> = ({
// * When a td is focused, Have esc key move focus to the table
// * When table is focused, Have esc key blur the focus
// TODO-barret-future; Combat edit mode being independent of selection mode
// * In row / column selection mode, allow for arrowoutput_binding_request_handler key navigation by focusing on a single cell, not a TR
// * In row / column selection mode, allow for arrow key navigation by focusing on a single cell, not a TR
// * If a cell is focused,
// * `enter key` allows you to go into edit mode; If editing is turned off, the selection is toggled
// * `space key` allows you toggle the selection of the cell
Expand Down Expand Up @@ -253,6 +256,7 @@ export const TableBodyCell: FC<TableBodyCellProps> = ({
// updateCellsData updates the underlying data via `setData` and `setCellEditMap`
updateCellsData({
id,
patchInfo: patchInfo,
patches: [
{
rowIndex,
Expand All @@ -273,6 +277,7 @@ export const TableBodyCell: FC<TableBodyCellProps> = ({
});
}, [
id,
patchInfo,
rowIndex,
columnIndex,
value,
Expand Down
9 changes: 4 additions & 5 deletions js/dataframe/data-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ResponseValue, makeRequestPromise } from "./request";
import type { CellState } from "./cell";
import { CellStateEnum } from "./cell";
import { CellEdit, SetCellEditMap, makeCellEditMapKey } from "./cell-edit-map";
import type { PatchInfo } from "./types";

export type CellPatch = {
rowIndex: number;
Expand All @@ -19,6 +20,7 @@ export type CellPatchPy = {

export function updateCellsData({
id,
patchInfo,
patches,
onSuccess,
onError,
Expand All @@ -27,6 +29,7 @@ export function updateCellsData({
setCellEditMap,
}: {
id: string | null;
patchInfo: PatchInfo;
patches: CellPatch[];
onSuccess: (values: CellPatch[]) => void;
onError: (err: string) => void;
Expand All @@ -47,12 +50,8 @@ export function updateCellsData({
});

makeRequestPromise({
method: "output_binding_request_handler",
method: patchInfo.key,
args: [
// id: string
id,
// handler: string
"patches",
// list[CellPatch]
patchesPy,
],
Expand Down
Loading

0 comments on commit c3c2120

Please sign in to comment.