Skip to content

Commit dac4ee6

Browse files
committed
Add ESLint configuration and refactor CI workflow to enhance code quality checks. Introduce a new CI/CD pipeline with dedicated jobs for code quality, security audits, and integration tests, while removing the old test workflow for better organization.
1 parent 1d300b4 commit dac4ee6

File tree

6 files changed

+133
-177
lines changed

6 files changed

+133
-177
lines changed

.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
parserOptions: {
4+
ecmaVersion: 2020,
5+
sourceType: "module",
6+
},
7+
plugins: ["@typescript-eslint"],
8+
extends: ["eslint:recommended"],
9+
root: true,
10+
env: {
11+
node: true,
12+
es6: true,
13+
},
14+
ignorePatterns: ["dist/", "node_modules/", "coverage/", "*.js", "*.d.ts"],
15+
rules: {
16+
// General ESLint rules
17+
"no-console": "warn",
18+
"prefer-const": "error",
19+
"no-var": "error",
20+
"object-shorthand": "error",
21+
"prefer-template": "error",
22+
"no-unused-vars": "off", // Turn off base rule
23+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
24+
},
25+
};

.github/workflows/ci.yml

Lines changed: 104 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
1-
name: CI
1+
name: CI/CD Pipeline
22

33
on:
44
push:
55
branches: [main, develop]
66
pull_request:
77
branches: [main, develop]
8+
schedule:
9+
# Run tests daily at 2 AM UTC
10+
- cron: "0 2 * * *"
11+
12+
env:
13+
NODE_ENV: test
814

915
jobs:
16+
code-quality:
17+
name: Code Quality & Linting
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js 20.x
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20.x
28+
cache: "npm"
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run ESLint
34+
run: npm run lint
35+
36+
- name: Check TypeScript compilation
37+
run: npx tsc --noEmit
38+
1039
test:
40+
name: Tests (Node ${{ matrix.node-version }})
1141
runs-on: ubuntu-latest
42+
needs: code-quality
1243

1344
strategy:
45+
fail-fast: false
1446
matrix:
1547
node-version: [18.x, 20.x, 22.x]
1648

1749
steps:
18-
- name: Checkout code
50+
- name: Checkout repository
1951
uses: actions/checkout@v4
2052

21-
- name: Use Node.js ${{ matrix.node-version }}
53+
- name: Setup Node.js ${{ matrix.node-version }}
2254
uses: actions/setup-node@v4
2355
with:
2456
node-version: ${{ matrix.node-version }}
@@ -27,32 +59,39 @@ jobs:
2759
- name: Install dependencies
2860
run: npm ci
2961

30-
- name: Run linter
31-
run: npm run lint
62+
- name: Run unit tests
63+
run: npm test
3264

33-
- name: Run tests
65+
- name: Generate coverage report
66+
if: matrix.node-version == '20.x'
3467
run: npm run test:coverage
3568

36-
- name: Build project
37-
run: npm run build
38-
39-
- name: Upload coverage reports to Codecov
69+
- name: Upload coverage to Codecov
4070
if: matrix.node-version == '20.x'
4171
uses: codecov/codecov-action@v3
4272
with:
4373
file: ./coverage/lcov.info
4474
flags: unittests
45-
name: codecov-umbrella
75+
name: unit-tests
4676
fail_ci_if_error: false
4777

48-
lint:
78+
- name: Archive coverage artifacts
79+
if: matrix.node-version == '20.x'
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: coverage-report
83+
path: coverage/
84+
85+
build:
86+
name: Build & Verify
4987
runs-on: ubuntu-latest
88+
needs: code-quality
5089

5190
steps:
52-
- name: Checkout code
91+
- name: Checkout repository
5392
uses: actions/checkout@v4
5493

55-
- name: Use Node.js 20.x
94+
- name: Setup Node.js 20.x
5695
uses: actions/setup-node@v4
5796
with:
5897
node-version: 20.x
@@ -61,17 +100,26 @@ jobs:
61100
- name: Install dependencies
62101
run: npm ci
63102

64-
- name: Run linter
65-
run: npm run lint
103+
- name: Build project
104+
run: npm run build
66105

67-
build:
106+
- name: Verify build artifacts
107+
run: |
108+
ls -la dist/
109+
test -f dist/index.js || (echo "Missing dist/index.js" && exit 1)
110+
test -f dist/index.d.ts || (echo "Missing dist/index.d.ts" && exit 1)
111+
echo "Build artifacts verified successfully"
112+
113+
integration-tests:
114+
name: Integration Tests
68115
runs-on: ubuntu-latest
116+
needs: [test, build]
69117

70118
steps:
71-
- name: Checkout code
119+
- name: Checkout repository
72120
uses: actions/checkout@v4
73121

74-
- name: Use Node.js 20.x
122+
- name: Setup Node.js 20.x
75123
uses: actions/setup-node@v4
76124
with:
77125
node-version: 20.x
@@ -80,11 +128,44 @@ jobs:
80128
- name: Install dependencies
81129
run: npm ci
82130

131+
- name: Create test environment file
132+
run: |
133+
cp .env.example .env
134+
echo "NODE_ENV=test" >> .env
135+
83136
- name: Build project
84137
run: npm run build
85138

86-
- name: Check build artifacts
139+
- name: Run integration tests
140+
run: npm test -- --testPathPattern=integration
141+
continue-on-error: true
142+
143+
- name: Run demo scripts (dry run)
87144
run: |
88-
ls -la dist/
89-
test -f dist/index.js
90-
test -f dist/index.d.ts
145+
echo "Testing demo scripts..."
146+
# Add any demo script tests here if needed
147+
echo "Demo scripts validation completed"
148+
149+
security-audit:
150+
name: Security & Dependencies
151+
runs-on: ubuntu-latest
152+
needs: code-quality
153+
154+
steps:
155+
- name: Checkout repository
156+
uses: actions/checkout@v4
157+
158+
- name: Setup Node.js 20.x
159+
uses: actions/setup-node@v4
160+
with:
161+
node-version: 20.x
162+
cache: "npm"
163+
164+
- name: Install dependencies
165+
run: npm ci
166+
167+
- name: Run security audit
168+
run: npm audit --audit-level=moderate
169+
170+
- name: Check for outdated packages
171+
run: npm outdated || true

.github/workflows/test.yml

Lines changed: 0 additions & 150 deletions
This file was deleted.

src/operations/base.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TidalApiClient } from '../api/client';
22
import { BulkOperationConfig, BulkResult, DryRunResult, ValidationResult } from '../types/bulk';
33
import { BulkOperationsService } from '../api/bulk';
4-
import { InputValidator } from '../utils/validation';
54
import { Logger, LogLevel } from '../utils/logger';
65

76
export abstract class BaseBulkOperation<T> {
@@ -205,7 +204,7 @@ export abstract class BaseBulkOperation<T> {
205204
const extracted: any = {};
206205

207206
for (const field of fields) {
208-
if (resourceAny.hasOwnProperty(field)) {
207+
if (Object.prototype.hasOwnProperty.call(resourceAny, field)) {
209208
extracted[field] = resourceAny[field];
210209
}
211210
}

src/utils/batch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export class BatchProcessor<T> {
6868
): Promise<BatchResult<T>> {
6969
let attempt = 0;
7070
let remainingItems = [...items];
71-
let allSuccessful: T[] = [];
72-
let allFailed: Array<{ item: T; error: string }> = [];
71+
const allSuccessful: T[] = [];
72+
const allFailed: Array<{ item: T; error: string }> = [];
7373

7474
while (attempt <= retries) {
7575
try {

0 commit comments

Comments
 (0)