langflow icon indicating copy to clipboard operation
langflow copied to clipboard

feat: Add DB migration validation workflow for nightly builds

Open vjgit96 opened this issue 6 months ago • 7 comments

Description

Implements automated database migration validation workflow for Langflow nightly builds.

This addresses the critical blocker identified by the QA team for ensuring safe database migrations when upgrading from stable to nightly versions in production deployments.

Changes

New Workflow: db-migration-validation.yml

Comprehensive automated testing for database migrations with two independent scenarios:

Scenario 1: pip/venv Migration

  • Installs latest stable langflow[postgresql] via uv pip
  • Initializes PostgreSQL database with stable version
  • Creates witness test data (flows and credentials)
  • Upgrades to langflow-nightly[postgresql] in same environment
  • Validates successful startup and data persistence

Scenario 2: Docker Compose Migration

  • Starts langflowai/langflow:latest with PostgreSQL
  • Creates witness test data via API
  • Stops Langflow container (keeps PostgreSQL volume)
  • Swaps to langflowai/langflow-nightly:latest using same volume
  • Validates successful startup and data persistence

Integration with Nightly Build

Modified .github/workflows/nightly_build.yml:

  • Added db-migration-validation job that runs after successful Docker build
  • Updated Slack notifications to include migration test results
  • Automatic execution on every nightly build

Documentation

Added comprehensive guide at docs/docs/Deployment/db-migration-validation.md:

  • Implementation details and test scenarios
  • Environment configuration and success criteria
  • Monitoring and troubleshooting guidelines
  • Next steps and maintenance procedures

Key Features

  • ✅ Validates data persistence across migrations (witness flows)
  • ✅ Tests both pip/venv and Docker deployment methods
  • ✅ Comprehensive error logging and artifact collection
  • ✅ Slack notifications with detailed results
  • ✅ Runs daily at 3:00 AM UTC (after nightly builds)
  • ✅ Manual trigger capability for testing

Testing

Both migration scenarios must pass for the workflow to succeed:

  1. Langflow starts successfully after migration
  2. Health check endpoint responds (200 OK)
  3. Witness flows are retrievable via API
  4. No database errors in logs

On failure, the workflow:

  • Captures all relevant logs (Langflow, Docker, PostgreSQL)
  • Saves API responses and flow data
  • Uploads artifacts to GitHub Actions (7-day retention)
  • Sends detailed Slack notification with failure reason

Files Changed

  • .github/workflows/db-migration-validation.yml (new, 449 lines)
  • .github/workflows/nightly_build.yml (modified, +8 lines)
  • docs/docs/Deployment/db-migration-validation.md (new, 164 lines)

Checklist

  • [x] Workflow implements both required migration scenarios
  • [x] Data persistence validation included
  • [x] Integrated into nightly build pipeline
  • [x] Comprehensive error handling and logging
  • [x] Slack notifications configured
  • [x] Documentation added
  • [ ] Manual test execution (to be done after PR approval)

Next Steps

  1. Review and approve PR
  2. Merge to release-1.10.0
  3. Manual trigger to validate workflow execution
  4. Monitor first automatic run in production
  5. Address any issues discovered during initial runs

Summary by CodeRabbit

Release Notes

  • Improvements

    • Implemented automated validation of database migrations to ensure data integrity during upgrades between stable and nightly releases, covering both pip-based and Docker-based deployment methods.
  • Documentation

    • Added documentation for the database migration validation workflow and its integration into the nightly release process.

Review Change Stack

vjgit96 avatar May 20 '26 19:05 vjgit96

✅ Test Coverage Advisor

No source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉

Advisory check only — never blocks merge.

github-actions[bot] avatar May 20 '26 19:05 github-actions[bot]

Build successful! :white_check_mark: Deploying docs draft. Deploy successful! View draft

github-actions[bot] avatar May 20 '26 19:05 github-actions[bot]

[!IMPORTANT]

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f7418ef-4930-4815-ac00-35696822a5bb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review

Walkthrough

Adds a new GitHub Actions workflow that validates database migrations when upgrading Langflow from stable to nightly versions. The workflow tests migration persistence via two execution paths (pip/venv and Docker Compose), creates and recovers witness test data across the upgrade, and reports results to Slack. Integration into nightly build and comprehensive documentation are included.

Changes

Database Migration Validation Workflow

Layer / File(s) Summary
DB Migration Validation Workflow Core
.github/workflows/db-migration-validation.yml
Defines workflow triggers (workflow_call, workflow_dispatch, cron schedule) and global config. Implements migration-pip-venv job using a Postgres service: provisions venv with stable package, initializes DB, creates witness flow via API, upgrades to nightly, runs migrations, verifies witness persistence, and uploads logs/artifacts on failure. Implements migration-docker-compose job: generates Compose file for stable, creates witness data, replaces image tag to nightly, verifies persistence across upgrade, and cleans up resources. Adds notify-results job that aggregates both migration job results and sends Slack message with status and nightly tag.
Nightly Build Workflow Integration
.github/workflows/nightly_build.yml
Adds db-migration-validation job that calls the validation workflow after nightly release succeeds, passing the nightly Docker tag and secrets. Updates slack-notification job to depend on migration validation results and extends the failure-notification condition to trigger when db-migration-validation fails, setting FAILED_JOB accordingly.
Documentation and Implementation Guide
docs/docs/Deployment/db-migration-validation.md
Documents the new workflow's purpose, two parallel migration test scenarios (pip/venv and Docker Compose), integration into nightly CI (daily cron, manual trigger, post-release), key behaviors (data persistence, logging, Slack alerts), required secrets/environment variables, success criteria (startup, health checks, witness-flow recovery, no DB errors), failure handling (log/artifact uploads), manual execution instructions, and monitoring/branch context.

Sequence Diagram(s)

sequenceDiagram
  participant Witness as Test Harness
  participant Stable as Stable Langflow
  participant Nightly as Nightly Langflow
  participant DB as PostgreSQL
  participant API as Migration API
  participant Slack as Slack Webhook
  
  Witness->>Stable: Start with stable version
  Stable->>DB: Initialize database
  Witness->>API: Create witness flow (test data)
  DB->>DB: Witness flow persisted
  Witness->>Nightly: Upgrade to nightly version
  Nightly->>DB: Execute pending migrations
  Witness->>API: Verify witness flow exists
  API->>DB: Query restored data
  Witness->>Slack: Report success/failure + status

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


[!IMPORTANT]

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR adds new GitHub Actions workflow and modifies nightly_build.yml but includes NO unit/integration test files (test_*.py) following project conventions. Add unit/integration tests (test_*.py files) under src/backend/tests/ for the migration validation functionality added in this PR.
Test Quality And Coverage ⚠️ Warning PR adds 454-line GitHub Actions workflow with two migration test scenarios but no dedicated pytest/integration tests. Migration validation uses inline shell/curl scripts not formally tested. Add pytest-based tests or integration test scripts verifying migration workflow logic, or document why GitHub Actions workflow testing is the primary test strategy for this CI/CD code.
✅ Passed checks (7 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test File Naming And Structure ✅ Passed PR adds only GitHub Actions workflows and documentation, not test files; check is not applicable to this PR.
Excessive Mock Usage Warning ✅ Passed PR adds integration workflows using real PostgreSQL and Docker services, not test files with mocks. The custom check for mock usage is not applicable.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new GitHub Actions workflow for validating database migrations in nightly builds, which is the primary objective of this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch LE-1259-db-migration-validation

[!WARNING]

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 20 '26 19:05 coderabbitai[bot]

Build successful! :white_check_mark: Deploying docs draft. Deploy successful! View draft

github-actions[bot] avatar May 20 '26 21:05 github-actions[bot]

@ogabrielluiz - I've addressed all your review feedback:

Workflow fixes (9 issues):

  • ✅ Now uses actual nightly tag from create-nightly-tag output instead of hardcoded :latest
  • ✅ Wired POSTGRES_VERSION env var into postgres service image
  • ✅ Removed unnecessary checkout steps from both migration jobs
  • ✅ Fixed step name from "Create witness flow and credentials" to "Create witness flow"
  • ✅ Added -f flag to curl commands for fail-fast behavior
  • ✅ Added flow creation verification with error handling
  • ✅ Fixed version extraction logic to test actual nightly build
  • ✅ Removed deprecated version field from docker-compose files
  • ✅ Removed duplicate Slack notification job

Documentation fix:

  • ✅ Removed docs/docs/Deployment/db-migration-validation.md - you're right, it was implementation notes not user-facing docs

All changes pushed in commits 9228d833ea and c262a67043.

Ready for re-review! 🚀

vjgit96 avatar May 20 '26 21:05 vjgit96

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 56.17%. Comparing base (e9514f5) to head (f37d365). :warning: Report is 4 commits behind head on release-1.10.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-1.10.0   #13249      +/-   ##
==================================================
- Coverage           56.45%   56.17%   -0.28%     
==================================================
  Files                2208     2212       +4     
  Lines              209281   210206     +925     
  Branches            29701    32602    +2901     
==================================================
- Hits               118158   118093      -65     
- Misses              89762    90752     +990     
  Partials             1361     1361              
Flag Coverage Δ
backend 61.59% <ø> (+0.06%) :arrow_up:
frontend 55.82% <ø> (-0.44%) :arrow_down:
lfx 52.20% <ø> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more. see 247 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 20 '26 21:05 codecov[bot]

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 40%
40.8% (52195/127898) 68.72% (7110/10345) 39.66% (1176/2965)

Unit Test Results

Tests Skipped Failures Errors Time
4514 0 :zzz: 0 :x: 0 :fire: 10m 18s :stopwatch:

github-actions[bot] avatar May 20 '26 21:05 github-actions[bot]