Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: 'Setup pgflow workspace'
description: 'Common setup steps for pgflow CI workflow (run after checkout)'

inputs:
atlas-cloud-token:
description: 'Atlas Cloud token for schema verification'
required: false

runs:
using: 'composite'
steps:
Expand Down Expand Up @@ -29,6 +34,20 @@ runs:
cache-dependency-path: |
**/pnpm-lock.yaml

- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: '2.1.4'

- name: Install sqruff
uses: quarylabs/install-sqruff-cli-action@main
Comment on lines +42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is failing because the 'quarylabs/install-sqruff-cli-action@main' action cannot successfully download and install the sqruff-linux-x86_64-musl.tar.gz file. Either pin this action to a specific stable version (e.g., 'quarylabs/[email protected]') instead of using the potentially unstable '@main' reference, or temporarily remove this step until the upstream action is fixed.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.


- name: Setup Atlas
if: inputs.atlas-cloud-token != ''
uses: ariga/setup-atlas@master
with:
cloud-token: ${{ inputs.atlas-cloud-token }}

- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --prefer-offline
Expand Down
295 changes: 181 additions & 114 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,23 @@
"preview": {
"dependsOn": ["^build"]
},
"supabase:*": {
"supabase:start": {
"local": true,
"cache": false
},
"supabase:stop": {
"local": true,
"cache": false
},
"supabase:status": {
"local": true,
"cache": false
},
"supabase:reset": {
"local": true,
"cache": false
},
"supabase:restart": {
"local": true,
"cache": false
},
Expand All @@ -95,9 +111,14 @@
"local": true
},
"verify-*": {
"local": true,
"cache": true
},
"db:verify": {
"cache": true
},
"test:live": {
"local": true
},
"dump-realtime-schema": {
"local": true,
"cache": true
Expand Down
1 change: 1 addition & 0 deletions pkgs/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"module": "./dist/index.js",
"devDependencies": {
"@types/node": "^22.14.1",
"supabase": "^2.34.3",
"tsx": "^4.19.3"
},
"dependencies": {
Expand Down
19 changes: 10 additions & 9 deletions pkgs/cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@
}
},
"test": {
"executor": "nx:noop",
"inputs": ["default", "^production"],
"dependsOn": ["test:vitest"]
},
"test:live": {
"executor": "nx:noop",
"inputs": ["default", "^production"],
"dependsOn": [
"test:vitest",
"test:e2e:install",
"test:e2e:compile",
"test:e2e:async-hang-issue-123"
],
"options": {
"parallel": false
},
"metadata": {
"description": "Tests requiring external tools (Supabase CLI)"
}
},
"test:vitest": {
Expand Down Expand Up @@ -75,14 +82,8 @@
"dependsOn": ["test:e2e:install", "build"],
"inputs": ["default", "^production"],
"options": {
"commands": [
"rm -rf supabase/",
"npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings",
"node dist/index.js compile examples/analyze_website.ts --deno-json examples/deno.json --supabase-path supabase",
"./scripts/assert-flow-compiled"
],
"cwd": "{projectRoot}",
"parallel": false
"command": "./scripts/test-compile",
"cwd": "{projectRoot}"
}
},
"test:e2e:async-hang-issue-123": {
Expand Down
20 changes: 11 additions & 9 deletions pkgs/cli/scripts/test-async-hang-issue-123
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

# Script to test if pgflow CLI compile hangs on flows with async functions
# This reproduces issue #123: https://github.com/pgflow-dev/pgflow/issues/123
Expand All @@ -12,25 +12,27 @@ set -e
cd "$(dirname "$0")/.."
ROOT_DIR=$(pwd)

# Create unique temp directory for this test
TEST_DIR=$(mktemp -d)
trap "rm -rf $TEST_DIR" EXIT

echo "🧪 Testing async function compilation"
echo " Issue #123: https://github.com/pgflow-dev/pgflow/issues/123"
echo "📁 Test directory: $TEST_DIR"
echo ""

# Clean up any existing output
echo "🧹 Cleaning up old test directory"
rm -rf supabase/

# Initialize a fresh Supabase project
# Initialize a fresh Supabase project in temp dir
cd "$TEST_DIR"
echo "🏗️ Creating new Supabase project"
npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings
pnpm --dir="$ROOT_DIR" supabase init --workdir "$TEST_DIR" --with-vscode-settings --with-intellij-settings

# Install pgflow with our CLI
echo "📦 Installing pgflow with CLI"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes

# Try to compile the flow with async functions
echo "🔧 Compiling flow with async functions"
timeout 30s node dist/index.js compile examples/async-function-hang.ts --deno-json examples/deno.json --supabase-path supabase || {
timeout 30s node "$ROOT_DIR/dist/index.js" compile "$ROOT_DIR/examples/async-function-hang.ts" --deno-json "$ROOT_DIR/examples/deno.json" --supabase-path supabase || {
EXIT_CODE=$?
if [ $EXIT_CODE -eq 124 ]; then
echo "❌ FAILURE: Compilation hung and was killed by timeout (30s)"
Expand Down
31 changes: 31 additions & 0 deletions pkgs/cli/scripts/test-compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail

# Script to test pgflow CLI compile functionality
# This simulates the test:e2e:compile target from project.json

cd "$(dirname "$0")/.."
ROOT_DIR=$(pwd)

# Create unique temp directory for this test
TEST_DIR=$(mktemp -d)
trap "rm -rf $TEST_DIR" EXIT

echo "🧪 Testing pgflow compile functionality"
echo "📁 Test directory: $TEST_DIR"

# Initialize a fresh Supabase project in temp dir
cd "$TEST_DIR"
echo "🏗️ Creating new Supabase project"
pnpm --dir="$ROOT_DIR" supabase init --with-vscode-settings --with-intellij-settings

# Compile the flow
echo "🔧 Compiling analyze_website flow"
node "$ROOT_DIR/dist/index.js" compile "$ROOT_DIR/examples/analyze_website.ts" --deno-json "$ROOT_DIR/examples/deno.json" --supabase-path supabase

# Verify compilation succeeded
echo "✅ Verifying flow compilation"
"$ROOT_DIR/scripts/assert-flow-compiled"

# Show success message
echo "✨ Compile test complete"
20 changes: 11 additions & 9 deletions pkgs/cli/scripts/test-install
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

# Script to test pgflow CLI install functionality
# This simulates the test:e2e:install target from project.json

cd "$(dirname "$0")/.."
ROOT_DIR=$(pwd)

echo "🧪 Testing pgflow install functionality"
# Create unique temp directory for this test
TEST_DIR=$(mktemp -d)
trap "rm -rf $TEST_DIR" EXIT

# Clean up any existing supabase directory
echo "🧹 Cleaning up old test directory"
rm -rf supabase/
echo "🧪 Testing pgflow install functionality"
echo "📁 Test directory: $TEST_DIR"

# Initialize a fresh Supabase project
# Initialize a fresh Supabase project in temp dir
cd "$TEST_DIR"
echo "🏗️ Creating new Supabase project"
npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings
pnpm --dir="$ROOT_DIR" supabase init --workdir "$TEST_DIR" --with-vscode-settings --with-intellij-settings

# Install pgflow with our CLI
echo "📦 Installing pgflow with CLI"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes

# Verify installation succeeded
echo "✅ Verifying pgflow installation"
Expand All @@ -31,5 +33,5 @@ echo "✨ Installation test complete"
# Optional: Test for duplicates by running install again
if [ "$1" == "--test-duplicates" ]; then
echo "🔄 Testing duplicate installation prevention"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes
fi
22 changes: 12 additions & 10 deletions pkgs/cli/scripts/test-install-duplicates
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

# Script to test pgflow CLI install duplicate prevention
# This verifies that we don't create duplicate migrations

cd "$(dirname "$0")/.."
ROOT_DIR=$(pwd)

echo "🧪 Testing pgflow migration duplicate prevention"
# Create unique temp directory for this test
TEST_DIR=$(mktemp -d)
trap "rm -rf $TEST_DIR" EXIT

# Clean up any existing supabase directory
echo "🧹 Cleaning up old test directory"
rm -rf supabase/
echo "🧪 Testing pgflow migration duplicate prevention"
echo "📁 Test directory: $TEST_DIR"

# Initialize a fresh Supabase project
# Initialize a fresh Supabase project in temp dir
cd "$TEST_DIR"
echo "🏗️ Creating new Supabase project"
npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings
pnpm --dir="$ROOT_DIR" supabase init --with-vscode-settings --with-intellij-settings

# First installation with pgflow CLI
echo "📦 First pgflow installation"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes

# Count number of migrations after first install
FIRST_COUNT=$(find supabase/migrations -name "*.sql" | wc -l)
echo "🔢 Found $FIRST_COUNT migrations after first install"

# Second installation with pgflow CLI
echo "🔄 Running second pgflow installation"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes

# Count number of migrations after second install
SECOND_COUNT=$(find supabase/migrations -name "*.sql" | wc -l)
Expand All @@ -51,7 +53,7 @@ if [ "$1" == "--test-third-install" ]; then
mv "$RANDOM_MIGRATION" "$NEW_NAME"

echo "🔄 Running third pgflow installation"
node dist/index.js install --supabase-path supabase/ --yes
node "$ROOT_DIR/dist/index.js" install --supabase-path supabase/ --yes

# Count number of migrations after third install
THIRD_COUNT=$(find supabase/migrations -name "*.sql" | wc -l)
Expand Down
48 changes: 34 additions & 14 deletions pkgs/client/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@
"executor": "@nx/eslint:lint",
"inputs": ["default", "^production"]
},
"supabase:ensure-started": {
"executor": "nx:run-commands",
"local": true,
"cache": false,
"dependsOn": ["supabase:prepare"],
"options": {
"cwd": "{projectRoot}",
"commands": [
"../../scripts/supabase-start-locked.sh ."
],
"parallel": false
}
},
"supabase:start": {
"executor": "nx:run-commands",
"local": true,
Expand Down Expand Up @@ -138,6 +125,31 @@
"parallel": false
}
},
"db:ensure": {
"executor": "nx:run-commands",
"local": true,
"dependsOn": ["supabase:prepare"],
"options": {
"cwd": "{projectRoot}",
"commands": [
"../../scripts/supabase-start-locked.sh .",
"./scripts/ensure-db"
],
"parallel": false
},
"inputs": [
"{projectRoot}/scripts/ensure-db",
"{workspaceRoot}/pkgs/core/supabase/migrations/**/*.sql",
"{workspaceRoot}/pkgs/core/supabase/seed.sql",
"{projectRoot}/supabase/config.toml",
"{projectRoot}/tests/helpers/db.ts",
"{projectRoot}/tests/helpers/permissions.ts"
],
"outputs": [
"{projectRoot}/.nx-inputs/db-ready.txt"
],
"cache": false
},
"test:integration": {
"executor": "nx:run-commands",
"local": true,
Expand Down Expand Up @@ -181,7 +193,15 @@
"test": {
"executor": "nx:noop",
"inputs": ["default", "^production"],
"dependsOn": ["test:vitest", "test:types"]
"dependsOn": ["test:unit", "test:types"]
},
"test:live": {
"executor": "nx:noop",
"inputs": ["default", "^production"],
"dependsOn": ["test:integration"],
"metadata": {
"description": "Tests requiring live infrastructure (Supabase)"
}
},
"benchmark": {
"executor": "nx:run-commands",
Expand Down
Loading
Loading