name: CI Pipeline on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: lint: name: Code Linting runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install ruff - name: Run Ruff run: ruff check . # PYTEST JOB (Runs ONLY if lint succeeds) pytest: name: Pytest and Coverage runs-on: ubuntu-latest needs: lint # Tells GitHub to wait for the lint job steps: - name: Check out repository uses: actions/checkout@v6 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install pytest pytest-cov - name: Run Pytest with Coverage XML report run: | pytest --cov=. --cov-report=xml - name: Upload Coverage Report Artifact uses: actions/upload-artifact@v4 with: name: coverage-report path: coverage.xml retention-days: 1 # SONARQUBE JOB (Runs ONLY if pytest succeeds) sonarqube: name: SonarQube Quality Gate runs-on: ubuntu-latest needs: pytest # Tells GitHub to wait for the pytest job steps: - name: Check out repository uses: actions/checkout@v6 with: fetch-depth: 0 - name: Download Coverage Report Artifact uses: actions/download-artifact@v4 with: name: coverage-report - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@v4 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} with: args: > -Dsonar.python.coverage.reportPaths=coverage.xml