Skip to content

PR Checks Backend

PR Checks Backend #54

name: PR Checks Backend
on:
pull_request:
branches:
- staging
paths:
- 'data/**'
- 'Dockerfile-pg'
- 'init_pg.sql'
- 'docker-compose.yml'
workflow_dispatch:
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Compose
uses: docker/setup-qemu-action@v3
- name: Install Dependencies
run: |
pip install ruff
run-radon:
runs-on: ubuntu-latest
needs: setup
continue-on-error: true # Continue even if Radon flags issues
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Radon
run: pip install radon
- name: Run Radon MI and Halstead Checks
run: |
# Run MI checks
radon mi ./data/ -s
# Run Halstead complexity analysis
radon hal ./data/ -s
- name: Flag issues from Radon MI and Halstead checks
run: |
# Check Maintainability Index (MI) results and flag any grade below B
bad_grades=$(radon mi ./data/ -s | grep -E " - [CDEF] \(" || true)
if [[ ! -z "$bad_grades" ]]; then
echo "Warning: Bad MI grades found (below B):"
echo "$bad_grades"
else
echo "Radon MI checks passed successfully."
fi
# Check Halstead complexity for effort > 2000
high_effort=$(radon hal ./data/ -s | awk '/effort/ { if ($3 > 2000) print $0 }')
if [[ ! -z "$high_effort" ]]; then
echo "Warning: High Halstead effort found (above 2000):"
echo "$high_effort"
else
echo "Halstead checks passed successfully."
fi
run-formatter:
runs-on: ubuntu-latest
needs: setup
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Ruff Formatter in Docker
run: |
cd data
docker compose run --rm formatter
run-linter:
runs-on: ubuntu-latest
needs: setup
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Ruff Linter in Docker
run: |
cd data
docker compose run --rm linter
build-project:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build vacant-lots-proj
run: |
cd data
docker compose build vacant-lots-proj
run-services:
runs-on: ubuntu-latest
needs: build-project
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run all services
run: |
cd data
docker compose up -d
check-build-status:
runs-on: ubuntu-latest
needs: run-services
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check build status
if: failure()
run: |
echo "One or more services failed to build and run."
exit 1
- name: Report success
if: success()
run: echo "All services built and ran successfully."
check-lint-format-status:
runs-on: ubuntu-latest
needs: [run-formatter, run-linter]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check formatter and linter status
if: failure()
run: |
echo "Formatting or linting issues found. Please fix the issues."
exit 1
- name: Formatter and linter success
if: success()
run: echo "Formatting and linting passed successfully."