From dc0a095ab44f40f13f394a04405f83b3cc50f0ff Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Fri, 25 Apr 2025 07:14:15 -0400 Subject: [PATCH] Update backend-ci.yml --- backend/.github/workflows/backend-ci.yml | 42 +++++++----------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/backend/.github/workflows/backend-ci.yml b/backend/.github/workflows/backend-ci.yml index 36c898c..31d28ca 100644 --- a/backend/.github/workflows/backend-ci.yml +++ b/backend/.github/workflows/backend-ci.yml @@ -9,20 +9,11 @@ on: jobs: lint: runs-on: self-hosted + defaults: + run: + working-directory: backend steps: - - name: Clean GitHub Actions workspace manually (force clean) - run: | - sudo rm -rf $GITHUB_WORKSPACE/* - - - name: Checkout repository without submodules - uses: actions/checkout@v2 - with: - submodules: false - clean: true - fetch-depth: 0 - persist-credentials: false - - name: Set up Python uses: actions/setup-python@v2 with: @@ -32,23 +23,22 @@ jobs: run: | python -m venv venv source venv/bin/activate - pip install -r backend/requirements.txt + pip install -r requirements.txt - - name: Run pylint on backend only + - name: Run pylint (backend only) run: | source venv/bin/activate - pylint ./backend/**/*.py + pylint . --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)" test: runs-on: self-hosted needs: lint steps: - - name: Clean GitHub Actions workspace manually (force clean) - run: | - sudo rm -rf $GITHUB_WORKSPACE/* - - - name: Checkout repository without submodules + - name: Checkout code uses: actions/checkout@v2 with: submodules: false @@ -68,14 +58,6 @@ jobs: pip install -r backend/requirements.txt pip install pytest-html - - name: Run pylint with score check - run: | - source venv/bin/activate - pylint backend/main.py backend/db.py backend/init_db.py --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)" - - name: Start Flask API server run: | nohup python backend/main.py > flask.log 2>&1 & @@ -93,7 +75,7 @@ jobs: BASE_URL: http://127.0.0.1:5000 run: | source venv/bin/activate - pytest ./backend/tests --html=backend/test-report.html --self-contained-html + pytest backend/tests --html=backend/test-report.html --self-contained-html - name: Upload test report uses: actions/upload-artifact@v3 @@ -110,7 +92,7 @@ jobs: needs: lint steps: - - name: Checkout repository without submodules + - name: Checkout repository uses: actions/checkout@v2 with: submodules: false