Langflow Migration: Fresh PostgreSQL Install #97
This file contains hidden or 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: "Langflow Migration: Fresh PostgreSQL Install" | |
| on: | |
| schedule: | |
| - cron: "0 8 * * *" # 05:00 BRT (UTC-3) | |
| workflow_dispatch: | |
| env: | |
| LANGFLOW_PORT: 7860 | |
| LANGFLOW_URL: http://localhost:7860 | |
| PG_USER: langflow | |
| PG_PASSWORD: langflow_test_pw | |
| PG_DB: langflow | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| fresh-install: | |
| name: Fresh PostgreSQL Install (nightly) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: langflow | |
| POSTGRES_PASSWORD: langflow_test_pw | |
| POSTGRES_DB: langflow | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install requests | |
| - name: Pull Langflow nightly | |
| run: | | |
| docker pull langflowai/langflow-nightly:latest | |
| docker inspect langflowai/langflow-nightly:latest \ | |
| --format='{{index .RepoDigests 0}}' | tee /tmp/nightly-digest.txt | |
| echo "Nightly digest: $(cat /tmp/nightly-digest.txt)" | |
| - name: Start Langflow nightly on fresh PostgreSQL | |
| run: | | |
| docker run -d --name langflow \ | |
| --network host \ | |
| -e LANGFLOW_DATABASE_URL="postgresql://$PG_USER:$PG_PASSWORD@localhost:5432/$PG_DB" \ | |
| -e LANGFLOW_AUTO_LOGIN=true \ | |
| -e LANGFLOW_SUPERUSER=langflow \ | |
| -e LANGFLOW_SUPERUSER_PASSWORD=langflow123 \ | |
| -e LANGFLOW_STORE=false \ | |
| langflowai/langflow-nightly:latest | |
| - name: Wait for Langflow nightly (includes migrations) | |
| run: python tests/github-workflows/migration/wait_for_langflow.py --timeout 180 | |
| env: | |
| LANGFLOW_URL: ${{ env.LANGFLOW_URL }} | |
| - name: Verify fresh install via API | |
| run: python tests/github-workflows/migration/verify_fresh_install.py | |
| env: | |
| LANGFLOW_URL: ${{ env.LANGFLOW_URL }} | |
| - name: Save container logs | |
| if: always() | |
| run: docker logs langflow > /tmp/langflow-fresh-install.log 2>&1 || true | |
| - name: Upload logs | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: fresh-install-${{ github.run_number }} | |
| path: | | |
| /tmp/langflow-fresh-install.log | |
| /tmp/nightly-digest.txt | |
| - name: Cleanup | |
| if: always() | |
| run: docker stop langflow 2>/dev/null; docker rm langflow 2>/dev/null; true | |
| - name: Close issue on success | |
| if: success() | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const { data: existing } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: 'migration-fresh-install', | |
| state: 'open', | |
| }); | |
| if (existing.length > 0) { | |
| const issue = existing[0]; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issue.number, | |
| body: [ | |
| `## ✅ Run #${context.runNumber} — ${new Date().toISOString().split('T')[0]}`, | |
| '', | |
| 'Fresh install test passed. Closing this issue.', | |
| '', | |
| `[Workflow Run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`, | |
| ].join('\n'), | |
| }); | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issue.number, | |
| state: 'closed', | |
| }); | |
| } | |
| - name: Create or update issue on failure | |
| if: failure() | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const digest = fs.existsSync('/tmp/nightly-digest.txt') | |
| ? fs.readFileSync('/tmp/nightly-digest.txt', 'utf8').trim().slice(-20) | |
| : 'unknown'; | |
| const { data: existing } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: 'migration-fresh-install', | |
| state: 'open', | |
| }); | |
| const body = [ | |
| `## Fresh Install Failure — Run #${context.runNumber}`, | |
| '', | |
| `- **Date:** ${new Date().toISOString().split('T')[0]}`, | |
| `- **Image:** \`langflowai/langflow-nightly:latest\` (\`...${digest}\`)`, | |
| `- **Scenario:** Fresh PostgreSQL install (empty database)`, | |
| '', | |
| `[Workflow Run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`, | |
| '', | |
| '/cc @lice-reis', | |
| ].join('\n'); | |
| if (existing.length > 0) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: existing[0].number, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: 'Langflow Nightly: Fresh PostgreSQL Install Failed', | |
| body, | |
| labels: ['migration-fresh-install', 'automated'], | |
| }); | |
| } |