Skip to content

Commit

Permalink
Merge pull request #72 from vintasoftware/feat/ga-tests
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
pamella authored Jun 12, 2024
2 parents c66054d + 7d29097 commit 9ec3d96
Show file tree
Hide file tree
Showing 11 changed files with 607 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
branch = True
source = django_ai_assistant

[report]
omit =
*/tests/*
*/migrations/*
*static*
*/templates/*
32 changes: 32 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Django CI (django-ai-assistant)

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run tests
run: |
poetry run coverage run -m pytest
# When the repo becomes public:
# 1. Add the COVERALLS_REPO_TOKEN to GitHub secrets
# 2. Uncomment the lines below
# poetry run coveralls
env:
OPENAI_API_KEY: "sk-fake-test-key-123"
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Node CI (django-ai-assistant-client)

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies
working-directory: ./frontend
run: |
npm install
- name: Run ci
working-directory: ./frontend
run: |
npm ci
- name: Run build
working-directory: ./frontend
run: |
npm run build
- name: Run tests
working-directory: ./frontend
run: |
npm test
# When the repo becomes public:
# 1. Add the COVERALLS_REPO_TOKEN to GitHub secrets
# 2. Uncomment the lines below
# npm run coveralls
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: pre-commit

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Django dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Node dependencies
run: |
npm install
working-directory: ./frontend

- name: Run pre-commit
uses: pre-commit/action@v3.0.1
27 changes: 23 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -15,33 +16,51 @@ repos:
- id: check-symlinks
- id: debug-statements
- id: detect-private-key

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.6
rev: v0.1.8
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format

- repo: local
hooks:
- id: frontend-lint
name: run frontend lint
entry: sh -c 'cd frontend && npm run lint'
language: system
types: [file]
files: ^frontend/.*\.(js|jsx|ts|tsx)$
pass_filenames: true
- id: frontend-tsc
name: run frontend tsc
entry: sh -c 'cd frontend && npm run tsc'
language: system
types: [file]
files: ^frontend/.*\.(ts|tsx)$
pass_filenames: false
- id: missing-migrations
name: missing-migrations-local
name: check missing migrations
entry: poetry run python manage.py makemigrations --check
language: system
# Only run missing migration check if migration-generating files have changed:
files: (.*/?(settings|migrations|models)/.+|.+models\.py|.+constants\.py|.+choices\.py|.+pyproject\.toml)
pass_filenames: false
- id: generate-openapi-schema
name: Generate OpenAPI schema
name: generate OpenAPI schema
entry: poetry run python manage.py generate_openapi_schema --output frontend/openapi_schema.json
language: system
# Only run OpenAPI schema generation if views.py has changed:
files: views\.py$
pass_filenames: false
- id: generate-frontend-client
name: Generate frontend client
name: generate frontend client
entry: sh -c 'cd frontend && npm run generate-client'
language: system
# Only run frontend client generation if frontend files have changed:
files: openapi_schema\.json$
pass_filenames: false
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Django CI](https://github.com/vintasoftware/django-ai-assistant/actions/workflows/django.yml/badge.svg)](https://github.com/vintasoftware/django-ai-assistant/actions/workflows/django.yml)
[![Node CI](https://github.com/vintasoftware/django-ai-assistant/actions/workflows/node.yml/badge.svg)](https://github.com/vintasoftware/django-ai-assistant/actions/workflows/node.yml)

# django-ai-assistant

Django app to integrate with [OpenAI Assistants API](https://platform.openai.com/docs/assistants/overview). Supports [Function calling](https://platform.openai.com/docs/assistants/tools/function-calling).
Expand Down
4 changes: 2 additions & 2 deletions django_ai_assistant/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class AssistantSchema(Schema):
id: str
id: str # noqa: A003
name: str


Expand Down Expand Up @@ -42,5 +42,5 @@ class ThreadMessageTypeEnum(str, Enum):


class ThreadMessagesSchemaOut(Schema):
type: ThreadMessageTypeEnum
type: ThreadMessageTypeEnum # noqa: A003
content: str
Loading

0 comments on commit 9ec3d96

Please sign in to comment.