diff --git a/backend/.github/workflows/backend-ci.yml b/backend/.github/workflows/backend-ci.yml index 4e831ec..68668fe 100644 --- a/backend/.github/workflows/backend-ci.yml +++ b/backend/.github/workflows/backend-ci.yml @@ -14,8 +14,13 @@ jobs: working-directory: backend steps: + - name: Checkout code without submodules + uses: actions/checkout@v2 # Using v2 for actions/checkout + with: + submodules: false # Skips submodule initialization + - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v2 # Using v2 for setup-python with: python-version: '3.11' @@ -23,10 +28,10 @@ jobs: run: | python -m venv venv source venv/bin/activate - pip install -r requirements.txt + pip install -r requirements.txt # Ensure all dependencies are installed, including requests - name: Cache Python dependencies - uses: actions/cache@v2 + uses: actions/cache@v2 # Using v2 for actions/cache with: path: venv key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }} @@ -36,31 +41,30 @@ jobs: - name: Run pylint (backend only on changed files) run: | source venv/bin/activate - changed_files=$(git diff --name-only HEAD^..HEAD | grep '\.py$' || true) + changed_files=$(git diff --name-only origin/main...HEAD | grep '\.py$' || true) + if [ -n "$changed_files" ]; then pylint $changed_files --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 fi - 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)" test: runs-on: self-hosted needs: lint steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code without submodules + uses: actions/checkout@v2 # Using v2 for actions/checkout with: - submodules: false - clean: true - fetch-depth: 0 - persist-credentials: false + submodules: false # Skips submodule initialization - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v2 # Using v2 for setup-python with: python-version: '3.11' @@ -68,11 +72,11 @@ jobs: run: | python -m venv venv source venv/bin/activate - pip install -r backend/requirements.txt + pip install -r backend/requirements.txt # Ensure all dependencies are installed, including requests pip install pytest-html - name: Cache Python dependencies - uses: actions/cache@v2 + uses: actions/cache@v2 # Using v2 for actions/cache with: path: venv key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }} @@ -95,11 +99,11 @@ jobs: env: BASE_URL: http://127.0.0.1:5000 run: | - source venv/bin/activate + source venv/bin/activate # Activate the virtual environment before running tests pytest backend/tests --html=backend/test-report.html --self-contained-html - name: Upload test report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v2 # Using v2 for actions/upload-artifact with: name: backend-test-report path: backend/test-report.html @@ -113,21 +117,18 @@ jobs: needs: [lint, test] steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository without submodules + uses: actions/checkout@v2 # Using v2 for actions/checkout with: - submodules: false - clean: true - fetch-depth: 0 - persist-credentials: false + submodules: false # Skips submodule initialization - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v3 # Using the latest stable version for Node.js with: node-version: '20' - name: Cache node modules - uses: actions/cache@v2 + uses: actions/cache@v2 # Using v2 for actions/cache with: path: frontend/node_modules key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}