Skip to content

feat: auto-downgrading revision #4678

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

Open
wants to merge 123 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
408e7fc
first version
korolenkowork May 1, 2025
dce47b0
fix
korolenkowork May 1, 2025
6127d86
Main logic completed
korolenkowork May 1, 2025
8cb9b81
minor
korolenkowork May 1, 2025
9cc98a8
Update configuration.mdx
korolenkowork May 1, 2025
2758d9f
lint fix
korolenkowork May 1, 2025
e1ee04b
Add test
korolenkowork May 2, 2025
51787ba
fix path
korolenkowork May 2, 2025
db174f9
fix
korolenkowork May 2, 2025
9b2f67f
migrations-e2e-prepare-for-coding
korolenkowork May 2, 2025
3fb2996
migrations-e2e
korolenkowork May 2, 2025
08db877
Done!
korolenkowork May 2, 2025
4f635f3
fix pull old version e2e
korolenkowork May 2, 2025
f140de4
fix
korolenkowork May 3, 2025
995fd83
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
1d1e462
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
5dd3bfa
fix
korolenkowork May 3, 2025
cb46278
Update test-pr-e2e.yml
korolenkowork May 3, 2025
bf1b653
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
f469bab
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork May 3, 2025
3e3975c
Check revision between runs
korolenkowork May 3, 2025
4671d62
Merge branch 'feature/auto-downgrade-revision' of https://github.com/…
korolenkowork May 3, 2025
c55103a
fix execute container name
korolenkowork May 3, 2025
83b748d
test
korolenkowork May 3, 2025
f3ee8e3
test
korolenkowork May 3, 2025
9036754
test
korolenkowork May 3, 2025
e185781
test
korolenkowork May 3, 2025
33fbe21
test
korolenkowork May 3, 2025
3fcdfcb
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
b2beede
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
e4dd78a
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
8fd2137
revert
korolenkowork May 3, 2025
9545c5a
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
87d28d3
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
a2a1260
fix e2e env
korolenkowork May 3, 2025
cf0d105
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
1d34408
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
ff4b2e9
I hate pipelines
korolenkowork May 3, 2025
303e63c
Done!
korolenkowork May 3, 2025
394fd03
Add dummy migrations to the second step
korolenkowork May 3, 2025
a3a2735
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
fd45db1
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
4c96bcc
Fix docker cp path
korolenkowork May 3, 2025
b3a1190
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
197c98a
Update run-migrations-e2e-tests.yml
korolenkowork May 3, 2025
a38facc
Merge branch 'main' into feature/auto-downgrade-revision
shahargl May 4, 2025
8702a2b
Update run-migrations-e2e-tests.yml
korolenkowork May 4, 2025
0e208ef
Merge branch 'feature/auto-downgrade-revision' of https://github.com/…
korolenkowork May 4, 2025
32f2cbe
fix workflow
korolenkowork May 4, 2025
9d7ea1f
Remove test alembic config
korolenkowork May 4, 2025
b05a727
fix
korolenkowork May 4, 2025
099d9ea
fix
korolenkowork May 4, 2025
755f143
fix
korolenkowork May 4, 2025
8af5a68
fix
korolenkowork May 6, 2025
f83c3f0
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork May 6, 2025
c29ef1b
fix?
korolenkowork May 6, 2025
753f899
fix?
korolenkowork May 6, 2025
1cdc291
change SECRET_MANAGER_DIRECTORY
korolenkowork May 6, 2025
9d9791e
Delete docker-compose-e2e-postgres.yml~
korolenkowork May 6, 2025
beb812e
Revert "change SECRET_MANAGER_DIRECTORY"
korolenkowork May 6, 2025
5136a03
fix
korolenkowork May 6, 2025
2b3693a
Revert "fix"
korolenkowork May 6, 2025
775322f
fix
korolenkowork May 6, 2025
ef08091
fix
korolenkowork May 9, 2025
f1072e8
fix?
korolenkowork May 9, 2025
fa83f0f
revert
korolenkowork May 9, 2025
c24254c
fix
korolenkowork May 9, 2025
f40ed3c
test
korolenkowork May 9, 2025
6b9d5a0
test
korolenkowork May 9, 2025
0be6341
try
korolenkowork May 9, 2025
5224b8c
test
korolenkowork May 10, 2025
0870a1b
fix
korolenkowork May 10, 2025
a8d1acc
Revert "test"
korolenkowork May 10, 2025
e1f4a30
Update docker-compose-e2e-postgres.yml
korolenkowork May 10, 2025
8ced224
fix
korolenkowork May 10, 2025
42a362a
Update docker-compose-e2e-postgres.yml
korolenkowork May 10, 2025
1211b91
Mock final step migrations
korolenkowork May 10, 2025
c1e648f
Update poetry.lock
korolenkowork May 10, 2025
99be2fa
Update run-migrations-e2e-tests.yml
korolenkowork May 10, 2025
5e1e409
fix
korolenkowork May 10, 2025
7a405b8
Update run-migrations-e2e-tests.yml
korolenkowork May 10, 2025
fea2ead
Update run-migrations-e2e-tests.yml
korolenkowork May 10, 2025
ea6746e
Update run-migrations-e2e-tests.yml
korolenkowork May 10, 2025
4fdb76e
try
korolenkowork May 10, 2025
d458eac
test
korolenkowork May 10, 2025
4c79efe
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
1d2716c
minor changes in copy migrations logic
korolenkowork May 15, 2025
4adea39
Merge branch 'feature/auto-downgrade-revision' of https://github.com/…
korolenkowork May 15, 2025
e645a5e
fix
korolenkowork May 15, 2025
a1ffa55
test
korolenkowork May 15, 2025
f4d8ea8
fix
korolenkowork May 15, 2025
84ce798
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
36051a0
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
d41c554
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
68416f8
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
4a6039e
stop instead of down
korolenkowork May 15, 2025
9eeaddd
Update docker-compose-e2e-postgres.yml
korolenkowork May 15, 2025
24200a7
final
korolenkowork May 15, 2025
e7ea523
final
korolenkowork May 15, 2025
70325a0
fix
korolenkowork May 15, 2025
1725ae2
fix test script path
korolenkowork May 15, 2025
166abba
fix
korolenkowork May 15, 2025
70808cc
fix
korolenkowork May 15, 2025
89868ba
Ahhhh
korolenkowork May 15, 2025
4faabfb
Merge branch 'main' into feature/auto-downgrade-revision
shahargl May 19, 2025
e1e1dad
Post review fixes
korolenkowork May 19, 2025
40a8340
Merge branch 'feature/auto-downgrade-revision' of https://github.com/…
korolenkowork May 19, 2025
ad148d8
fix
korolenkowork May 19, 2025
7afb934
Update docker-compose-e2e-postgres.yml
korolenkowork May 19, 2025
3f1f88a
Merge branch 'main' into feature/auto-downgrade-revision
shahargl May 19, 2025
49df674
fix
korolenkowork May 19, 2025
077ba69
Merge branch 'feature/auto-downgrade-revision' of https://github.com/…
korolenkowork May 19, 2025
ed91ff4
Add migration path to dockerfiles
korolenkowork May 19, 2025
f1328ef
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork May 22, 2025
bc5ebce
Merge branch 'main' into feature/auto-downgrade-revision
shahargl May 25, 2025
02ca8bf
Merge branch 'main' into feature/auto-downgrade-revision
shahargl May 26, 2025
db76ae7
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork May 29, 2025
c05e35e
Make separate docker compose for migrations e2e
korolenkowork May 29, 2025
aea9b81
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork Jun 9, 2025
356ce18
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork Jun 14, 2025
13fe761
Update poetry.lock
korolenkowork Jun 16, 2025
96d9479
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork Jun 27, 2025
71e81be
Merge branch 'main' into feature/auto-downgrade-revision
korolenkowork Jul 3, 2025
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
Prev Previous commit
Next Next commit
migrations-e2e-prepare-for-coding
  • Loading branch information
korolenkowork committed May 2, 2025
commit 9b2f67fe301f266f06a04e67c9453b2718041bae
335 changes: 335 additions & 0 deletions .github/workflows/run-migration-e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,335 @@
on:
workflow_call:
inputs:
db-type:
required: true
type: string
redis_enabled:
required: true
type: boolean
python-version:
required: true
type: string
is-fork:
required: true
type: boolean
backend-image-name:
required: true
type: string
frontend-image-name:
required: true
type: string

jobs:
# Run tests with all services in one job
run-tests:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REDIS: ${{ inputs.redis_enabled }}
REDIS_HOST: keep-redis
REDIS_PORT: 6379
OLD_BACKEND_IMAGE: keep-backend:0.42.0
SOURCE_BACKEND_IMAGE: ${{ inputs.backend-image-name }}
OLD_FRONTEND_IMAGE: keep-frontend:0.42.0
SOURCE_FRONTEND_IMAGE: ${{ inputs.frontend-image-name }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
if: ${{ inputs.is-fork != true }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Restore dependencies cache
id: cache-deps
uses: actions/cache@v4.2.0
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

# Only install dependencies if cache miss
- name: Install dependencies using poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
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.2.0
with:
path: ~/.cache/ms-playwright
key: playwright-${{ steps.playwright-version.outputs.version }}

- name: Install Playwright and dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
poetry run playwright install --with-deps

# For forks: Build images locally again since they don't persist between jobs
- name: Set up Docker Buildx
if: ${{ inputs.is-fork == true }}
id: buildx
uses: docker/setup-buildx-action@v2

- name: Rebuild frontend image locally for fork PRs
if: ${{ inputs.is-fork == true }}
uses: docker/build-push-action@v4
with:
context: keep-ui
file: ./docker/Dockerfile.ui
push: false
load: true
tags: |
keep-frontend:local
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1

- name: Rebuild backend image locally for fork PRs
if: ${{ inputs.is-fork == true }}
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile.api
push: false
load: true
tags: |
keep-backend:local
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1

# Create a modified compose file with our built images
- name: Create modified docker-compose file with old images
run: |
cp tests/e2e_tests/docker-compose-e2e-${{ inputs.db-type }}.yml tests/e2e_tests/docker-compose-modified.yml

# Replace image placeholders with actual image references
sed -i "s|%KEEPFRONTEND_IMAGE%|${{ env.OLD_FRONTEND_IMAGE }}|g" tests/e2e_tests/docker-compose-modified.yml
sed -i "s|%KEEPBACKEND_IMAGE%|${{ env.OLD_BACKEND_IMAGE }}|g" tests/e2e_tests/docker-compose-modified.yml

# cat the modified file for debugging
cat tests/e2e_tests/docker-compose-modified.yml

# Start ALL services in one go
- name: Start ALL services
run: |
echo "Starting ALL services for ${{ inputs.db-type }}..."

# Pull the required images first (only needed for non-fork builds)
if [[ "${{ inputs.is-fork }}" != "true" ]]; then
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml pull
fi

# Start all services together
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml up -d

# Show running containers
docker ps

# Show the images sha of the running containers
docker images

# Wait for all services to be ready
- name: Wait for services to be ready
run: |
# Function for exponential backoff
function wait_for_service() {
local service_name=$1
local check_command=$2
local max_attempts=$3
local compose_service=$4 # Docker Compose service name
local attempt=0
local wait_time=1

echo "Waiting for $service_name to be ready..."
until eval "$check_command"; do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting..."
# Show final logs before exiting
if [ ! -z "$compose_service" ]; then
echo "===== FINAL LOGS FOR ON ERROR EXIT $compose_service ====="
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs $compose_service
echo "=========================================="
fi
exit 1
fi

echo "Waiting for $service_name... (Attempt: $((attempt+1)), waiting ${wait_time}s)"

# Print logs using docker compose
if [ ! -z "$compose_service" ]; then
echo "===== RECENT LOGS FOR $compose_service ====="
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs $compose_service --tail 100
echo "=========================================="
fi

attempt=$((attempt+1))
sleep $wait_time
# Exponential backoff with max of 8 seconds
wait_time=$((wait_time * 2 > 8 ? 8 : wait_time * 2))
done
echo "$service_name is ready!"

# last time, print logs using docker compose
if [ ! -z "$compose_service" ]; then
echo "===== FINAL LOGS FOR $compose_service ====="
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs $compose_service --tail 100
echo "=========================================="
fi
}

# Database checks
if [ "${{ inputs.db-type }}" == "mysql" ]; then
wait_for_service "MySQL Database" "docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml exec -T keep-database mysqladmin ping -h \"localhost\" --silent" 10 "keep-database"
wait_for_service "MySQL Database (DB AUTH)" "docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml exec -T keep-database-db-auth mysqladmin ping -h \"localhost\" --silent" 10 "keep-database-db-auth"
elif [ "${{ inputs.db-type }}" == "postgres" ]; then
wait_for_service "Postgres Database" "docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml exec -T keep-database pg_isready -h localhost -U keepuser" 10 "keep-database"
wait_for_service "Postgres Database (DB AUTH)" "docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml exec -T keep-database-db-auth pg_isready -h localhost -U keepuser" 10 "keep-database-db-auth"
fi

# Wait for services with health checks
wait_for_service "Keep backend" "curl --output /dev/null --silent --fail http://localhost:8080/healthcheck" 15 "keep-backend"
wait_for_service "Keep backend (DB AUTH)" "curl --output /dev/null --silent --fail http://localhost:8081/healthcheck" 15 "keep-backend-db-auth"
wait_for_service "Keep frontend" "curl --output /dev/null --silent --fail http://localhost:3000/" 15 "keep-frontend"
wait_for_service "Keep frontend (DB AUTH)" "curl --output /dev/null --silent --fail http://localhost:3001/" 15 "keep-frontend-db-auth"

# Give Prometheus and Grafana extra time to initialize
# (using direct curl commands instead of container exec)
echo "Waiting for Prometheus to be ready..."
MAX_ATTEMPTS=15
for i in $(seq 1 $MAX_ATTEMPTS); do
if curl --output /dev/null --silent --fail http://localhost:9090/-/healthy; then
echo "Prometheus is ready!"
break
elif [ $i -eq $MAX_ATTEMPTS ]; then
echo "Prometheus did not become ready in time, but continuing..."
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs prometheus-server-for-test-target --tail 50
else
echo "Waiting for Prometheus... Attempt $i/$MAX_ATTEMPTS"
sleep 5
fi
done

echo "Waiting for Grafana to be ready..."
MAX_ATTEMPTS=15
for i in $(seq 1 $MAX_ATTEMPTS); do
if curl --output /dev/null --silent --fail http://localhost:3002/api/health; then
echo "Grafana is ready!"
break
elif [ $i -eq $MAX_ATTEMPTS ]; then
echo "Grafana did not become ready in time, but continuing..."
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs grafana --tail 50
else
echo "Waiting for Grafana... Attempt $i/$MAX_ATTEMPTS"
sleep 5
fi
done

# Give everything a bit more time to stabilize
echo "Giving services additional time to stabilize..."
sleep 10

# Debug the environment before running tests
- name: Debug environment
run: |
echo "Checking all container status..."
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml ps

echo "Network information:"
docker network ls
docker network inspect keep_default || true

echo "Testing Prometheus API..."
curl -v http://localhost:9090/api/v1/status/config || echo "Prometheus API not responding, but continuing..."

echo "Testing Grafana API..."
curl -v http://localhost:3002/api/health || echo "Grafana API not responding, but continuing..."

echo "Test Keep Frontend..."
curl -v http://localhost:3000/ || echo "Keep Frontend not responding, but continuing..."

echo "Test Keep Frontend with DB Auth..."
curl -v http://localhost:3001/ || echo "Keep Frontend with DB Auth not responding, but continuing..."

echo "Listing available ports:"
netstat -tuln | grep -E '3000|3001|3002|8080|8081|9090'

# Run e2e tests
- name: Run e2e tests and report coverage
run: |
echo "Running tests..."
poetry run coverage run --branch -m pytest -v tests/e2e_tests/ -n 4 --dist=loadfile
echo "Tests completed!"

- 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
files: coverage.json
verbose: true

# Collect logs
- name: Dump logs
if: always()
run: |
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs keep-backend > backend_logs-${{ inputs.db-type }}.txt
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs keep-frontend > frontend_logs-${{ inputs.db-type }}.txt
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs keep-backend-db-auth > backend_logs-${{ inputs.db-type }}-db-auth.txt
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs keep-frontend-db-auth > frontend_logs-${{ inputs.db-type }}-db-auth.txt
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs prometheus-server-for-test-target > prometheus_logs-${{ inputs.db-type }}.txt
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml logs grafana > grafana_logs-${{ inputs.db-type }}.txt
continue-on-error: true

# Upload artifacts
- name: Upload test artifacts on failure
if: always()
uses: actions/upload-artifact@v4.4.3
with:
name: test-artifacts-db-${{ inputs.db-type }}-redis-${{ inputs.redis_enabled }}
path: |
playwright_dump_*.html
playwright_dump_*.png
playwright_dump_*.txt
playwright_dump_*.json
backend_logs-${{ inputs.db-type }}.txt
frontend_logs-${{ inputs.db-type }}.txt
backend_logs-${{ inputs.db-type }}-db-auth.txt
frontend_logs-${{ inputs.db-type }}-db-auth.txt
prometheus_logs-${{ inputs.db-type }}.txt
grafana_logs-${{ inputs.db-type }}.txt
continue-on-error: true

# Tear down environment
- name: Tear down environment
if: always()
run: |
docker compose -p keep --project-directory . -f tests/e2e_tests/docker-compose-modified.yml down
11 changes: 11 additions & 0 deletions .github/workflows/test-pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@ jobs:
frontend-image-name: ${{ needs.build-frontend.outputs.image_name }}

run-sqlite-without-redis:
needs: [build-frontend, build-backend, prepare-test-environment]
uses: ./.github/workflows/run-e2e-tests.yml
with:
db-type: sqlite
redis_enabled: false
python-version: 3.11
is-fork: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
backend-image-name: ${{ needs.build-backend.outputs.image_name }}
frontend-image-name: ${{ needs.build-frontend.outputs.image_name }}

run-migrations-tests:
needs: [build-frontend, build-backend, prepare-test-environment]
uses: ./.github/workflows/run-e2e-tests.yml
with:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy