Skip to content

Reorganize shinychat into a monorepo #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6c2e263
chore: Move R package into `pkg-r`
gadenbuie May 21, 2025
3816f5b
ci: update CI for new paths
gadenbuie May 21, 2025
cc36b9f
chore: update r package README
gadenbuie May 21, 2025
49bc4bc
add makefile
gadenbuie May 22, 2025
1ef928a
setup r/python/js vscode settings
gadenbuie May 22, 2025
c2ce16e
add chat + markdown-stream js components
gadenbuie May 22, 2025
7af739e
chore: move `js` source into `js/src` and `js/dist`
gadenbuie May 22, 2025
d835495
chore: Add `make r-update-dist`
gadenbuie May 22, 2025
35fed38
refactor build.ts; autoformat with prettier
gadenbuie May 22, 2025
084033e
ci: update r-cmd-check workdir
gadenbuie May 22, 2025
27a8f2a
feat: Add Python package
gadenbuie May 23, 2025
7750aeb
chore: add shinychat to spelling words
gadenbuie May 23, 2025
92edaec
py: Fix `Effect_` import
gadenbuie May 23, 2025
1b1233f
feat: Move `ChatController`
gadenbuie May 27, 2025
c1dbf3c
Avoid import from shiny._utils
cpsievert May 28, 2025
a962dfd
Add some python stuff to gitignore
cpsievert May 28, 2025
d0634f1
Avoid shiny.express._stub_session import
cpsievert May 28, 2025
bc6f1a8
remove deploy utils
gadenbuie May 28, 2025
05daf9e
feat: `shiny.express.Chat`
gadenbuie May 28, 2025
150a70c
Avoid import from shiny._utils
cpsievert May 28, 2025
c999229
chore: Add quartodoc site
gadenbuie May 29, 2025
711514d
chore: Update dependencies and make targets
gadenbuie May 29, 2025
99fd212
feat: Add shinychat splash page to docs
gadenbuie May 29, 2025
84fac05
ci: Add quartodoc workflow
gadenbuie May 29, 2025
86236c0
chore: Use `make r-docs` to build pkgdown site
gadenbuie May 29, 2025
051a5ce
ci: add py-check.yaml
gadenbuie May 29, 2025
7f0dc35
ci: Update quarto version
gadenbuie May 29, 2025
24381e9
chore: reorganize imports
gadenbuie May 29, 2025
b460dd2
chore(make): Install playwright browsers
gadenbuie May 29, 2025
11ffd2c
ci: include providers extras
gadenbuie May 29, 2025
080f5ca
ci: Add verify-js-built.yaml
gadenbuie May 30, 2025
3626e7b
chore: make js-setup-ci js-build
gadenbuie May 30, 2025
f151339
chore: Update py package version constraints to match shiny
gadenbuie May 30, 2025
30a7ebc
chore: Add redirects for old R pages
gadenbuie May 30, 2025
e064d63
ci: Add py-release workflow
gadenbuie May 30, 2025
fb78b61
ci: just install all extras for testing
gadenbuie May 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
on:
push:
branches: [main, master]
paths:
- 'pkg-r/**'
- '.github/workflows/R-CMD-check.yaml'
pull_request:
paths:
- 'pkg-r/**'
- '.github/workflows/R-CMD-check.yaml'

name: R-CMD-check.yaml

Expand Down Expand Up @@ -44,8 +50,10 @@ jobs:
with:
extra-packages: any::rcmdcheck
needs: check
working-directory: pkg-r

- uses: r-lib/actions/check-r-package@v2
with:
working-directory: pkg-r
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
14 changes: 12 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
on:
push:
branches: [main, master]
paths:
- 'pkg-r/man'
- 'pkg-r/vignettes'
- 'pkg-r/pkgdown'
- '.github/workflows/R-CMD-check.yaml'
pull_request:
paths:
- 'pkg-r/man'
- 'pkg-r/vignettes'
- 'pkg-r/pkgdown'
- '.github/workflows/R-CMD-check.yaml'
release:
types: [published]
workflow_dispatch:
Expand Down Expand Up @@ -35,10 +45,10 @@ jobs:
with:
extra-packages: any::pkgdown, local::.
needs: website
working-directory: pkg-r

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}
run: make r-docs

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/py-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: py-check.yaml

on:
push:
branches: [main]
paths:
- 'pkg-py/**/*'
- 'pyproject.toml'
- '.github/workflows/py-check.yaml'
pull_request:
paths:
- 'pkg-py/**/*'
- 'pyproject.toml'
- '.github/workflows/py-check.yaml'

permissions:
contents: read

env:
UV_VERSION: "0.7.x"

jobs:
py-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v4

- name: 🚀 Install uv
uses: astral-sh/[email protected]
with:
version: ${{ env.UV_VERSION }}

- name: 🐍 Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: 📦 Install the project
run: uv sync --python ${{ matrix.python-version }} --all-extras

- name: 📜 Show uv.lock
run: cat uv.lock

- name: 🧪 Check tests
run: make py-check-tests

- name: 📝 Check types
run: make py-check-types

- name: 📐 Check formatting
run: make py-check-format
54 changes: 54 additions & 0 deletions .github/workflows/py-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: py-release.yaml

on:
release:
types: [published]

env:
UV_VERSION: "0.7.x"
PYTHON_VERSION: 3.13

jobs:
py-release:
name: Build and release Python package
runs-on: ubuntu-latest

# Python release tags start with "py/v*"
if: startsWith(github.ref, 'refs/tags/py/v')

environment:
name: pypi
url: https://pypi.org/project/shinychat/

permissions: # for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v4

- name: 🚀 Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}

- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
run: uv python install ${{ env.PYTHON_VERSION }}

- name: 📦 Install the project
run: uv sync --python ${{ env.PYTHON_VERSION }} --all-extras

- name: 🧪 Check tests
run: make py-check-tests

- name: 📝 Check types
run: make py-check-types

- name: 📐 Check formatting
run: make py-check-format

- name: 🧳 Build package
run: uv build

# TODO: https://pypi.org/manage/project/shinychat/settings/publishing/
- name: 🚢 Publish release on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
58 changes: 58 additions & 0 deletions .github/workflows/quartodoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
push:
branches:
- main
paths:
- "docs/**/*"
- .github/workflows/quartodoc.yaml
workflow_dispatch:

name: quartodoc.yaml

env:
UV_VERSION: "0.7.x"
PYTHON_VERSION: 3.13
QUARTO_VERSION: 1.7.31

jobs:
docs-publish:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history needed for correct versioning of py pkg

- name: 🔵 Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: ${{ env.QUARTO_VERSION }}

- name: 🚀 Install uv
uses: astral-sh/[email protected]
with:
version: ${{ env.UV_VERSION }}

- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
run: uv python install ${{ env.PYTHON_VERSION }}

- name: 📦 Install shinychat and dependencies
run: uv sync --python ${{ env.PYTHON_VERSION }} --no-dev --extra docs

- name: 🔌 Activate venv
run: |
source .venv/bin/activate
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV

- name: 🏭 Update Python docs
run: make py-docs

- name: 🚢 Deploy to GitHub pages
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
folder: docs
branch: gh-pages
45 changes: 45 additions & 0 deletions .github/workflows/verify-js-built.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Verify built assets

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

jobs:
verify_js_built:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🔎 Extract node version from .nvmrc
id: nvm
working-directory: js
run: |
echo "version=$(cat .nvmrc)" >> $GITHUB_OUTPUT

- name: 🟡 Use Node.js
uses: actions/setup-node@v4
with:
node-version: "${{ steps.nvm.outputs.version }}"

- name: 🆙 Install dependencies
run: make js-setup-ci
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: 🏭 Build
run: make js-build

- name: 🧐 Check for uncommitted changes
run: |
if [[ `git status --porcelain` ]]; then
git diff
echo "Uncommitted changes found. Please commit any changes that result from 'make js-setup-ci js-build'."
exit 1
else
echo "No uncommitted changes found."
fi
working-directory: js
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
.RData
.Ruserdata
.Renviron
docs
_dev
.venv
docs/r
docs/py
_dev
uv.lock
.coverage
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"Posit.air-vscode",
"dbaeumer.vscode-eslint"
]
}
40 changes: 40 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
},
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"eslint.validate": [
"javascript",
"typescript",
"jsx",
"tsx"
],
"quarto.path": "~/.local/share/qvm/versions/v1.7.31/bin/quarto",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels off

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is tricky because qvm is the best thing around but also isn't being developed or maintained.

The idea here is that the Quarto version used in the project is controlled with the QUARTO_VERSION string in the Makefile. To update the Quarto version, you change that string and call make install-quarto, which uses qvm to install the desired version of Quarto and updates the GitHub Actions files AND the VS Code settings so that everyone uses the same version of Quarto.

Unfortunately, qvm doesn't give you a way to control where the quarto binary is installed, or we'd use a local folder. I also don't really want to go write code to download and install quarto since that's basically covered by qvm, so we're kind of stuck here.

It also means that in CI, we install quarto but can't use make docs and have to rely on quarto render ..., which is annoying but not the worst thing ever.

"cSpell.words": [
"shinychat"
],
"python.testing.pytestArgs": [
"pkg-py"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
23 changes: 21 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
YEAR: 2024
COPYRIGHT HOLDER: Posit Software, PBC
# MIT License

Copyright (c) 2024 Posit Software, PBC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading