From a17272c4e8410002b1ba27f47457d4975a28a436 Mon Sep 17 00:00:00 2001 From: GabrielPalmar Date: Mon, 16 Jun 2025 14:18:22 -0500 Subject: [PATCH 1/5] chore(ci): add SonarQube analysis workflow --- .github/workflows/sonarqube.yml | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..ed55534 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,48 @@ +name: SonarQube analysis + +on: + push: + branches: [ "main", "test" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + pull-requests: read + contents: read + +jobs: + Analysis: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Disable shallow clones for better analysis + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests with coverage + run: | + pip install coverage pytest + coverage run -m pytest test_main.py + coverage xml + + - name: Analyze with SonarQube + uses: SonarSource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.projectKey=GabrielPalmar_HiveBox-Project + -Dsonar.sources=. + -Dsonar.exclusions=**/*test*/**,**/fixtures/**,**/__pycache__/**,**/venv/**,**/.git/** \ No newline at end of file From 8a2c138d1eafc372603b91494be70ab1f4458f36 Mon Sep 17 00:00:00 2001 From: GabrielPalmar Date: Mon, 16 Jun 2025 14:21:46 -0500 Subject: [PATCH 2/5] fix(ci): Added sonarqube required deps --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index ed55534..ef7d475 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -29,6 +29,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install coverage pytest vcrpy - name: Run tests with coverage run: | From 2d39bceda37193d525ad90755fe31c7dec5e7daf Mon Sep 17 00:00:00 2001 From: GabrielPalmar Date: Mon, 16 Jun 2025 15:41:58 -0500 Subject: [PATCH 3/5] fix(ci): Added org to sonarqube --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index ef7d475..5dcec24 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -45,5 +45,6 @@ jobs: with: args: > -Dsonar.projectKey=GabrielPalmar_HiveBox-Project + -Dsonar.organization=gabrielpalmar -Dsonar.sources=. -Dsonar.exclusions=**/*test*/**,**/fixtures/**,**/__pycache__/**,**/venv/**,**/.git/** \ No newline at end of file From 88fc765e890395fd8df68c374534b5bff0e19d1e Mon Sep 17 00:00:00 2001 From: GabrielPalmar Date: Mon, 16 Jun 2025 15:51:05 -0500 Subject: [PATCH 4/5] fix(ci): Removed pytest from sonarqube --- .github/workflows/sonarqube.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 5dcec24..6573540 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -33,8 +33,7 @@ jobs: - name: Run tests with coverage run: | - pip install coverage pytest - coverage run -m pytest test_main.py + coverage run -m test_main.py coverage xml - name: Analyze with SonarQube From bfedbd7c39c6af65438ac29af7f8eabed1a45b79 Mon Sep 17 00:00:00 2001 From: GabrielPalmar Date: Tue, 17 Jun 2025 12:21:01 -0500 Subject: [PATCH 5/5] fix(ci): Switch to run test script, no module --- .github/workflows/sonarqube.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 6573540..9ae7570 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -33,7 +33,7 @@ jobs: - name: Run tests with coverage run: | - coverage run -m test_main.py + coverage run test_main.py coverage xml - name: Analyze with SonarQube