From 7fb055697616d026fe18aa3e0dd86c61f40bf486 Mon Sep 17 00:00:00 2001 From: Minase Mekete Mengistu Date: Sat, 27 Sep 2025 19:53:03 +0300 Subject: [PATCH] Update GitHub Actions workflow for build process --- .github/workflows/build.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 021e93d..4680221 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,7 @@ name: Build on: push: - branches: - - master + branches: [ master ] pull_request: types: [opened, synchronize, reopened] @@ -10,35 +9,40 @@ jobs: sonarcloud: name: SonarCloud runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write # needed for PR decoration/comments env: DB_CONNECTION_STRING: "mysql+mysqlconnector://user:password@localhost/dbname" + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # <-- required for the new action + # No SONAR_HOST_URL for SonarCloud steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Install Dependencies - run: | - pip install -r requirements.txt + run: pip install -r requirements.txt - name: Run Tests with Coverage run: | + mkdir -p reports pytest --junitxml=reports/results.xml --cov=app --cov-report=xml - coverage xml -i # Regenerate the XML report with corrected paths - mv coverage.xml reports/coverage.xml # Move the report to the correct directory + # Ensure coverage XML paths are correct & in expected location + coverage xml -i || true + if [ -f coverage.xml ]; then mv -f coverage.xml reports/coverage.xml; fi - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master + uses: SonarSource/sonarqube-scan-action@v5.0.0 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for PR decoration with: args: > -Dsonar.projectKey=ManassehV2_aptarapi