LibreChat/.github/workflows/agents-integration-tests.yml
Danny Avila fb1322401d
🧪 test: Restore Two Rotted Integration Suites and Run Every One in CI (#15866)
* 🧪 test: Restore Two Rotted packages/api Integration Suites

MCPReinitRecovery.integration.test.ts mocked @librechat/data-schemas down to
its logger, so all eight tests threw once MCPServersRegistry started calling
scopedCacheKey (#15028). The mock now spreads the real module under the logger
override; ServerConfigsDB stays mocked, so the suite still never touches Mongo.

secrets.integration.spec.ts drove langfuse.secretKey through the generic admin
config API, which has stripped the langfuse section since #14108 moved it to
the dedicated Langfuse connection API. The generic-write matrix drops that row,
and a langfuse block covers the current contract against a real Config
collection: the stored secret stays encrypted at rest, generic reads redact it,
generic patch, tombstone and field-delete writes leave it untouched, and a full
base-config replacement carries it forward.

* 👷 ci: Run Every packages/api Integration Suite in CI

test:ci excludes every path containing "integration.", but the jobs meant to
run those suites selected by folder: the cache workflow only
src/{cache,cluster,mcp,stream}, the agents workflow only
src/agents/*.integration.spec.ts. Thirteen suites ran in no job, including
every *.integration.test.ts.

test:integration selects *.integration.(spec|test).ts anywhere under src and
replaces test:agents-integration in the (renamed) Integration Tests workflow.
The cache scripts also accept .test.ts, stream selects by suffix alone, and
core picks up src/middleware. Every suite test:ci excludes is now selected by
exactly one CI script.

* 🧪 test: Read the Tool Snapshot in the Concurrent Reinit Simulation

The concurrent reinitialize test copied reinitMCPServer but still called
fetchTools(), which returns [] when tools/list fails. Concurrent reinspections
of a recovered server can each succeed, and a later write replaces the app
connection an earlier request was already handed, so that request's tools/list
fails. The test failed in 9 of 25 iterations on Linux, and in the first CI run
that included the suite. Since #14686 production reads the snapshot and keeps
cached tools when it is incomplete; the simulation now does the same, and still
requires every complete snapshot to list both tools and at least one to complete.

A deterministic test pins the property that tolerance relies on, without
depending on the race: a newer config write replaces the held app connection,
whose snapshot is then incomplete, while the replacement lists the real tools.
2026-09-12 16:20:22 -04:00

117 lines
4.7 KiB
YAML

name: Integration Tests
# Runs every packages/api `*.integration.spec.ts` / `*.integration.test.ts` suite (e.g. the
# durable HITL checkpointer and cross-replica subagent delivery against real MongoDB and
# Redis, the admin config secret registry against a real Config collection, MCP flows
# against in-process servers). `test:ci` deliberately excludes them, and the Redis-backed
# `*.cache_integration` / `*.stream_integration` suites run in cache-integration-tests.yml —
# without this job they run nowhere and their regressions guard nothing. Selection is by
# suffix, not folder, so a suite added anywhere under src is picked up.
on:
pull_request:
branches:
- main
- dev
- dev-staging
- release/*
# The suites build and consume data-provider and data-schemas and import
# across packages/api (the build-cache keys below hash all three src trees),
# so they must re-run on any of them.
paths:
- 'packages/api/src/**'
- 'packages/api/package.json'
- 'packages/data-provider/src/**'
- 'packages/data-provider/package.json'
- 'packages/data-schemas/src/**'
- 'packages/data-schemas/package.json'
- '.github/workflows/agents-integration-tests.yml'
- '!**.md'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
agents_integration_tests:
name: Integration Tests (MongoDB and Redis)
timeout-minutes: 20
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Use Node.js 24.16.0
uses: actions/setup-node@v5
with:
node-version: '24.16.0'
- name: Restore node_modules cache
id: cache-node-modules
uses: actions/cache@v5
with:
path: |
node_modules
api/node_modules
packages/api/node_modules
packages/data-provider/node_modules
packages/data-schemas/node_modules
key: node-modules-backend-${{ runner.os }}-24.16.0-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Restore data-provider build cache
id: cache-data-provider
uses: actions/cache@v5
with:
path: packages/data-provider/dist
key: build-data-provider-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'packages/data-provider/src/**', 'packages/data-provider/tsconfig*.json', 'packages/data-provider/tsdown.config.mjs', 'packages/data-provider/package.json') }}
- name: Build data-provider
if: steps.cache-data-provider.outputs.cache-hit != 'true'
run: npm run build:data-provider
- name: Restore data-schemas build cache
id: cache-data-schemas
uses: actions/cache@v5
with:
path: packages/data-schemas/dist
key: build-data-schemas-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'packages/data-schemas/src/**', 'packages/data-schemas/tsconfig*.json', 'packages/data-schemas/tsdown.config.mjs', 'packages/data-schemas/package.json', 'packages/data-provider/src/**', 'packages/data-provider/tsconfig*.json', 'packages/data-provider/tsdown.config.mjs', 'packages/data-provider/package.json') }}
- name: Build data-schemas
if: steps.cache-data-schemas.outputs.cache-hit != 'true'
run: npm run build:data-schemas
- name: Restore api build cache
id: cache-api
uses: actions/cache@v5
with:
path: packages/api/dist
key: build-api-${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json', 'packages/api/src/**', 'packages/api/tsconfig*.json', 'packages/api/tsdown.config.mjs', 'packages/api/package.json', 'packages/data-provider/src/**', 'packages/data-provider/tsconfig*.json', 'packages/data-provider/tsdown.config.mjs', 'packages/data-provider/package.json', 'packages/data-schemas/src/**', 'packages/data-schemas/tsconfig*.json', 'packages/data-schemas/tsdown.config.mjs', 'packages/data-schemas/package.json') }}
- name: Build api
if: steps.cache-api.outputs.cache-hit != 'true'
run: npm run build:api
- name: Run integration tests
working-directory: packages/api
env:
NODE_ENV: test
REDIS_URI: redis://127.0.0.1:6379
run: npm run test:integration