Skip to content
Merged
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
74 changes: 74 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Integration Tests

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 30

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: chenaikit
POSTGRES_PASSWORD: testpass
POSTGRES_DB: chenaikit_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm build

- name: Run integration tests
env:
DATABASE_URL: postgresql://chenaikit:testpass@localhost:5432/chenaikit_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-secret-key
NODE_ENV: test
run: |
cd tests/integration
pnpm test --coverage

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: ./tests/integration/coverage/lcov.info
Comment on lines +65 to +72
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Coverage upload path mismatch will cause silent failure.

The workflow changes to tests/integration before running tests (line 66-67), so Jest outputs coverage to ./coverage/ relative to that directory. However, the Codecov upload (line 72) expects ./tests/integration/coverage/lcov.info relative to the repo root, which resolves to tests/integration/tests/integration/coverage/lcov.info.

Either add coverageDirectory to jest.config.js or fix the upload path.

🛠️ Option 1: Fix upload path
      - name: Upload coverage
-        uses: codecov/codecov-action@v3
+        uses: codecov/codecov-action@v4
        with:
-          files: ./tests/integration/coverage/lcov.info
+          files: ./coverage/lcov.info
          flags: integration
          name: integration-tests
+        working-directory: tests/integration
🛠️ Option 2: Add coverageDirectory to jest.config.js

In tests/integration/jest.config.js:

module.exports = {
  // ...existing config
  coverageDirectory: '<rootDir>/coverage',
};

Then update the workflow to run from repo root or adjust path accordingly.

🧰 Tools
🪛 actionlint (1.7.11)

[error] 70-70: the runner of "codecov/codecov-action@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/integration-tests.yml around lines 65 - 72, The workflow
uploads coverage from the wrong path because the job cd's into tests/integration
before running tests; fix by either updating the Codecov step path to match the
actual output (e.g., reference ./coverage/lcov.info from tests/integration) or
set coverageDirectory in tests/integration/jest.config.js (add
coverageDirectory: '<rootDir>/coverage') and then adjust the upload path or run
the upload from the repo root; modify the Codecov action input (files) or the
jest config accordingly so the uploaded path matches the generated lcov.info.

flags: integration
name: integration-tests
5 changes: 3 additions & 2 deletions backend/src/services/apiKeyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,12 @@ export class ApiKeyService {
requestsThisMonth,
averageResponseTime: avgResponseTime._avg.responseTime || 0,
successRate,
topEndpoints: endpointCounts.map(item => ({
topEndpoints: endpointCounts.map((item: any) => ({
endpoint: item.endpoint,
count: item._count,
})),
dailyUsage: dailyCounts.map(item => ({
<<<<<<< HEAD
dailyUsage: (dailyCounts as any[]).map((item: any) => ({
date: item.date,
requests: Number(item.requests),
})),
Comment on lines +328 to 332
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for unresolved merge conflict markers

rg -n "^(<<<<<<<|=======|>>>>>>>)" --type ts

Repository: nexoraorg/chenaikit

Length of output: 117


🏁 Script executed:

# Read the file around the merge conflict marker
sed -n '320,340p' backend/src/services/apiKeyService.ts | cat -n

Repository: nexoraorg/chenaikit

Length of output: 813


🏁 Script executed:

# Search for merge markers in any position
rg "(<<<<<<<|=======|>>>>>>>)" backend/src/services/apiKeyService.ts -n

Repository: nexoraorg/chenaikit

Length of output: 79


🏁 Script executed:

# Check the full file to find if there are other merge markers
rg "^(=======|>>>>>>>)" backend/src/services/apiKeyService.ts -n

# Also check file length to understand scope
wc -l backend/src/services/apiKeyService.ts

Repository: nexoraorg/chenaikit

Length of output: 104


🏁 Script executed:

# Get more context around the marker and check what follows
sed -n '325,340p' backend/src/services/apiKeyService.ts | cat -n

Repository: nexoraorg/chenaikit

Length of output: 579


Critical: Unresolved merge conflict marker at line 328 must be removed.

The file contains an incomplete Git merge conflict marker (<<<<<<< HEAD at line 328) that will prevent compilation. The corresponding closing markers are missing, making this a malformed conflict that blocks builds.

🐛 Fix: Remove merge conflict marker
-<<<<<<< HEAD
         dailyUsage: (dailyCounts as any[]).map((item: any) => ({
           date: item.date,
           requests: Number(item.requests),
         })),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<<<<<<< HEAD
dailyUsage: (dailyCounts as any[]).map((item: any) => ({
date: item.date,
requests: Number(item.requests),
})),
dailyUsage: (dailyCounts as any[]).map((item: any) => ({
date: item.date,
requests: Number(item.requests),
})),
🧰 Tools
🪛 Biome (2.4.6)

[error] 328-328: Expected a property, a shorthand property, a getter, a setter, or a method but instead found '<<'.

(parse)


[error] 328-328: Expected an expression but instead found '<<'.

(parse)


[error] 328-328: Expected an expression but instead found '<<'.

(parse)


[error] 329-329: expected > but instead found dailyUsage

(parse)


[error] 329-329: Expected a semicolon or an implicit semicolon after a statement, but found none

(parse)


[error] 331-331: Expected a semicolon or an implicit semicolon after a statement, but found none

(parse)


[error] 332-332: Expected a statement but instead found ')),'.

(parse)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/services/apiKeyService.ts` around lines 328 - 332, Remove the
leftover merge conflict marker `<<<<<<< HEAD` (and any stray conflict markers
like `=======` or `>>>>>>>`) from the block that constructs dailyUsage; ensure
the dailyUsage mapping over dailyCounts remains intact and returns objects with
date and requests (see symbols dailyUsage and dailyCounts) so the code compiles
cleanly.

Expand Down
10 changes: 5 additions & 5 deletions backend/src/services/usageTrackingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ export class UsageTrackingService {
averageResponseTime: avgResponseTime._avg.responseTime || 0,
successRate,
errorRate,
topEndpoints: endpointStats.map(item => ({
topEndpoints: endpointStats.map((item: any) => ({
endpoint: item.endpoint,
count: item._count,
avgResponseTime: item._avg.responseTime || 0,
})),
hourlyStats: (hourlyStats as any[]).map(item => ({
hourlyStats: (hourlyStats as any[]).map((item: any) => ({
hour: item.hour,
requests: Number(item.requests),
})),
statusDistribution: statusDistribution.reduce((acc, item) => {
statusDistribution: statusDistribution.reduce((acc: any, item: any) => {
acc[item.statusCode.toString()] = item._count;
return acc;
}, {} as Record<string, number>),
Expand Down Expand Up @@ -237,12 +237,12 @@ export class UsageTrackingService {
totalRequests,
averageResponseTime: avgResponseTime._avg.responseTime || 0,
successRate,
endpointBreakdown: endpointBreakdown.map(item => ({
endpointBreakdown: endpointBreakdown.map((item: any) => ({
endpoint: item.endpoint,
count: item._count,
avgResponseTime: item._avg.responseTime || 0,
})),
dailyUsage: (dailyUsage as any[]).map(item => ({
dailyUsage: (dailyUsage as any[]).map((item: any) => ({
date: item.date,
requests: Number(item.requests),
})),
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"test:cli": "cd packages/cli && jest --coverage",
"test:backend": "cd backend && jest --coverage",
"test:frontend": "cd frontend && react-scripts test --coverage --watchAll=false",
"test:integration": "cd backend && jest --config=jest.integration.config.js",
"test:integration": "cd tests/integration && pnpm test",
"test:integration:ci": "cd tests/integration && ./run-tests.sh",
"test:watch": "jest --watch",
"test:ci": "jest --coverage --ci --watchAll=false --maxWorkers=2",
"test:unit": "jest --testPathIgnorePatterns=integration",
"test:all": "pnpm test && pnpm test:backend && pnpm test:frontend && pnpm test:integration",
Comment on lines +19 to +24
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check CI workflow artifact paths
rg -n 'coverage' .github/workflows/ci.yml

Repository: nexoraorg/chenaikit

Length of output: 296


🏁 Script executed:

#!/bin/bash
# Get full context of CI workflow around coverage references
head -n 100 .github/workflows/ci.yml | tail -n 70

Repository: nexoraorg/chenaikit

Length of output: 1681


🏁 Script executed:

#!/bin/bash
# Check what test:integration script does
cat tests/integration/run-tests.sh

Repository: nexoraorg/chenaikit

Length of output: 1484


🏁 Script executed:

#!/bin/bash
# Check if integration tests generate coverage
rg -A 5 -B 5 'backend/coverage' .github/workflows/ci.yml

Repository: nexoraorg/chenaikit

Length of output: 309


Fix CI artifact path for integration test coverage.

The integration-test job uploads artifacts from backend/coverage/, but since the integration tests run from tests/integration/ (via cd tests/integration && pnpm test), any generated coverage will be in tests/integration/coverage/, not backend/coverage/. Update the upload path to correctly capture integration test coverage artifacts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 19 - 24, The CI is uploading integration coverage
from the wrong directory; update the integration-test job to upload artifacts
from tests/integration/coverage/ (or change any configured upload path
referencing backend/coverage/) so it matches the location produced by the
package.json scripts "test:integration" and "test:integration:ci"; ensure the
upload artifact path exactly points to tests/integration/coverage/** to capture
the integration test coverage files.

"coverage": "jest --coverage && open coverage/lcov-report/index.html",
"coverage:report": "jest --coverage --coverageReporters=text-summary",
"lint": "pnpm -r lint",
Expand Down
31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ packages:
- 'packages/*'
- 'examples/*'
- 'tests/*'
- 'tests/integration'
- 'backend'
- 'frontend'
14 changes: 14 additions & 0 deletions tests/integration/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Test environment variables
DATABASE_URL=postgresql://chenaikit:testpass@localhost:5432/chenaikit_test
REDIS_URL=redis://localhost:6379
JWT_SECRET=test-secret-key-do-not-use-in-production
NODE_ENV=test
API_URL=http://localhost:3000

# Stellar testnet
STELLAR_NETWORK=testnet
HORIZON_URL=https://horizon-testnet.stellar.org

# AI API Keys (optional - tests will use mocks if not provided)
# OPENAI_API_KEY=your-test-key
# HUGGINGFACE_API_KEY=your-test-key
26 changes: 26 additions & 0 deletions tests/integration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dependencies
node_modules/
pnpm-lock.yaml

# Test output
coverage/
*.log

# Environment
.env
.env.local
.env.test

# Build output
dist/
*.tsbuildinfo

# IDE
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db
Loading