feat: add /incidents/{id}/split
endpoint
#3150
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests (E2E) | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "keep/**" | |
- "keep-ui/**" | |
- "tests/**" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
env: | |
PYTHON_VERSION: 3.11 | |
STORAGE_MANAGER_DIRECTORY: /tmp/storage-manager | |
# MySQL server environment variables | |
MYSQL_ROOT_PASSWORD: keep | |
MYSQL_DATABASE: keep | |
# Postgres environment variables | |
POSTGRES_USER: keepuser | |
POSTGRES_PASSWORD: keeppassword | |
POSTGRES_DB: keepdb | |
# To test if imports are working properly | |
EE_ENABLED: true | |
jobs: | |
tests-e2e: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
db_type: [mysql, postgres] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: chartboost/ruff-action@v1 | |
with: | |
src: "./keep" | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Cache dependencies | |
id: cache-deps | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: pydeps-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies using poetry | |
run: poetry install --no-interaction --no-root --with dev | |
- name: Get Playwright version from poetry.lock | |
id: playwright-version | |
run: | | |
PLAYWRIGHT_VERSION=$(grep "playwright" poetry.lock -A 5 | grep "version" | head -n 1 | cut -d'"' -f2) | |
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT | |
- name: Cache Playwright browsers | |
id: playwright-cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-${{ steps.playwright-version.outputs.version }} | |
- name: Install Playwright and dependencies | |
run: | | |
if [ "${{ steps.playwright-cache.outputs.cache-hit }}" != "true" ]; then | |
poetry run playwright install --with-deps | |
else | |
poetry run playwright install-deps | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up Keep environment | |
run: | | |
DOCKER_BUILDKIT=1 docker compose \ | |
--project-directory . \ | |
-f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml up -d | |
- name: Wait for database to be ready | |
run: | | |
# Add commands to wait for the database to be ready | |
if [ "${{ matrix.db_type }}" == "mysql" ]; then | |
until docker exec $(docker ps -qf "name=keep-database") mysqladmin ping -h "localhost" --silent; do | |
echo "Waiting for MySQL to be ready..." | |
sleep 2 | |
done | |
elif [ "${{ matrix.db_type }}" == "postgres" ]; then | |
until docker exec $(docker ps -qf "name=keep-database") pg_isready -h localhost -U keepuser; do | |
echo "Waiting for Postgres to be ready..." | |
sleep 2 | |
done | |
fi | |
# wait to keep backend on port 8080 | |
echo "Waiting for Keep backend to be ready..." | |
attempt=0 | |
max_attempts=10 | |
until $(curl --output /dev/null --silent --fail http://localhost:8080/healthcheck); do | |
if [ "$attempt" -ge "$max_attempts" ]; then | |
echo "Max attempts reached, exiting... Sometimes Keep can't start because of double-headed migrations, use: 'alembic -c keep/alembic.ini history' to investigate, or check artifacts." | |
exit 1 | |
fi | |
echo "Waiting for Keep backend to be ready... (Attempt: $((attempt+1)))" | |
attempt=$((attempt+1)) | |
sleep 2 | |
done | |
echo "Keep backend is ready!" | |
# wait to the backend | |
echo "Waiting for Keep frontend to be ready..." | |
attempt=0 | |
max_attempts=10 | |
until $(curl --output /dev/null --silent --fail http://localhost:3000/); do | |
if [ "$attempt" -ge "$max_attempts" ]; then | |
echo "Max attempts reached, exiting..." | |
exit 1 | |
fi | |
echo "Waiting for Keep frontend to be ready... (Attempt: $((attempt+1)))" | |
attempt=$((attempt+1)) | |
sleep 2 | |
done | |
# create the state directory | |
# mkdir -p ./state && chown -R root:root ./state && chmod -R 777 ./state | |
- name: Run e2e tests and report coverage | |
run: | | |
poetry run coverage run --branch -m pytest -s tests/e2e_tests/ | |
- name: Convert coverage results to JSON (for CodeCov support) | |
run: poetry run coverage json --omit="keep/providers/*" | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
fail_ci_if_error: false # don't fail if we didn't manage to upload the coverage report | |
files: coverage.json | |
verbose: true | |
- name: Dump backend logs | |
if: always() | |
run: | | |
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-backend > backend_logs-${{ matrix.db_type }}.txt | |
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-frontend > frontend_logs-${{ matrix.db_type }}.txt | |
continue-on-error: true | |
- name: Upload test artifacts on failure | |
if: always() | |
uses: actions/[email protected] | |
with: | |
name: test-artifacts-my-artifacts-${{ matrix.db_type }} | |
path: | | |
playwright_dump_*.html | |
playwright_dump_*.png | |
backend_logs-${{ matrix.db_type }}.txt | |
frontend_logs-${{ matrix.db_type }}.txt | |
continue-on-error: true | |
- name: Tear down environment | |
run: | | |
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml down |