From 4523bccc2b40aa4ee231ec9719243b5aaa1da69c Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Sat, 26 Apr 2025 04:16:48 -0400 Subject: [PATCH] Update backend-ci.yml --- .github/workflows/backend-ci.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 061a3af..8ca720b 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code without submodules - uses: actions/checkout@v3 # Updated to v3 + uses: actions/checkout@v3 with: submodules: false # Skips submodule initialization @@ -28,30 +28,29 @@ jobs: run: | python -m venv venv source venv/bin/activate - pip install -r requirements.txt # Ensure all dependencies are installed, including requests + pip install -r backend/requirements.txt # Ensure all dependencies are installed, including requests - name: Cache Python dependencies - uses: actions/cache@v3 # Using the latest stable version + uses: actions/cache@v3 with: path: venv - key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }} restore-keys: | ${{ runner.os }}-python- - name: Run pylint (backend only on changed files) run: | source venv/bin/activate - # Compare against the remote main branch to handle the first commit - changed_files=$(git diff --name-only origin/main...HEAD | grep '\.py$' || true) - + changed_files=$(git diff --name-only origin/main...HEAD | grep '^backend/' || true) + if [ -n "$changed_files" ]; then - pylint $changed_files --exit-zero | tee pylint.log + pylint backend --exit-zero | tee pylint.log SCORE=$(tail -n 2 pylint.log | grep -oP '[0-9]+\.[0-9]+(?=/10)') echo "Pylint score: $SCORE" python -c "import sys; sys.exit(0 if float('$SCORE') >= 8.0 else 1)" else - echo "No Python files changed, skipping pylint." - exit 0 # Exit with status 0 (success) if no Python files changed + echo "No Python files changed in the backend, skipping pylint." + exit 0 # Exit with status 0 (success) if no Python files changed in the backend fi test: @@ -60,7 +59,7 @@ jobs: steps: - name: Checkout code without submodules - uses: actions/checkout@v3 # Updated to v3 + uses: actions/checkout@v3 with: submodules: false # Skips submodule initialization @@ -77,7 +76,7 @@ jobs: pip install pytest-html - name: Cache Python dependencies - uses: actions/cache@v3 # Using the latest stable version + uses: actions/cache@v3 with: path: venv key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }} @@ -119,7 +118,7 @@ jobs: steps: - name: Checkout repository without submodules - uses: actions/checkout@v3 # Updated to v3 + uses: actions/checkout@v3 with: submodules: false # Skips submodule initialization @@ -129,7 +128,7 @@ jobs: node-version: '20' - name: Cache node modules - uses: actions/cache@v3 # Using the latest stable version + uses: actions/cache@v3 with: path: frontend/node_modules key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}