cognee/.github/workflows/test_common.yml
2024-08-08 17:53:30 +02:00

155 lines
4.3 KiB
YAML

name: test | environments
on:
pull_request:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
RUNTIME__LOG_LEVEL: ERROR
jobs:
get_docs_changes:
name: docs changes
uses: ./.github/workflows/get_docs_changes.yml
setup_docker:
name: Set up Docker Buildx
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
run_common:
name: test
needs: get_docs_changes
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true'
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11.x"]
include:
- python-version: "3.9.x"
os: "ubuntu-22.04"
- python-version: "3.10.x"
os: "ubuntu-22.04"
defaults:
run:
shell: bash
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: cognee
POSTGRES_PASSWORD: cognee
POSTGRES_DB: cognee_db
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U $POSTGRES_USER"
--health-interval=10s
--health-timeout=5s
--health-retries=5
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install tzdata on windows
run: |
cd %USERPROFILE%
curl https://data.iana.org/time-zones/releases/tzdata2021e.tar.gz --output tzdata.tar.gz
mkdir tzdata
tar --extract --file tzdata.tar.gz --directory tzdata
mkdir %USERPROFILE%\Downloads\tzdata
copy tzdata %USERPROFILE%\Downloads\tzdata
curl https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml --output %USERPROFILE%\Downloads\tzdata\windowsZones.xml
if: runner.os == 'Windows'
shell: cmd
- name: Install Poetry
uses: snok/install-poetry@v1.3.2
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install dependencies
run: poetry install --no-interaction
- name: Create .cognee_system directory and print path
run: |
mkdir .cognee_system
echo $(pwd)/.cognee_system
- name: Wait for PostgreSQL to be ready
run: |
echo "Waiting for PostgreSQL to be ready..."
until docker exec ${RUNNER_USER_NAME}-postgres pg_isready -U cognee; do
sleep 1
done
- name: Run tests
run: poetry run pytest tests/
- name: Run default basic pipeline
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ENV: 'dev'
POSTGRES_USER: cognee
POSTGRES_PASSWORD: cognee
POSTGRES_DB: cognee_db
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
DESTINATION__POSTGRES__CREDENTIALS__HOST: 127.0.0.1
DESTINATION__POSTGRES__CREDENTIALS__USERNAME: cognee
DESTINATION__POSTGRES__CREDENTIALS__PASSWORD: cognee
DESTINATION__POSTGRES__CREDENTIALS__DATABASE: cognee_db
run: poetry run python ./cognee/tests/test_library.py
- name: Clean up disk space
run: |
sudo rm -rf ~/.cache
sudo rm -rf /tmp/*
df -h
- name: Build with Poetry
run: poetry build
- name: Install Package
run: |
cd dist
pip install *.whl
matrix_job_required_check:
name: common | common tests
needs: run_common
runs-on: ubuntu-latest
if: always()
steps:
- name: Check matrix job results
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One or more matrix job tests failed or were cancelled. You may need to re-run them." && exit 1