Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: easy wins for e2e speed #2788

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
docs/*
keep-ui/node_modules
keep-ui/.next/*
keep-ui/.env.local
**/node_modules
keep-ui/
tests/
**/__pycache__
*.pyc
.git
.venv/
.vercel/
.vscode/
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/test-pr-e2e-build-and-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build and up (E2E)

on:
workflow_dispatch:
pull_request:
paths:
- 'keep/**'
- 'keep-ui/**'
- 'tests/**'

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:
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: chartboost/ruff-action@v1
with:
src: "./keep"

- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Set up Depot CLI
uses: depot/setup-action@v1

- name: Bake Docker images
uses: depot/bake-action@v1
with:
token: ${{ secrets.DEPOT_TOKEN }}
project: ${{ secrets.DEPOT_PROJECT }}
workdir: .
files: |
tests/e2e_tests/docker-compose-e2e-mysql.yml
load: true

- name: Set up Keep environment
run: |
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose \
--project-directory . \
-f tests/e2e_tests/docker-compose-e2e-mysql.yml up -d

- name: Wait for services to be ready
run: |
# Add commands to wait for the database to be ready
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

# 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

162 changes: 0 additions & 162 deletions .github/workflows/test-pr-e2e.yml

This file was deleted.

6 changes: 2 additions & 4 deletions docker/Dockerfile.ui
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


FROM node:18-alpine AS base
FROM node:20-alpine AS base

# Install dependencies only when needed
FROM base AS deps
Expand All @@ -26,7 +24,7 @@ ENV NEXT_TELEMETRY_DISABLED 1

# If using npm comment out above and use below instead
ENV API_URL http://localhost:8080
RUN npm run build
RUN NODE_OPTIONS="--max-old-space-size=8192" npm run build


# Production image, copy all the files and run next
Expand Down
8 changes: 8 additions & 0 deletions keep-ui/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.next
.vercel
.env.*
.venv/
.vscode/
.github/
.pytest_cache
1 change: 0 additions & 1 deletion keep-ui/app/(keep)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export const metadata = {
title: "Keep",
description: "The open-source AIOps and alert management platform.",
};

export default ProvidersPage;
1 change: 1 addition & 0 deletions keep/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,4 @@ def run(app: FastAPI):
port=PORT,
log_config=logging_config,
)

10 changes: 10 additions & 0 deletions tests/e2e_tests/docker-compose-e2e-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ services:
build:
context: ./keep-ui/
dockerfile: ../docker/Dockerfile.ui
x-bake:
cache-from:
- type=gha,scope=frontend
cache-to:
- type=gha,mode=max,scope=frontend
environment:
- AUTH_TYPE=NO_AUTH
- API_URL=http://keep-backend:8080
Expand All @@ -33,6 +38,11 @@ services:
build:
context: .
dockerfile: docker/Dockerfile.api
x-bake:
cache-from:
- type=gha,scope=backend
cache-to:
- type=gha,mode=max,scope=backend
environment:
- AUTH_TYPE=NO_AUTH
- DATABASE_CONNECTION_STRING=postgresql://keepuser:keeppassword@keep-database:5432/keepdb
Expand Down
Loading