From 38b5385feeeb671f3e0a4bfc4afae4894afbffca Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Fri, 25 Apr 2025 06:46:25 -0400 Subject: [PATCH] Update backend-ci.yml --- .github/workflows/backend-ci.yml | 47 ++++++++++++++------------------ 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index 50ed1b6..31d28ca 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -9,23 +9,11 @@ on: jobs: lint: runs-on: self-hosted + defaults: + run: + working-directory: backend steps: - - name: Clean up ghost submodule (prevents checkout failure) - run: | - echo "Removing submodule remnants if they exist..." - rm -f .gitmodules - rm -rf .git/modules/cse2102-spring25-Team27 || true - git config --global --remove-section submodule.cse2102-spring25-Team27 || true - - - name: Checkout code - 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: @@ -35,12 +23,15 @@ 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 @@ -49,6 +40,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + submodules: false + clean: true + fetch-depth: 0 + persist-credentials: false - name: Set up Python uses: actions/setup-python@v2 @@ -62,14 +58,6 @@ jobs: pip install -r backend/requirements.txt pip install pytest-html - - name: Run pylint on Python code - 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 & @@ -87,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 @@ -106,6 +94,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + with: + submodules: false + clean: true + fetch-depth: 0 + persist-credentials: false - name: Set up Node.js uses: actions/setup-node@v3