From 3744b64c1bc185e81572507926518fd158958fb1 Mon Sep 17 00:00:00 2001 From: Jenifer Date: Fri, 13 Nov 2026 18:01:52 +0530 Subject: [PATCH] Refactor CI workflow for clarity and structure Implements an automated Continuous Integration (CI) pipeline using GitHub Actions to maintain code quality and ensure application stability. Automatically installs dependencies and runs backend tests, frontend tests, and frontend production builds whenever changes are pushed to the main branch or submitted through pull requests. Uses Node.js 22, npm dependency caching, isolated jobs, execution time limits, and restricted repository permissions. Also supports manual workflow execution and automatically cancels outdated workflow runs to improve CI efficiency and reliability. --- .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c1086..7eef5f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,23 +1,37 @@ + name: CI on: push: - branches: [main] + branches: + - main + pull_request: + workflow_dispatch: + permissions: contents: read +# Cancel outdated workflow runs for the same branch or PR. +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: + + # Backend test job backend-tests: + name: Backend Tests runs-on: ubuntu-latest timeout-minutes: 10 + defaults: run: working-directory: backend steps: - - name: Get the code + - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false @@ -29,17 +43,21 @@ jobs: cache: npm cache-dependency-path: backend/package-lock.json - - name: Install dependencies + - name: Install backend dependencies run: npm ci - name: Run backend tests run: npm test + + # Frontend test job frontend-tests: + name: Frontend Tests runs-on: ubuntu-latest timeout-minutes: 10 + steps: - - name: Get the code + - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false @@ -51,17 +69,21 @@ jobs: cache: npm cache-dependency-path: package-lock.json - - name: Install dependencies + - name: Install frontend dependencies run: npm ci - name: Run frontend tests run: npm test + + # Frontend production build job frontend-build: + name: Frontend Production Build runs-on: ubuntu-latest timeout-minutes: 10 + steps: - - name: Get the code + - name: Checkout repository uses: actions/checkout@v6 with: persist-credentials: false @@ -73,7 +95,7 @@ jobs: cache: npm cache-dependency-path: package-lock.json - - name: Install dependencies + - name: Install frontend dependencies run: npm ci - name: Build frontend