11# =============================================================================
2- # TelemetryFlow Core - CI Workflow
2+ # TelemetryFlow Core - CI Workflow (Simplified with Makefile)
33# =============================================================================
44#
55# TelemetryFlow Core - Identity and Access Management Service
66# Copyright (c) 2024-2026 DevOpsCorner Indonesia. All rights reserved.
77#
8- # This workflow runs tests, linting, and module standardization validation:
9- # - Unit tests with coverage
10- # - Integration tests
11- # - E2E tests
12- # - Linting with ESLint
13- # - Module standardization validation
14- # - Security scanning
8+ # This workflow uses Makefile targets to simplify CI operations:
9+ # - Standardized commands across local development and CI
10+ # - Consistent behavior between environments
11+ # - Easier maintenance and debugging
1512#
1613# =============================================================================
1714
@@ -114,49 +111,10 @@ jobs:
114111 ${{ runner.os }}-pnpm-store-
115112
116113 - name : Install dependencies
117- run : pnpm install --frozen-lockfile
114+ run : make ci-install
118115
119116 - name : Validate specification structure
120- run : |
121- echo "Validating module standardization specifications..."
122-
123- # Check if .kiro/specs directory exists
124- if [ ! -d ".kiro/specs" ]; then
125- echo "❌ .kiro/specs directory not found"
126- exit 1
127- fi
128-
129- # Validate each module specification
130- MODULES=("iam-module-standardization" "audit-module-standardization" "auth-module-standardization" "cache-module-standardization")
131-
132- for module in "${MODULES[@]}"; do
133- echo "Validating $module..."
134-
135- SPEC_DIR=".kiro/specs/$module"
136- if [ ! -d "$SPEC_DIR" ]; then
137- echo "❌ Module specification directory not found: $SPEC_DIR"
138- exit 1
139- fi
140-
141- # Check required files
142- REQUIRED_FILES=("requirements.md" "design.md" "tasks.md")
143- for file in "${REQUIRED_FILES[@]}"; do
144- if [ ! -f "$SPEC_DIR/$file" ]; then
145- echo "❌ Required file not found: $SPEC_DIR/$file"
146- exit 1
147- fi
148-
149- # Check file size (should not be empty)
150- if [ ! -s "$SPEC_DIR/$file" ]; then
151- echo "❌ File is empty: $SPEC_DIR/$file"
152- exit 1
153- fi
154- done
155-
156- echo "✅ $module specification is valid"
157- done
158-
159- echo "✅ All module specifications are valid"
117+ run : make ci-validate
160118
161119 - name : Validate EARS patterns in requirements
162120 run : |
@@ -248,13 +206,13 @@ jobs:
248206 ${{ runner.os }}-pnpm-store-
249207
250208 - name : Install dependencies
251- run : pnpm install --frozen-lockfile
209+ run : make ci-install
252210
253211 - name : Run ESLint
254- run : pnpm lint
212+ run : make ci- lint
255213
256214 - name : Check TypeScript compilation
257- run : pnpm build
215+ run : make ci- build
258216
259217 - name : Check for circular dependencies
260218 run : |
@@ -296,19 +254,12 @@ jobs:
296254 ${{ runner.os }}-pnpm-store-
297255
298256 - name : Install dependencies
299- run : pnpm install --frozen-lockfile
257+ run : make ci-install
300258
301259 # TODO: Fix Jest configuration issues with module resolution
302260 # Currently allowing tests to fail to unblock CI pipeline
303261 - name : Run unit tests with coverage
304- run : |
305- echo "Running tests with coverage..."
306- pnpm test:cov || {
307- echo "⚠️ Tests failed due to Jest module resolution issues"
308- echo "This is a known issue that needs to be fixed in a follow-up PR"
309- echo "The build and linting are working correctly"
310- exit 0
311- }
262+ run : make ci-test
312263
313264 - name : Check coverage thresholds
314265 run : |
@@ -404,7 +355,7 @@ jobs:
404355 ${{ runner.os }}-pnpm-store-
405356
406357 - name : Install dependencies
407- run : pnpm install --frozen-lockfile
358+ run : make ci-install
408359
409360 - name : Wait for services
410361 run : |
@@ -423,29 +374,11 @@ jobs:
423374 echo "ClickHouse is ready!"
424375
425376 - name : Run database migrations
426- run : |
427- export NODE_ENV=test
428- export POSTGRES_HOST=localhost
429- export POSTGRES_PORT=5432
430- export POSTGRES_DB=telemetryflow_test_db
431- export POSTGRES_USERNAME=postgres
432- export POSTGRES_PASSWORD=telemetryflow123
433- export CLICKHOUSE_HOST=localhost
434- export CLICKHOUSE_PORT=8123
435- export CLICKHOUSE_DB=telemetryflow_test_db
436- export CLICKHOUSE_PASSWORD=telemetryflow123
437-
438- pnpm db:migrate
377+ run : make db-migrate
439378
440379 # TODO: Fix Jest configuration for integration tests
441380 - name : Run integration tests
442- run : |
443- echo "Running integration tests..."
444- pnpm test --testPathPattern=integration || {
445- echo "⚠️ Integration tests failed due to Jest configuration issues"
446- echo "Continuing CI pipeline - this needs to be fixed"
447- exit 0
448- }
381+ run : make test || echo "⚠️ Integration tests failed due to Jest configuration issues"
449382
450383 # ===========================================================================
451384 # E2E Tests (Optional)
@@ -508,10 +441,10 @@ jobs:
508441 ${{ runner.os }}-pnpm-store-
509442
510443 - name : Install dependencies
511- run : pnpm install --frozen-lockfile
444+ run : make ci-install
512445
513446 - name : Build application
514- run : pnpm build
447+ run : make ci- build
515448
516449 - name : Start application
517450 run : |
@@ -526,15 +459,15 @@ jobs:
526459 export CLICKHOUSE_DB=telemetryflow_e2e_db
527460 export CLICKHOUSE_PASSWORD=telemetryflow123
528461
529- pnpm db:migrate:seed
462+ make db-setup
530463 pnpm start &
531464
532465 # Wait for application to start
533466 sleep 10
534467 curl -f http://localhost:3000/health
535468
536469 - name : Run BDD tests
537- run : pnpm test: bdd
470+ run : make test- bdd
538471
539472 # ===========================================================================
540473 # Build Verification
@@ -572,10 +505,10 @@ jobs:
572505 ${{ runner.os }}-pnpm-store-
573506
574507 - name : Install dependencies
575- run : pnpm install --frozen-lockfile
508+ run : make ci-install
576509
577510 - name : Build application
578- run : pnpm build
511+ run : make ci- build
579512
580513 - name : Verify build artifacts
581514 run : |
@@ -627,11 +560,10 @@ jobs:
627560 ${{ runner.os }}-pnpm-store-
628561
629562 - name : Install dependencies
630- run : pnpm install --frozen-lockfile
563+ run : make ci-install
631564
632565 - name : Run npm audit
633- run : pnpm audit --audit-level moderate
634- continue-on-error : true
566+ run : make ci-security
635567
636568 # TODO: Fix CodeQL configuration conflict
637569 # Currently disabled due to "advanced configurations cannot be processed when default setup is enabled"
0 commit comments