Update apps/cli-e2e-tests/src/helpers/gateways/PackmindHttpClient.ts #3
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: Build and Test | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| node-version: | ||
| required: true | ||
| type: string | ||
| description: 'Node.js version to use' | ||
| secrets: | ||
| VITE_SENTRY_FRONTEND_DSN: | ||
| required: false | ||
| description: 'Sentry DSN for frontend monitoring (proprietary only)' | ||
| VITE_CRISP_WEBSITE_ID: | ||
| required: false | ||
| description: 'Crisp Website ID for chat support (proprietary only)' | ||
| outputs: | ||
| api-artifact: | ||
| description: 'API build artifact name' | ||
| value: ${{ jobs.build-api.outputs.artifact-name }} | ||
| frontend-artifact: | ||
| description: 'Frontend build artifact name' | ||
| value: ${{ jobs.build-frontend.outputs.artifact-name }} | ||
| mcp-server-artifact: | ||
| description: 'MCP Server build artifact name' | ||
| value: ${{ jobs.build-mcp-server.outputs.artifact-name }} | ||
| cli-artifact: | ||
| description: 'CLI build artifact name' | ||
| value: ${{ jobs.build-cli.outputs.artifact-name }} | ||
| cli-version: | ||
| description: 'CLI version' | ||
| value: ${{ jobs.build-cli.outputs.version }} | ||
| cli-executables-artifact: | ||
| description: 'CLI executables artifact name' | ||
| value: ${{ jobs.build-cli.outputs.cli-executables-artifact }} | ||
| standard-samples-artifact: | ||
| description: 'Standard samples artifact name' | ||
| value: ${{ jobs.build-packages.outputs.standard-samples-artifact }} | ||
| jobs: | ||
| build-api: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| outputs: | ||
| artifact-name: api-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - name: Build API | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx build api | ||
| - name: Test API | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx test api | ||
| - run: cp apps/api/docker-package.json dist/apps/api/. | ||
| - run: cp package.json dist/apps/api/. | ||
| - run: cp package-lock.json dist/apps/api/. | ||
| - run: cp tsconfig.base.effective.json dist/apps/api/. | ||
| - name: Upload API build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: api-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| path: dist/apps/api/ | ||
| build-frontend: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| outputs: | ||
| artifact-name: frontend-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - name: Generate Chakra types | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: npm run chakra:typegen | ||
| - name: Typechecks | ||
| run: npm run typecheck:frontend | ||
| - name: Test Frontend | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx test frontend | ||
| - name: Build frontend | ||
| env: | ||
| NODE_ENV: production | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| VITE_SENTRY_FRONTEND_DSN: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && secrets.VITE_SENTRY_FRONTEND_DSN || '' }} | ||
| VITE_SENTRY_ENVIRONMENT: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && 'production' || '' }} | ||
| VITE_CRISP_WEBSITE_ID: ${{ vars.PACKMIND_EDITION == 'proprietary' && !startsWith(github.ref, 'refs/tags/release/') && secrets.VITE_CRISP_WEBSITE_ID || '' }} | ||
| run: ./node_modules/.bin/nx build frontend | ||
| - run: cp tsconfig.base.effective.json apps/frontend/build/client/. | ||
| - name: Upload Frontend build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: frontend-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| path: apps/frontend/build/client | ||
| build-mcp-server: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| outputs: | ||
| artifact-name: mcp-server-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - name: Build MCP Server | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx build mcp-server | ||
| - name: Test MCP Server | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx test mcp-server | ||
| - run: cp tsconfig.base.effective.json dist/apps/mcp-server/. | ||
| - name: Upload MCP-Server build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: mcp-server-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| path: dist/apps/mcp-server/ | ||
| build-packages: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| outputs: | ||
| standard-samples-artifact: standard-samples-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - name: Build packages | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx run-many -t build -p packages/* | ||
| - name: Test packages | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx run-many -t test -p packages/* --passWithNoTests | ||
| - name: Upload standard samples artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: standard-samples-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| path: dist/packages/standards/samples/generated/ | ||
| if-no-files-found: ignore | ||
| build-cli: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| outputs: | ||
| artifact-name: cli-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| cli-executables-artifact: cli-executables-${{ steps.get-version.outputs.version }} | ||
| version: ${{ steps.get-version.outputs.version }} | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - name: Set up Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
| - name: Get package version | ||
| id: get-version | ||
| run: echo "version=$(node -p "require('./apps/cli/package.json').version")" >> $GITHUB_OUTPUT | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - name: Build CLI | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx build-publish packmind-cli | ||
| - name: Test CLI | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx test packmind-cli | ||
| - name: Upload CLI build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cli-dist-${{ vars.PACKMIND_EDITION }}-${{ github.run_number }}-${{ github.sha }} | ||
| path: dist/apps/cli/ | ||
| - name: Build CLI executables for all platforms | ||
| run: | | ||
| echo "📦 Building CLI executables with embedded WASM files..." | ||
| bun --version | ||
| bun run apps/cli/bun-build.ts --target=all | ||
| - name: List built executables | ||
| run: | | ||
| echo "Built executables (with embedded WASM files):" | ||
| ls -lh dist/apps/cli-executables/ | ||
| - name: Test executables | ||
| run: | | ||
| node dist/apps/cli/main.cjs --version | ||
| ./dist/apps/cli-executables/packmind-cli-linux-x64 --version | ||
| - name: Upload CLI executables | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cli-executables-${{ steps.get-version.outputs.version }} | ||
| path: | | ||
| dist/apps/cli-executables/packmind-cli-linux-x64 | ||
| dist/apps/cli-executables/packmind-cli-linux-arm64 | ||
| dist/apps/cli-executables/packmind-cli-macos-arm64 | ||
| dist/apps/cli-executables/packmind-cli-windows-x64.exe | ||
| retention-days: 30 | ||
| cli-e2e-tests: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - run: npm ci | ||
| - name: Generate tsconfig | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| run: node scripts/select-tsconfig.mjs | ||
| - run: ./node_modules/.bin/nx run packmind-cli:build | ||
| - name: Fix CLI artifacts permissions | ||
| run: | | ||
| chmod +x dist/apps/cli/main.cjs || true | ||
| chmod -R +r dist/apps/cli/ | ||
| ls -la dist/apps/cli/ | ||
| - name: Start docker compose for CLI E2E tests | ||
| uses: nick-fields/retry@v3 | ||
| with: | ||
| timeout_minutes: 15 | ||
| max_attempts: 3 | ||
| retry_wait_seconds: 10 | ||
| command: | | ||
| echo "Starting docker compose with COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" | ||
| echo "Docker version:" | ||
| docker --version | ||
| docker compose version | ||
| echo "Starting containers..." | ||
| docker compose up -d --wait --wait-timeout 300 | ||
| echo "Docker compose up completed. Container status:" | ||
| docker compose ps -a | ||
| docker ps -a --format 'table {{.Names}}\t{{.Status}}' | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }} | ||
| CI: 'true' | ||
| APP_WEB_URL: http://localhost:4200 | ||
| timeout 60 bash -c 'until curl -f http://localhost:4200/api/health > /dev/null 2>&1; do sleep 2; done' | ||
| - name: Run CLI E2E tests | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| NODE_OPTIONS: '--max-old-space-size=16384' | ||
| run: ./node_modules/.bin/nx test cli-e2e-tests | ||
| - name: Collect Docker container logs | ||
| if: always() | ||
| env: | ||
| COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }} | ||
| run: | | ||
| mkdir -p docker-logs-cli-e2e | ||
| echo "Looking for containers with prefix: ${COMPOSE_PROJECT_NAME}" | ||
| docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || echo "No containers found" | ||
| for container in $(docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || true); do | ||
| echo "Collecting logs for $container..." | ||
| docker logs "$container" > "docker-logs-cli-e2e/${container}.log" 2>&1 || true | ||
| done | ||
| echo "Collected logs:" | ||
| ls -la docker-logs-cli-e2e/ || echo "No logs collected" | ||
| - name: Upload Docker logs | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: docker-logs-cli-e2e-${{ github.run_number }}-${{ github.sha }} | ||
| path: docker-logs-cli-e2e/ | ||
| if-no-files-found: ignore | ||
| - name: Cleanup Docker containers | ||
| if: always() | ||
| env: | ||
| COMPOSE_PROJECT_NAME: cli-e2e-${{ github.run_number }} | ||
| run: docker compose down -v --remove-orphans | ||
| e2e-tests: | ||
| runs-on: ${{ vars.ACTION_RUNNER_TAG || 'self-hosted' }} | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| matrix: | ||
| node-version: ['${{ inputs.node-version }}'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Start E2E test environment | ||
| uses: nick-fields/retry@v3 | ||
| with: | ||
| timeout_minutes: 15 | ||
| max_attempts: 3 | ||
| retry_wait_seconds: 10 | ||
| command: | | ||
| echo "Starting docker compose with COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" | ||
| echo "Docker version:" | ||
| docker --version | ||
| docker compose version | ||
| echo "Starting containers..." | ||
| docker compose --profile=e2e up -d --wait-timeout 300 | ||
| echo "Docker compose up completed. Container status:" | ||
| docker compose --profile=e2e ps -a | ||
| docker ps -a --format 'table {{.Names}}\t{{.Status}}' | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| COMPOSE_PROJECT_NAME: ci-${{ github.run_number }} | ||
| CI: 'true' | ||
| APP_WEB_URL: http://frontend:4200 | ||
| - name: Wait for E2E tests to complete | ||
| env: | ||
| PACKMIND_EDITION: ${{ vars.PACKMIND_EDITION }} | ||
| COMPOSE_PROJECT_NAME: ci-${{ github.run_number }} | ||
| run: ./scripts/wait-for-e2e-tests.sh | ||
| - name: Upload Playwright report | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: playwright-report-${{ github.run_number }}-${{ github.sha }} | ||
| path: apps/e2e-tests/playwright-report/ | ||
| if-no-files-found: ignore | ||
| - name: Collect Docker container logs | ||
| if: always() | ||
| env: | ||
| COMPOSE_PROJECT_NAME: ci-${{ github.run_number }} | ||
| run: | | ||
| mkdir -p docker-logs | ||
| echo "Looking for containers with prefix: ${COMPOSE_PROJECT_NAME}" | ||
| docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || echo "No containers found" | ||
| for container in $(docker ps -a --format '{{.Names}}' | grep "^${COMPOSE_PROJECT_NAME}" || true); do | ||
| echo "Collecting logs for $container..." | ||
| docker logs "$container" > "docker-logs/${container}.log" 2>&1 || true | ||
| done | ||
| echo "Collected logs:" | ||
| ls -la docker-logs/ || echo "No logs collected" | ||
| - name: Upload Docker logs | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: docker-logs-${{ github.run_number }}-${{ github.sha }} | ||
| path: docker-logs/ | ||
| if-no-files-found: ignore | ||
| - name: Cleanup Docker containers | ||
| if: always() | ||
| env: | ||
| COMPOSE_PROJECT_NAME: ci-${{ github.run_number }} | ||
| run: docker compose --profile=e2e down -v --remove-orphans | ||