Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
SAINIAbhishek committed Sep 13, 2024
1 parent 2901511 commit 73862bd
Showing 1 changed file with 25 additions and 39 deletions.
64 changes: 25 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
# Step: Cache and Install Frontend Dependencies
frontend:
npm-frontend:
uses: SAINIAbhishek/shared-workflows/.github/workflows/cache-install-dependencies.yml@main
with:
node-version: "20.17.0"
Expand All @@ -21,7 +21,7 @@ jobs:
working-directory: "frontend"

# Step: Cache and Install Server Dependencies
server:
npm-server:
uses: SAINIAbhishek/shared-workflows/.github/workflows/cache-install-dependencies.yml@main
with:
node-version: "20.17.0"
Expand All @@ -32,7 +32,7 @@ jobs:

# Step: Lint the code
lint:
needs: [frontend, server] # Wait for dependencies to be installed before linting
needs: [npm-frontend, npm-server] # Wait for dependencies to be installed before linting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down Expand Up @@ -63,8 +63,8 @@ jobs:
working-directory: ./frontend

# Step: Formatting job
format:
needs: [frontend, server] # Dependencies must be installed before formatting
format-frontend:
needs: [npm-frontend] # Dependencies must be installed before formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand All @@ -82,43 +82,29 @@ jobs:
run: npm run prettier
working-directory: ./frontend

# Step: Security audit for both server and frontend
security-audit:
needs: [frontend, server] # Run only after tests have passed
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

# Restore Server Node.js Modules cache
- name: Restore Server Node.js Modules Cache
uses: actions/cache@v3
with:
path: server/node_modules
key: ${{ runner.os }}-server-${{ hashFiles('server/package-lock.json') }}

# Restore Frontend Node.js Modules cache
- name: Restore Frontend Node.js Modules Cache
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-frontend-${{ hashFiles('frontend/package-lock.json') }}

# Run npm audit for server
- name: Run Server npm audit
run: npm run audit
working-directory: ./server
continue-on-error: true
# Step: Security audit Frontend
security-frontend:
uses: SAINIAbhishek/shared-workflows/.github/workflows/security-audit.yml@main
with:
node-version: "20.17.0"
lock-file: "frontend/package-lock.json"
cache-path: "frontend/node_modules"
cache-key-prefix: "frontend"
working-directory: "frontend"

# Run npm audit for frontend
- name: Run Frontend npm audit
run: npm run audit
working-directory: ./frontend
continue-on-error: true
# Step: Security audit Server
security-server:
uses: SAINIAbhishek/shared-workflows/.github/workflows/security-audit.yml@main
with:
node-version: "20.17.0"
lock-file: "server/package-lock.json"
cache-path: "server/node_modules"
cache-key-prefix: "server"
working-directory: "server"

# Step: Run unit tests
test-frontend:
needs: [lint, format, security-audit]
needs: [lint, format-frontend, security-frontend]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down Expand Up @@ -170,7 +156,7 @@ jobs:

# Step: Build the Server project
build-server:
needs: [lint, format, security-audit]
needs: [lint, security-server]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down

0 comments on commit 73862bd

Please sign in to comment.