Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dokterbob authored Sep 19, 2024
2 parents b75852a + 2bdd541 commit 0b77d63
Show file tree
Hide file tree
Showing 72 changed files with 4,871 additions and 1,229 deletions.
10 changes: 5 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To contribute to Chainlit, you first need to setup the project on your local mac

<!--
Generated using https://ecotrust-canada.github.io/markdown-toc/.
I've copy/pasted the whole document there, without the previous two headings.
I've copy/pasted the whole document there, and then formatted it with prettier.
-->

- [Contribute to Chainlit](#contribute-to-chainlit)
Expand Down Expand Up @@ -37,11 +37,11 @@ I've copy/pasted the whole document there, without the previous two headings.

With this setup you can easily code in your fork and fetch updates from the main repository.

1. Go to https://github.com/Chainlit/chainlit/fork to fork the chainlit code into your own repository.
1. Go to [https://github.com/Chainlit/chainlit/fork](https://github.com/Chainlit/chainlit/fork) to fork the chainlit code into your own repository.
2. Clone your fork locally

```sh
$ git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git
git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git
```

3. Go into your fork and list the current configured remote repository.
Expand All @@ -55,7 +55,7 @@ $ git remote -v
4. Specify the new remote upstream repository that will be synced with the fork.

```sh
$ git remote add upstream https://github.com/Chainlit/chainlit.git
git remote add upstream https://github.com/Chainlit/chainlit.git
```

5. Verify the new upstream repository you've specified for your fork.
Expand Down Expand Up @@ -103,7 +103,7 @@ If you've made it this far, you can now replace `chainlit/hello.py` by your own

## Start the UI from source

First, you will have to start the server either [from source](#start-the-chainlit-server-from-source) or with `chainlit run... `. Since we are starting the UI from source, you can start the server with the `-h` (headless) option.
First, you will have to start the server either [from source](#start-the-chainlit-server-from-source) or with `chainlit run...`. Since we are starting the UI from source, you can start the server with the `-h` (headless) option.

Then, start the UI.

Expand Down
27 changes: 27 additions & 0 deletions .github/actions/pnpm-node-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Install Node, pnpm and dependencies.
description: Install Node, pnpm and dependencies using cache.

inputs:
node-version:
description: Node.js version
required: true
pnpm-version:
description: pnpm version
required: true
pnpm-install-args:
description: Extra arguments for pnpm install, e.g. --no-frozen-lockfile.

runs:
using: composite
steps:
- uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: pnpm
- name: Install JS dependencies
run: pnpm install ${{ inputs.pnpm-install-args }}
shell: bash
42 changes: 42 additions & 0 deletions .github/actions/poetry-python-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Install Python, poetry and dependencies.
description: Install Python, Poetry and poetry dependencies using cache

inputs:
python-version:
description: Python version
required: true
poetry-version:
description: Poetry version
required: true
poetry-working-directory:
description: Working directory for poetry command.
required: false
default: .
poetry-install-args:
description: Extra arguments for poetry install, e.g. --with tests.
required: false

runs:
using: composite
steps:
- name: Cache poetry install
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ inputs.poetry-version }}-0
- name: Install Poetry
run: pipx install 'poetry==${{ inputs.poetry-version }}'
shell: bash
- name: Set up Python ${{ inputs.python-version }}
id: setup_python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry
cache-dependency-path: ${{ inputs.poetry-working-directory }}/poetry.lock
- name: Set Poetry environment
run: poetry -C '${{ inputs.poetry-working-directory }}' env use '${{ steps.setup_python.outputs.python-path }}'
shell: bash
- name: Install Python dependencies
run: poetry -C '${{ inputs.poetry-working-directory }}' install ${{ inputs.poetry-install-args }}
shell: bash
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: CI

on:
workflow_call:
workflow_dispatch:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]

permissions: read-all

jobs:
pytest:
uses: ./.github/workflows/pytest.yaml
Expand All @@ -22,5 +25,5 @@ jobs:
name: Run CI
needs: [mypy, pytest, e2e-tests]
steps:
- name: 'Done'
- name: Done
run: echo "Done"
32 changes: 15 additions & 17 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@ name: E2ETests

on: [workflow_call]

permissions: read-all

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.6.9
- name: Use Node.js 16.15.0
uses: actions/setup-node@v3
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
node-version: '16.15.0'
cache: 'pnpm'
- name: Set up Python
uses: actions/setup-python@v4
python-version: 3.9
poetry-version: 1.8.3
poetry-working-directory: ${{ env.BACKEND_DIR }}
poetry-install-args: --with tests
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
with:
python-version: '3.9'
cache: 'pip'
- name: Install Poetry
run: pip install poetry
- name: Install JS dependencies
run: pnpm install --no-frozen-lockfile
node-version: 22.7.0
pnpm-version: 9.7.0
pnpm-install-args: --no-frozen-lockfile
- name: Build UI
run: pnpm run buildUi
- name: Lint UI
run: pnpm run lintUi
- name: Install Python dependencies
run: poetry install -C ./backend --with tests
- name: Run tests
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ name: Mypy

on: [workflow_call]

permissions: read-all

jobs:
mypy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
python-version: '3.9'
cache: 'pip'
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install --with tests --with mypy --with custom-data
python-version: 3.9
poetry-version: 1.8.3
poetry-install-args: --with tests --with mypy --with custom-data
poetry-working-directory: ${{ env.BACKEND_DIR }}
- name: Run Mypy
run: poetry run mypy chainlit/
working-directory: ${{ env.BACKEND_DIR }}
33 changes: 16 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,41 @@ on:
release:
types: [published]

permissions: read-all

jobs:
tests:
uses: ./.github/workflows/tests.yaml
ci:
uses: ./.github/workflows/ci.yaml
secrets: inherit
build-n-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [tests]
needs: [ci]
env:
name: pypi
url: https://pypi.org/p/chainlit
BACKEND_DIR: ./backend
permissions:
contents: read
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: pnpm/action-setup@v2
with:
version: 8.6.9
- name: Use Node.js 16.15.0
uses: actions/setup-node@v3
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
with:
node-version: '16.15.0'
cache: 'pnpm'
- name: Set up Python
uses: actions/setup-python@v4
node-version: 22.7.0
pnpm-version: 9.7.0
pnpm-install-args: --no-frozen-lockfile
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
python-version: '3.9'
- name: Install Poetry
uses: snok/install-poetry@v1
python-version: 3.9
poetry-version: 1.8.3
poetry-working-directory: ${{ env.BACKEND_DIR }}
- name: Copy readme to backend
run: cp README.md backend/
- name: Install JS dependencies
run: pnpm install --no-frozen-lockfile
- name: Build chainlit
run: pnpm run build
- name: Publish package distributions to PyPI
Expand Down
39 changes: 27 additions & 12 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@ name: Pytest

on: [workflow_call]

permissions: read-all

jobs:
mypy:
pytest:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
fastapi-version: ['0.110', '0.111', '0.112']
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
python-version: ${{ matrix.python-version }}
poetry-version: 1.8.3
poetry-install-args: --with tests --with mypy --with custom-data
poetry-working-directory: ${{ env.BACKEND_DIR }}
- name: Install fastapi ${{ matrix.fastapi-version }}
run: poetry add fastapi@^${{ matrix.fastapi-version}}
working-directory: ${{ env.BACKEND_DIR }}
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
with:
python-version: '3.9'
cache: 'pip'
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install --with tests --with mypy --with custom-data
node-version: 22.7.0
pnpm-version: 9.7.0
pnpm-install-args: --no-frozen-lockfile
- name: Build UI
run: pnpm run buildUi
- name: Run Pytest
run: poetry run pytest --cov=chainlit/
working-directory: ${{ env.BACKEND_DIR }}
Loading

0 comments on commit 0b77d63

Please sign in to comment.