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
3 changes: 3 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/chaindexing_test
NODE_ENV=test
SETUP_TEST_DB=true
46 changes: 46 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
node: true,
es6: true,
jest: true,
},
rules: {
// TypeScript specific rules - more lenient for development
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-var-requires': 'error',

// General ESLint rules - more lenient for development
'no-console': 'off', // Allow console.log for debugging
'no-debugger': 'error',
'no-duplicate-imports': 'warn',
'no-unused-expressions': 'warn',
'prefer-const': 'warn',
'no-var': 'error',
'no-prototype-builtins': 'warn',

// Prettier integration
'prettier/prettier': 'error',
},
ignorePatterns: [
'node_modules/',
'dist/',
'build/',
'target/',
'coverage/',
'*.js',
'!jest.config.js',
'!.eslintrc.js',
],
};
266 changes: 266 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
types: [opened, synchronize, reopened]
workflow_dispatch:
schedule: [cron: '44 4 * * 6']

permissions:
contents: read

env:
NODE_VERSION: '20'
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/chaindexing_test

jobs:
lint:
name: Lint and Format
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint:strict

- name: Check Prettier formatting
run: npm run format:check

- name: TypeScript type checking
run: npm run type-check

test-unit:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit

test-integration:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: chaindexing_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Setup test database
run: npm run setup-db

- name: Run integration tests
run: npm run test:integration

test-coverage:
name: Test Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: chaindexing_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Setup test database
run: npm run setup-db

- name: Run tests with coverage
run: npm run test:coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: false

build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
**/dist/
**/build/
retention-days: 7

outdated:
name: Check Outdated Dependencies
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true # Don't fail CI if dependencies are outdated
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check for outdated dependencies
run: npm run outdated

matrix-test:
name: Test Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
timeout-minutes: 30
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
node-version: ['18', '20', '21']
experimental: [false]
include:
- node-version: '22'
experimental: true

services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: chaindexing_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Setup test database
run: npm run setup-db

- name: Run unit tests
run: npm run test:unit

- name: Run integration tests
run: npm run test:integration

# Summary job that depends on all other jobs
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [lint, test-unit, test-integration, build]
if: always()
steps:
- name: Check all jobs
run: |
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "Lint job failed"
exit 1
fi
if [[ "${{ needs.test-unit.result }}" != "success" ]]; then
echo "Unit tests failed"
exit 1
fi
if [[ "${{ needs.test-integration.result }}" != "success" ]]; then
echo "Integration tests failed"
exit 1
fi
if [[ "${{ needs.build.result }}" != "success" ]]; then
echo "Build failed"
exit 1
fi
echo "All required jobs passed!"
11 changes: 8 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"proseWrap": "always",
"tabWidth": 2,
"useTabs": false,
"trailingComma": "none",
"bracketSpacing": true,
"semi": true
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf",
"quoteProps": "as-needed",
"jsxSingleQuote": true,
"embeddedLanguageFormatting": "auto"
}
Loading
Loading