diff --git a/backend/.github/workflows/backend-ci.yml b/backend/.github/workflows/backend-ci.yml index 31d28ca..4e831ec 100644 --- a/backend/.github/workflows/backend-ci.yml +++ b/backend/.github/workflows/backend-ci.yml @@ -25,10 +25,23 @@ jobs: source venv/bin/activate pip install -r requirements.txt - - name: Run pylint (backend only) + - name: Cache Python dependencies + uses: actions/cache@v2 + with: + path: venv + key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-python- + + - name: Run pylint (backend only on changed files) run: | source venv/bin/activate - pylint . --exit-zero | tee pylint.log + changed_files=$(git diff --name-only HEAD^..HEAD | grep '\.py$' || true) + if [ -n "$changed_files" ]; then + pylint $changed_files --exit-zero | tee pylint.log + else + echo "No Python files changed, skipping pylint." + 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)" @@ -58,6 +71,14 @@ jobs: pip install -r backend/requirements.txt pip install pytest-html + - name: Cache Python dependencies + uses: actions/cache@v2 + with: + path: venv + key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-python- + - name: Start Flask API server run: | nohup python backend/main.py > flask.log 2>&1 & @@ -67,7 +88,7 @@ jobs: break fi echo "Waiting for Flask... Attempt $i/10" - sleep 3 + sleep 5 done - name: Run backend tests with pytest @@ -89,7 +110,7 @@ jobs: build-frontend: runs-on: self-hosted - needs: lint + needs: [lint, test] steps: - name: Checkout repository @@ -105,6 +126,14 @@ jobs: with: node-version: '20' + - name: Cache node modules + uses: actions/cache@v2 + with: + path: frontend/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install frontend dependencies working-directory: frontend run: npm install