mirror of
https://github.com/Alvin-Zilverstand/narrow_casting_system.git
synced 2026-03-06 13:24:46 +01:00
🔧 Fix GitHub Actions CI/CD pipeline and improve project structure
- Split CI workflow into separate backend and admin testing jobs - Fix package-lock.json caching issues with proper cache paths - Update Docker configuration for better CI/CD integration - Improve root package.json with comprehensive npm scripts - Add proper build and test scripts for all components - Fix Dockerfile to work correctly with GitHub Actions - Add Docker BuildKit support for faster builds - Organize project structure with deployment folder This fixes the GitHub Actions error about missing package-lock.json and improves the overall CI/CD pipeline for the project.
This commit is contained in:
66
.github/workflows/ci.yml
vendored
66
.github/workflows/ci.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
test-backend:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
@@ -18,39 +18,62 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
- name: Setup Node.js ${{ matrix.node-version }} for Backend
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install backend dependencies
|
||||
run: |
|
||||
npm run setup:backend
|
||||
npm run setup:admin
|
||||
cd backend
|
||||
npm ci
|
||||
|
||||
- name: Run system tests
|
||||
- name: Run backend tests
|
||||
run: |
|
||||
cd backend
|
||||
npm start &
|
||||
sleep 5
|
||||
cd ..
|
||||
node test_system.js
|
||||
pkill -f "node server.js"
|
||||
pkill -f "node server.js" || true
|
||||
|
||||
- name: Run linting (if configured)
|
||||
run: |
|
||||
echo "Linting not configured yet"
|
||||
|
||||
- name: Security audit
|
||||
- name: Security audit backend
|
||||
run: |
|
||||
cd backend
|
||||
npm audit --audit-level=high
|
||||
cd ../admin
|
||||
|
||||
test-admin:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18.x, 20.x]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }} for Admin
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: admin/package-lock.json
|
||||
|
||||
- name: Install admin dependencies
|
||||
run: |
|
||||
cd admin
|
||||
npm ci
|
||||
|
||||
- name: Security audit admin
|
||||
run: |
|
||||
cd admin
|
||||
npm audit --audit-level=high
|
||||
|
||||
build:
|
||||
needs: test
|
||||
needs: [test-backend, test-admin]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -61,23 +84,25 @@ jobs:
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install all dependencies
|
||||
run: npm run setup
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
||||
- name: Upload artifacts
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-files
|
||||
name: project-files
|
||||
path: |
|
||||
backend/
|
||||
admin/
|
||||
client/
|
||||
docs/
|
||||
deployment/
|
||||
package.json
|
||||
README.md
|
||||
!backend/node_modules/
|
||||
!admin/node_modules/
|
||||
|
||||
@@ -103,9 +128,12 @@ jobs:
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./deployment/docker/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
snowworld/narrowcasting:latest
|
||||
snowworld/narrowcasting:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-to: type=gha,mode=max
|
||||
env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
Reference in New Issue
Block a user