Skip to content

Commit c26c769

Browse files
gadenbuiecpsievert
andauthored
Reorganize shinychat into a monorepo (#56)
* chore: Move R package into `pkg-r` * ci: update CI for new paths * chore: update r package README * add makefile * setup r/python/js vscode settings * add chat + markdown-stream js components * chore: move `js` source into `js/src` and `js/dist` * chore: Add `make r-update-dist` * refactor build.ts; autoformat with prettier * ci: update r-cmd-check workdir * feat: Add Python package * chore: add shinychat to spelling words * py: Fix `Effect_` import * feat: Move `ChatController` * Avoid import from shiny._utils * Add some python stuff to gitignore * Avoid shiny.express._stub_session import * remove deploy utils * feat: `shiny.express.Chat` * Avoid import from shiny._utils * chore: Add quartodoc site * chore: Update dependencies and make targets * feat: Add shinychat splash page to docs * ci: Add quartodoc workflow * chore: Use `make r-docs` to build pkgdown site * ci: add py-check.yaml * ci: Update quarto version * chore: reorganize imports * chore(make): Install playwright browsers * ci: include providers extras * ci: Add verify-js-built.yaml * chore: make js-setup-ci js-build * chore: Update py package version constraints to match shiny * chore: Add redirects for old R pages ```r links <- c( "https://posit-dev.github.io/shinychat/authors.html", "https://posit-dev.github.io/shinychat/LICENSE-text.html", "https://posit-dev.github.io/shinychat/LICENSE.html", "https://posit-dev.github.io/shinychat/news/index.html", "https://posit-dev.github.io/shinychat/reference/chat_append.html", "https://posit-dev.github.io/shinychat/reference/chat_ui.html", "https://posit-dev.github.io/shinychat/reference/index.html" ) links <- sub("https://posit-dev.github.io/shinychat/", "", links) template <- r"---( <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Redirect</title> <script type="text/javascript"> var redirects = {"":"{{redirect}}"}; var hash = window.location.hash.startsWith('#') ? window.location.hash.slice(1) : window.location.hash; var redirect = redirects[hash] || redirects[""] || "/"; window.document.title = 'Redirect to ' + redirect; window.location.replace(redirect); </script> </head> <body> </body> </html> )---" dirs <- fs::path_dir(links) dirs <- unique(dirs[dirs != "."]) dirs <- fs::path("docs", dirs) fs::dir_create(dirs) htmls <- glue::glue( template, redirect = file.path("r", links), .open = "{{", .close = "}}" ) purrr::walk2(links, htmls, function(from, html) { writeLines(html, fs::path("docs", from)) }) ``` * ci: Add py-release workflow * ci: just install all extras for testing --------- Co-authored-by: Carson <[email protected]>
1 parent 98973d3 commit c26c769

File tree

179 files changed

+15886
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+15886
-426
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
on:
44
push:
55
branches: [main, master]
6+
paths:
7+
- 'pkg-r/**'
8+
- '.github/workflows/R-CMD-check.yaml'
69
pull_request:
10+
paths:
11+
- 'pkg-r/**'
12+
- '.github/workflows/R-CMD-check.yaml'
713

814
name: R-CMD-check.yaml
915

@@ -44,8 +50,10 @@ jobs:
4450
with:
4551
extra-packages: any::rcmdcheck
4652
needs: check
53+
working-directory: pkg-r
4754

4855
- uses: r-lib/actions/check-r-package@v2
4956
with:
57+
working-directory: pkg-r
5058
upload-snapshots: true
5159
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/pkgdown.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
on:
44
push:
55
branches: [main, master]
6+
paths:
7+
- 'pkg-r/man'
8+
- 'pkg-r/vignettes'
9+
- 'pkg-r/pkgdown'
10+
- '.github/workflows/R-CMD-check.yaml'
611
pull_request:
12+
paths:
13+
- 'pkg-r/man'
14+
- 'pkg-r/vignettes'
15+
- 'pkg-r/pkgdown'
16+
- '.github/workflows/R-CMD-check.yaml'
717
release:
818
types: [published]
919
workflow_dispatch:
@@ -35,10 +45,10 @@ jobs:
3545
with:
3646
extra-packages: any::pkgdown, local::.
3747
needs: website
48+
working-directory: pkg-r
3849

3950
- name: Build site
40-
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
41-
shell: Rscript {0}
51+
run: make r-docs
4252

4353
- name: Deploy to GitHub pages 🚀
4454
if: github.event_name != 'pull_request'

.github/workflows/py-check.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: py-check.yaml
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'pkg-py/**/*'
8+
- 'pyproject.toml'
9+
- '.github/workflows/py-check.yaml'
10+
pull_request:
11+
paths:
12+
- 'pkg-py/**/*'
13+
- 'pyproject.toml'
14+
- '.github/workflows/py-check.yaml'
15+
16+
permissions:
17+
contents: read
18+
19+
env:
20+
UV_VERSION: "0.7.x"
21+
22+
jobs:
23+
py-test:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version:
29+
- "3.9"
30+
- "3.10"
31+
- "3.11"
32+
- "3.12"
33+
- "3.13"
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: 🚀 Install uv
39+
uses: astral-sh/[email protected]
40+
with:
41+
version: ${{ env.UV_VERSION }}
42+
43+
- name: 🐍 Set up Python ${{ matrix.python-version }}
44+
run: uv python install ${{ matrix.python-version }}
45+
46+
- name: 📦 Install the project
47+
run: uv sync --python ${{ matrix.python-version }} --all-extras
48+
49+
- name: 📜 Show uv.lock
50+
run: cat uv.lock
51+
52+
- name: 🧪 Check tests
53+
run: make py-check-tests
54+
55+
- name: 📝 Check types
56+
run: make py-check-types
57+
58+
- name: 📐 Check formatting
59+
run: make py-check-format

.github/workflows/py-release.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: py-release.yaml
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
UV_VERSION: "0.7.x"
9+
PYTHON_VERSION: 3.13
10+
11+
jobs:
12+
py-release:
13+
name: Build and release Python package
14+
runs-on: ubuntu-latest
15+
16+
# Python release tags start with "py/v*"
17+
if: startsWith(github.ref, 'refs/tags/py/v')
18+
19+
environment:
20+
name: pypi
21+
url: https://pypi.org/project/shinychat/
22+
23+
permissions: # for trusted publishing
24+
id-token: write
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: 🚀 Install uv
30+
uses: astral-sh/setup-uv@v3
31+
with:
32+
version: ${{ env.UV_VERSION }}
33+
34+
- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
35+
run: uv python install ${{ env.PYTHON_VERSION }}
36+
37+
- name: 📦 Install the project
38+
run: uv sync --python ${{ env.PYTHON_VERSION }} --all-extras
39+
40+
- name: 🧪 Check tests
41+
run: make py-check-tests
42+
43+
- name: 📝 Check types
44+
run: make py-check-types
45+
46+
- name: 📐 Check formatting
47+
run: make py-check-format
48+
49+
- name: 🧳 Build package
50+
run: uv build
51+
52+
# TODO: https://pypi.org/manage/project/shinychat/settings/publishing/
53+
- name: 🚢 Publish release on PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/quartodoc.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
paths:
6+
- "docs/**/*"
7+
- .github/workflows/quartodoc.yaml
8+
workflow_dispatch:
9+
10+
name: quartodoc.yaml
11+
12+
env:
13+
UV_VERSION: "0.7.x"
14+
PYTHON_VERSION: 3.13
15+
QUARTO_VERSION: 1.7.31
16+
17+
jobs:
18+
docs-publish:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # full history needed for correct versioning of py pkg
26+
27+
- name: 🔵 Set up Quarto
28+
uses: quarto-dev/quarto-actions/setup@v2
29+
with:
30+
version: ${{ env.QUARTO_VERSION }}
31+
32+
- name: 🚀 Install uv
33+
uses: astral-sh/[email protected]
34+
with:
35+
version: ${{ env.UV_VERSION }}
36+
37+
- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }}
38+
run: uv python install ${{ env.PYTHON_VERSION }}
39+
40+
- name: 📦 Install shinychat and dependencies
41+
run: uv sync --python ${{ env.PYTHON_VERSION }} --no-dev --extra docs
42+
43+
- name: 🔌 Activate venv
44+
run: |
45+
source .venv/bin/activate
46+
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
47+
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
48+
49+
- name: 🏭 Update Python docs
50+
run: make py-docs
51+
52+
- name: 🚢 Deploy to GitHub pages
53+
if: github.event_name != 'pull_request'
54+
uses: JamesIves/[email protected]
55+
with:
56+
clean: false
57+
folder: docs
58+
branch: gh-pages
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Verify built assets
2+
3+
on:
4+
push:
5+
branches: ["main", "rc-*"]
6+
pull_request:
7+
8+
jobs:
9+
verify_js_built:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: 🔎 Extract node version from .nvmrc
18+
id: nvm
19+
working-directory: js
20+
run: |
21+
echo "version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
22+
23+
- name: 🟡 Use Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "${{ steps.nvm.outputs.version }}"
27+
28+
- name: 🆙 Install dependencies
29+
run: make js-setup-ci
30+
env:
31+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
33+
- name: 🏭 Build
34+
run: make js-build
35+
36+
- name: 🧐 Check for uncommitted changes
37+
run: |
38+
if [[ `git status --porcelain` ]]; then
39+
git diff
40+
echo "Uncommitted changes found. Please commit any changes that result from 'make js-setup-ci js-build'."
41+
exit 1
42+
else
43+
echo "No uncommitted changes found."
44+
fi
45+
working-directory: js

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
.RData
44
.Ruserdata
55
.Renviron
6-
docs
7-
_dev
6+
.venv
7+
docs/r
8+
docs/py
9+
_dev
10+
uv.lock
11+
.coverage

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"Posit.air-vscode",
4+
"dbaeumer.vscode-eslint"
5+
]
6+
}

.vscode/settings.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"[r]": {
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "Posit.air-vscode"
5+
},
6+
"[python]": {
7+
"editor.formatOnSave": true,
8+
"editor.codeActionsOnSave": {
9+
"source.fixAll": "explicit",
10+
"source.organizeImports": "explicit"
11+
},
12+
"editor.defaultFormatter": "charliermarsh.ruff"
13+
},
14+
"[typescript]": {
15+
"editor.formatOnSave": true,
16+
"editor.defaultFormatter": "esbenp.prettier-vscode"
17+
},
18+
"[javascript]": {
19+
"editor.formatOnSave": true,
20+
"editor.defaultFormatter": "esbenp.prettier-vscode"
21+
},
22+
"editor.codeActionsOnSave": {
23+
"source.fixAll.eslint": "always"
24+
},
25+
"eslint.validate": [
26+
"javascript",
27+
"typescript",
28+
"jsx",
29+
"tsx"
30+
],
31+
"quarto.path": "~/.local/share/qvm/versions/v1.7.31/bin/quarto",
32+
"cSpell.words": [
33+
"shinychat"
34+
],
35+
"python.testing.pytestArgs": [
36+
"pkg-py"
37+
],
38+
"python.testing.unittestEnabled": false,
39+
"python.testing.pytestEnabled": true
40+
}

LICENSE

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
YEAR: 2024
2-
COPYRIGHT HOLDER: Posit Software, PBC
1+
# MIT License
2+
3+
Copyright (c) 2024 Posit Software, PBC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)