Skip to content

Commit 2d8843a

Browse files
committed
Add SonarCloud scan workflow
1 parent 1879cbf commit 2d8843a

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: SonarCloud Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
sonarcloud:
13+
name: SonarCloud Scan
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
pip install pytest pytest-cov
30+
31+
- name: Run tests with coverage
32+
run: |
33+
pytest --cov=./ --cov-report=xml
34+
35+
- name: SonarCloud Scan
36+
uses: sonarsource/sonarcloud-github-action@v2.2.1
37+
with:
38+
projectBaseDir: .
39+
extraProperties: |
40+
sonar.projectKey=alexjelani_python-fastapi
41+
sonar.sources=.
42+
sonar.python.coverage.reportPaths=coverage.xml
43+
sonar.tests=tests
44+
sonar.test.inclusions=tests/**/*.py
45+
sonar.sourceEncoding=UTF-8
46+
sonar.exclusions=.github/**,tests/**
47+
sonar.login=${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)