Skip to content

Commit

Permalink
Merge branch 'main' into willy/copilot-audio-presence
Browse files Browse the repository at this point in the history
  • Loading branch information
dokterbob authored Nov 6, 2024
2 parents 9e22f60 + 2ba2c59 commit f548f6f
Show file tree
Hide file tree
Showing 74 changed files with 5,388 additions and 5,678 deletions.
35 changes: 19 additions & 16 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,9 @@ $ git remote -v
> upstream https://github.com/Chainlit/chainlit.git (push)
```

### Install JS dependencies
### Install dependencies

```sh
pnpm install
```

### Install python dependencies
The following command will install Python dependencies, Node (pnpm) dependencies and build the frontend.

```sh
cd backend
Expand All @@ -83,12 +79,6 @@ poetry install --with tests --with mypy --with dev

## Start the Chainlit server from source

You need to build the UI once before starting the server.

```sh
pnpm run buildUi
```

Start by running `backend/hello.py` as an example.

```sh
Expand Down Expand Up @@ -116,16 +106,29 @@ If you visit `http://127.0.0.1:5174/`, it should connect to your local server. I

## Run the tests

Run `pnpm test`
### Backend unit tests

Once you create a pull request, the tests will automatically run. It is a good practice to run the tests locally before pushing.
This will run the backend's unit tests.

You will need to rebuild the UI if you updated it between test runs.
```sh
cd backend
pytest
```

### E2E tests

This will run end to end tests, assessing both the frontend, the backend and their interaction:

```sh
pnpm run buildUi
pnpm test
```

(Go grab a cup of something, this will take a while.)

Once you create a pull request, the tests will automatically run. It is a good practice to run the tests locally before pushing.

Make sure to run `poetry install` again whenever you've updated the frontend!

### Run one test

1. Find the folder containing the e2e test that you're looking for in `cypress/e2e`.
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/pnpm-node-install/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ inputs:
node-version:
description: Node.js version
required: true
default: '22.7.0'
pnpm-version:
description: pnpm version
required: true
default: '9.7.0'
pnpm-skip-install:
description: Skip install.
required: false
default: 'false'
pnpm-install-args:
description: Extra arguments for pnpm install, e.g. --no-frozen-lockfile.
default: '--frozen-lockfile'

runs:
using: composite
Expand All @@ -25,3 +32,5 @@ runs:
- name: Install JS dependencies
run: pnpm install ${{ inputs.pnpm-install-args }}
shell: bash
# Skip install if pnpm-skip-install is true
if: ${{ inputs.pnpm-skip-install != 'true' }}
2 changes: 2 additions & 0 deletions .github/actions/poetry-python-install/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ inputs:
python-version:
description: Python version
required: true
default: '3.9'
poetry-version:
description: Poetry version
required: true
default: '1.8.3'
poetry-working-directory:
description: Working directory for poetry command.
required: false
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_call:
workflow_dispatch:
pull_request:
branches: [main, dev]
branches: [main, dev, 'release/**']
push:
branches: [main, dev]
branches: [main, dev, 'release/**']

permissions: read-all

Expand All @@ -20,10 +20,13 @@ jobs:
e2e-tests:
uses: ./.github/workflows/e2e-tests.yaml
secrets: inherit
lint-ui:
uses: ./.github/workflows/lint-ui.yaml
secrets: inherit
ci:
runs-on: ubuntu-latest
name: Run CI
needs: [mypy, pytest, e2e-tests]
needs: [mypy, pytest, lint-ui, e2e-tests]
steps:
- name: Done
run: echo "Done"
22 changes: 9 additions & 13 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@ jobs:
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
with:
pnpm-skip-install: true
- name: Install depdendencies and Cypress
uses: cypress-io/github-action@v6
with:
runTests: false
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
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:
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: Run tests
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/lint-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: LintUI

on: [workflow_call]

permissions: read-all

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
- name: Build UI
run: pnpm run buildUi
- name: Lint UI
run: pnpm run lintUi
6 changes: 2 additions & 4 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ jobs:
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/poetry-python-install
name: Install Python, poetry and Python dependencies
with:
python-version: 3.9
poetry-version: 1.8.3
poetry-install-args: --with tests --with mypy --with custom-data
poetry-install-args: --with tests --with mypy --with custom-data --no-root
poetry-working-directory: ${{ env.BACKEND_DIR }}
- name: Run Mypy
run: poetry run mypy chainlit/
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,20 @@ jobs:
contents: read
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: main
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
with:
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
poetry-version: 1.8.3
poetry-working-directory: ${{ env.BACKEND_DIR }}
- name: Copy readme to backend
run: cp README.md backend/
- name: Build chainlit
run: pnpm run build
- name: Build Python distribution
run: poetry self add poetry-plugin-ignore-build-script && poetry build --ignore-build-script
working-directory: ${{ env.BACKEND_DIR }}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,18 @@ jobs:
env:
BACKEND_DIR: ./backend
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/pnpm-node-install
name: Install Node, pnpm and dependencies.
- 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:
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ dist-ssr

.aider*
.coverage

backend/README.md
Loading

0 comments on commit f548f6f

Please sign in to comment.