Skip to content

fix: ensure APP_URL resolves at runtime for self-hosted instances #231

fix: ensure APP_URL resolves at runtime for self-hosted instances

fix: ensure APP_URL resolves at runtime for self-hosted instances #231

Workflow file for this run

name: CLI Integration Tests
on:
push:
branches: [main, develop]
paths:
- 'cli/**'
- 'packages/shared/**'
- '.github/workflows/cli-tests.yml'
pull_request:
branches: [main, develop]
paths:
- 'cli/**'
- 'packages/shared/**'
workflow_dispatch:
inputs:
environment:
description: 'Test environment'
required: true
default: 'dev'
type: choice
options:
- dev
- prod
env:
NODE_VERSION: '22'
jobs:
# Basic tests without authentication
public-tests:
name: Public CLI Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install CLI globally from npm
run: npm install -g lynxprompt
- name: Verify CLI installation
run: |
lynxp --version
lynxp --help
- name: Create test directory
run: mkdir -p /tmp/lynxp-test && cd /tmp/lynxp-test
- name: Test wizard (AGENTS.md)
working-directory: /tmp/lynxp-test
run: |
lynxp wizard -y --name "CI Test Project"
test -f AGENTS.md || exit 1
echo "✓ AGENTS.md generated"
- name: Test wizard (Cursor format)
working-directory: /tmp/lynxp-test
run: |
lynxp wizard -y --name "Cursor Test" --format cursor
test -f .cursor/rules/project.mdc || exit 1
echo "✓ Cursor config generated"
- name: Test check
working-directory: /tmp/lynxp-test
run: |
lynxp check
echo "✓ Check passed"
- name: Test check --ci (exit code)
working-directory: /tmp/lynxp-test
run: |
lynxp check --ci
echo "✓ Check CI mode works (exit 0)"
- name: Test status
working-directory: /tmp/lynxp-test
run: |
lynxp status
echo "✓ Status works"
- name: Test search (public)
env:
LYNXPROMPT_API_URL: ${{ inputs.environment == 'prod' && 'https://lynxprompt.com' || 'https://dev.lynxprompt.com' }}
run: |
lynxp search "nextjs" --limit 3 || true
echo "✓ Search works"
# Authenticated tests (only on main/develop, not PRs from forks)
# Uses built-from-source CLI to test current code against dev server
authenticated-tests:
name: Authenticated CLI Tests
runs-on: ubuntu-latest
needs: [build-test] # Ensure build passes first
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
LYNXPROMPT_TOKEN: ${{ secrets.LYNXPROMPT_DEV_TOKEN }}
LYNXPROMPT_API_URL: https://dev.lynxprompt.com
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build shared package
run: npx --yes --package typescript tsc -p packages/shared/tsconfig.json
- name: Build CLI from source
working-directory: cli
run: |
npm ci
npm run build
npm link
- name: Verify CLI is from source
run: |
lynxp --version
echo "✓ CLI built from source"
- name: Check for token
run: |
if [ -z "$LYNXPROMPT_TOKEN" ]; then
echo "⚠️ LYNXPROMPT_DEV_TOKEN secret not set, skipping authenticated tests"
exit 0
fi
echo "✓ Token available"
- name: Wait for dev server to be healthy
run: |
echo "Checking dev server health..."
for i in 1 2 3 4 5; do
if curl -sf https://dev.lynxprompt.com/api/health > /dev/null 2>&1; then
echo "✓ Dev server is healthy"
exit 0
fi
echo "Attempt $i: Server not ready, waiting 30s..."
sleep 30
done
echo "⚠️ Dev server may not be fully deployed yet, proceeding anyway"
- name: Test whoami
if: env.LYNXPROMPT_TOKEN != ''
run: |
# Retry up to 3 times in case server is still warming up
for i in 1 2 3; do
if lynxp whoami; then
echo "✓ Authentication working"
exit 0
fi
echo "Attempt $i failed, retrying in 10s..."
sleep 10
done
echo "❌ whoami failed after 3 attempts"
exit 1
- name: Test list blueprints
if: env.LYNXPROMPT_TOKEN != ''
run: |
lynxp list || true
echo "✓ List works"
- name: Create test directory
if: env.LYNXPROMPT_TOKEN != ''
run: mkdir -p /tmp/lynxp-auth-test && cd /tmp/lynxp-auth-test
- name: Test push new blueprint
if: env.LYNXPROMPT_TOKEN != ''
working-directory: /tmp/lynxp-auth-test
run: |
echo "# CI Test Blueprint" > ci-test.md
echo "" >> ci-test.md
echo "Auto-generated by GitHub Actions CI" >> ci-test.md
echo "Run: ${{ github.run_id }}" >> ci-test.md
lynxp push ci-test.md --yes \
--name "CI Test ${{ github.run_id }}" \
--description "Auto-generated test blueprint" \
--visibility PRIVATE
echo "✓ Push new blueprint works"
- name: Test link list
if: env.LYNXPROMPT_TOKEN != ''
working-directory: /tmp/lynxp-auth-test
run: |
lynxp link --list
echo "✓ Link list works"
- name: Test push update
if: env.LYNXPROMPT_TOKEN != ''
working-directory: /tmp/lynxp-auth-test
run: |
echo "" >> ci-test.md
echo "## Updated" >> ci-test.md
echo "Updated at $(date -u)" >> ci-test.md
# Use --force since local file was modified (optimistic locking)
lynxp push ci-test.md --yes --force
echo "✓ Push update works"
- name: Test status with linked blueprint
if: env.LYNXPROMPT_TOKEN != ''
working-directory: /tmp/lynxp-auth-test
run: |
lynxp status
echo "✓ Status shows linked blueprint"
# Build from source test
build-test:
name: Build CLI from Source
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build shared package
run: npx --yes --package typescript tsc -p packages/shared/tsconfig.json
- name: Install dependencies
working-directory: cli
run: npm ci
- name: Build
working-directory: cli
run: npm run build
- name: Typecheck
working-directory: cli
run: npm run typecheck
- name: Test built CLI
working-directory: cli
run: |
node dist/index.js --version
node dist/index.js --help
echo "✓ Built CLI works"