Skip to content

Commit

Permalink
Merge pull request #30 from wednesday-solutions/feat/sonar_integration
Browse files Browse the repository at this point in the history
Feat:Sonar Integration
  • Loading branch information
anasnadeemws authored Mar 18, 2024
2 parents 2803dfa + bb76458 commit 6b768ab
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
68 changes: 39 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
name: FastAPI-CI

on:
'on':
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
types:
- opened
- synchronize
- reopened
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: 3.11.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install plugin
run: pip install pytest-github-actions-annotate-failures

- name: Build coverage file
run: |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=app app/tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml

- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install plugin
run: pip install pytest-github-actions-annotate-failures
- name: Build coverage file
run: >
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered
--cov=app app/tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
with:
args: |
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }}
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
SONAR_HOST_URL: '${{ secrets.SONAR_HOST_URL }}'
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
SONAR_HOST_URL: '${{ secrets.SONAR_HOST_URL }}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ venv
tmp/
temp/
*.xml
.idea
2 changes: 1 addition & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
coverage run -m pytest
coverage report
coverage report
11 changes: 11 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.projectKey=wednesday-solutions_python-fastapi_AY434cJSB2n8RRmGoUoD
sonar.projectName=python-fastapi
sonar.projectVersion=1.0
sonar.sources=./app
sonar.test.inclusions=**/test_*.py
sonar.tests=./app
sonar.language=py
sonar.sourceEncoding=UTF-8
sonar.coverage.exclusions=**/*.*
sonar.python.tests.reportPaths=test-report.json
sonar.python.coverage.reportPaths=coverage.xml

1 comment on commit 6b768ab

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app
   app.py312423%10–61
app/config
   __init__.py3167%6
   base.py32391%44–46
   celery_config.py16160%1–25
   celery_utils.py20200%1–28
   redis_config.py4325%2–6
app/constants
   jwt_utils.py151127%7–19
app/daos
   home.py10550%11–18
   users.py716311%12–134
app/middlewares
   cache_middleware.py52520%1–68
   rate_limiter_middleware.py24240%1–32
   request_id_injection.py17170%1–25
app/models
   __init__.py330%1–5
   users.py27270%1–38
app/routes
   __init__.py11110%1–13
app/routes/cache_router
   __init__.py220%1–3
   cache_samples.py11110%1–15
app/routes/celery_router
   __init__.py220%1–3
   celery_samples.py11110%1–14
app/routes/home
   __init__.py220%1–3
   home.py33330%1–45
app/routes/users
   __init__.py220%1–3
   users.py38380%1–57
app/schemas/users
   users_request.py41410%1–70
   users_response.py880%1–11
app/sessions
   db.py53530%1–82
app/tests
   test_basic.py201525%10–34
   test_daos_home.py241058%14–21, 27–36, 39
   test_daos_users.py1109514%19–208
app/utils
   exception_handler.py19190%1–36
   redis_utils.py330%1–5
   slack_notification_utils.py13130%1–29
   user_utils.py25250%1–36
app/wrappers
   cache_wrappers.py19190%1–27
TOTAL78868213% 

Tests Skipped Failures Errors Time
2 0 💤 0 ❌ 2 🔥 0.810s ⏱️

Please sign in to comment.