Skip to content

Commit

Permalink
Merge pull request #735 from airtai/dev
Browse files Browse the repository at this point in the history
Move studio files into studio project (#733)
  • Loading branch information
harishmohanraj authored Sep 27, 2024
2 parents 5458fbd + 0d0043f commit 1a4401c
Show file tree
Hide file tree
Showing 86 changed files with 11,268 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-broken-links-in-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
- name: Check links using container
uses: ruzickap/action-my-broken-link-checker@v2
with:
url: https://fastagency.airt.ai
url: https://studio.fastagency.ai
cmd_params: '--buffer-size=8192 --max-connections=1 --color=always --header="User-Agent:Mozilla/5.0(Firefox/97.0)" --exclude="(localhost:8000|linkedin.com|fonts.gstatic.com|reddit.com)" --max-connections-per-host=1 --rate-limit=1'
debug: true
167 changes: 161 additions & 6 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Pipeline
name: Tests

on:
push:
branches-ignore:
# branches-ignore:
# - main
- dev
# - dev
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
static-analysis:
strategy:
Expand All @@ -28,7 +32,7 @@ jobs:
run: |
set -ux
python -m pip install --upgrade pip
pip install -e ".[submodules,docs,lint,test-core]"
pip install -e ".[submodules,docs,lint,testing]"
- name: Run mypy
shell: bash
run: mypy fastagency_studio tests
Expand All @@ -41,6 +45,145 @@ jobs:
shell: bash
run: semgrep scan --config auto --error

test-without-llms:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
uses: ./.github/workflows/test.yaml
with:
python-version: ${{ matrix.python-version }}
environment: null
use-llms: ""
secrets: inherit # pragma: allowlist secret

test-with-anthropic:
uses: ./.github/workflows/test.yaml
with:
python-version: "3.9"
environment: testing
use-llms: "anthropic"
secrets: inherit # pragma: allowlist secret

test-with-azure_oai:
uses: ./.github/workflows/test.yaml
with:
python-version: "3.9"
environment: testing
use-llms: "azure_oai"
secrets: inherit # pragma: allowlist secret

test-with-openai:
uses: ./.github/workflows/test.yaml
with:
python-version: "3.9"
environment: testing
use-llms: "openai"
secrets: inherit # pragma: allowlist secret

test-with-togetherai:
uses: ./.github/workflows/test.yaml
with:
python-version: "3.9"
environment: testing
use-llms: "togetherai"
secrets: inherit # pragma: allowlist secret

test-with-llm:
uses: ./.github/workflows/test.yaml
with:
python-version: "3.9"
environment: testing
use-llms: "llm"
secrets: inherit # pragma: allowlist secret

test-macos-latest:
if: github.event.pull_request.draft == false
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[submodules,docs,testing]
- name: Prisma
run: prisma generate
- name: Test
run: bash scripts/test.sh -m "not (db or nats or anthropic or azure_oai or openai or togetherai or llm)"

test-windows-latest:
if: github.event.pull_request.draft == false
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[submodules,docs,testing]
- name: Prisma
run: prisma generate
- name: Test
run: bash scripts/test.sh -m "not (db or nats or anthropic or azure_oai or openai or togetherai or llm)"

coverage-combine:
needs:
- test-without-llms
- test-with-llm
- test-with-anthropic
- test-with-azure_oai
- test-with-openai
- test-with-togetherai
- test-windows-latest
- test-macos-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Get coverage files
uses: actions/download-artifact@v4
with:
pattern: .coverage*
path: coverage
merge-multiple: true

- run: pip install coverage[toml]

- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "FastAgency coverage for ${{ github.sha }}"

- name: Store coverage html
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: airtai/fastagency

unit-test-wasp:
if: github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/main' && github.event.pull_request.draft == false
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -79,6 +222,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Set $PY environment variable
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v4
Expand All @@ -93,17 +238,27 @@ jobs:

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
if: github.event.pull_request.draft == false
# from: https://github.com/re-actors/alls-green
# Important: For this to work properly, it is a must to have the job always
# run, otherwise GitHub will make it skipped when any of the dependencies
# fail. In some contexts, skipped is interpreted as success which may lead
# to undersired, unobvious and even dangerous (as in security breach
# "dangerous") side-effects.
if: always()

needs:
- static-analysis
- pre-commit-check
- unit-test-wasp
- coverage-combine
- test-macos-latest
- test-windows-latest

runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1 # nosemgrep
with:
# allowed-failures: docs, linters
# allowed-skips: non-voting-flaky-job
jobs: ${{ toJSON(needs) }}
142 changes: 142 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Internal test runner

on:
workflow_call:
inputs:
environment:
description: 'Environment to run the tests in'
required: false
default: null
type: string
python-version:
description: 'Python version to run the tests in'
required: true
type: string
use-llms:
description: 'Use LLM in the tests'
required: true
type: string

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
environment: ${{ inputs.environment }}
services:
nats:
image: diementros/nats:js
ports:
- 4222:4222
postgres-wasp:
image: postgres:13
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_DB: fastagency
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
postgres-py:
image: postgres:13
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_DB: pyfastagency
ports:
- 5433:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
DATABASE_URL: postgresql://admin:password@localhost:5432/fastagency
PY_DATABASE_URL: postgresql://admin:password@localhost:5433/pyfastagency
NATS_URL: nats://localhost:4222

steps:
- name: Set up environment variables
run: |
# check if an environment var or secret is defined and set env var to its value
# vars
if [ -n "${{ vars.AZURE_API_VERSION }}" ]; then
echo "AZURE_API_VERSION=${{ vars.AZURE_API_VERSION }}" >> $GITHUB_ENV
fi
if [ -n "${{ vars.AZURE_API_ENDPOINT }}" ]; then
echo "AZURE_API_ENDPOINT=${{ vars.AZURE_API_ENDPOINT }}" >> $GITHUB_ENV
fi
if [ -n "${{ vars.AZURE_GPT35_MODEL }}" ]; then
echo "AZURE_GPT35_MODEL=${{ vars.AZURE_GPT35_MODEL }}" >> $GITHUB_ENV
fi
if [ -n "${{ vars.AZURE_GPT4_MODEL }}" ]; then
echo "AZURE_GPT4_MODEL=${{ vars.AZURE_GPT4_MODEL }}" >> $GITHUB_ENV
fi
if [ -n "${{ vars.AZURE_GPT4o_MODEL }}" ]; then
echo "AZURE_GPT4o_MODEL=${{ vars.AZURE_GPT4o_MODEL }}" >> $GITHUB_ENV
fi
# secrets
if [ -n "${{ secrets.AZURE_OPENAI_API_KEY }}" ]; then
echo "AZURE_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.TOGETHER_API_KEY }}" ]; then
echo "TOGETHER_API_KEY=${{ secrets.TOGETHER_API_KEY }}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
echo "ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}" >> $GITHUB_ENV
fi
if [ -n "${{ secrets.BING_API_KEY }}" ]; then
echo "BING_API_KEY=${{ secrets.BING_API_KEY }}" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install wasp
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.14.0
- name: Run wasp migration
run: cd app && wasp db migrate-dev && cd ..
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[docs,testing]
- name: Install Pydantic v2
run: pip install --pre "pydantic>=2,<3"
- run: mkdir coverage
- name: Prisma
run: prisma migrate deploy && prisma generate
- name: Test without LLMs
if: ${{ inputs.use-llms == '' }}
run: bash scripts/test.sh -vv -m "not (anthropic or azure_oai or openai or togetherai or llm)"
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ inputs.python-version }}-${{ inputs.use-llms }}
CONTEXT: ${{ runner.os }}-py${{ inputs.python-version }}-${{ inputs.use-llms }}
- name: Test with LLMs
if: ${{ inputs.use-llms != '' }}
run: bash scripts/test.sh -vv -m "${{ inputs.use-llms }}"
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ inputs.python-version }}-${{ inputs.use-llms }}
CONTEXT: ${{ runner.os }}-py${{ inputs.python-version }}-${{ inputs.use-llms }}
- name: Check coverage file
run: ls -al coverage
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: .coverage.${{ runner.os }}-py${{ inputs.python-version }}-${{ inputs.use-llms }}
path: coverage/.coverage.*
if-no-files-found: error
overwrite: true
include-hidden-files: true
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@
}
]
},
"generated_at": "2024-07-16T06:40:25Z"
"generated_at": "2024-09-25T10:05:08Z"
}
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
RUN python3 -m pip install --upgrade pip

COPY migrations ./migrations
COPY templates ./templates
COPY fastagency_studio ./fastagency_studio
COPY scripts/* schema.prisma pyproject.toml README.md ./
RUN pip install -e ".[submodules,server]" --ignore-installed blinker
Expand Down
Loading

0 comments on commit 1a4401c

Please sign in to comment.