khrefberiyge #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Content Service PR Checks | |
| on: | |
| push: | |
| paths: | |
| - 'content-api/**' | |
| jobs: | |
| test-and-analyze: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Required for SonarCloud analysis | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '11' | |
| cache: 'maven' | |
| - name: Build Content Service | |
| run: | | |
| mvn clean install -DskipTests=true \ | |
| -DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \ | |
| -DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \ | |
| -DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }} | |
| # - name: Run Tests | |
| # working-directory: content-api/content-service | |
| # run: | | |
| # mvn test -pl content-service -am \ | |
| # -DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \ | |
| # -DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \ | |
| # -DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }} | |
| # Build and test content-service | |
| - name: Build and Test Content Service | |
| working-directory: content-api/content-service | |
| run: | | |
| mvn test \ | |
| -DCLOUD_STORE_GROUP_ID=${{ vars.CLOUD_STORE_GROUP_ID }} \ | |
| -DCLOUD_STORE_ARTIFACT_ID=${{ vars.CLOUD_STORE_ARTIFACT_ID }} \ | |
| -DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }} | |
| - name: Generate Test Coverage Report | |
| working-directory: content-api/content-service | |
| run: | | |
| mvn scoverage:report | |
| - name: SonarCloud Scan | |
| uses: SonarSource/sonarcloud-github-action@master | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| with: | |
| projectBaseDir: content-api/content-service | |
| args: > | |
| -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} | |
| -Dsonar.projectKey=knowledge-platform-content-service | |
| -Dsonar.java.binaries=target/scala-2.12/classes | |
| -Dsonar.scala.coverage.reportPaths=target/scala-2.12/scoverage-report/scoverage.xml | |
| -Dsonar.sources=app | |
| -Dsonar.tests=test | |
| -Dsonar.test.inclusions=test/**/*.* | |
| - name: Check Quality Gate | |
| id: sonarqube-quality-gate-check | |
| uses: sonarsource/sonarqube-quality-gate-action@master | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| timeout-minutes: 5 | |
| # - name: Add PR Comment | |
| # uses: actions/github-script@v6 | |
| # if: always() | |
| # with: | |
| # script: | | |
| # const testResult = '${{ job.status }}'; | |
| # const sonarStatus = '${{ steps.sonarqube-quality-gate-check.outcome }}'; | |
| # let comment = '## Content Service PR Check Results\n\n'; | |
| # // Test Results Section | |
| # comment += '### Test Results\n'; | |
| # comment += `**Status**: ${testResult === 'success' ? '✅ Passed' : '❌ Failed'}\n\n`; | |
| # // Code Quality Section | |
| # comment += '### Code Quality Check\n'; | |
| # comment += `**Status**: ${sonarStatus === 'success' ? '✅ Passed' : '❌ Failed'}\n\n`; | |
| # if (testResult !== 'success' || sonarStatus !== 'success') { | |
| # comment += '### ⚠️ Action Required\n'; | |
| # comment += '- Please check the test failures and code quality issues\n'; | |
| # comment += '- Fix the identified issues and update the PR\n'; | |
| # comment += '- Detailed reports are available in the Actions tab\n'; | |
| # } else { | |
| # comment += '### ✅ All Checks Passed!\n'; | |
| # comment += 'This PR meets all quality standards.\n'; | |
| # } | |
| # github.rest.issues.createComment({ | |
| # issue_number: context.issue.number, | |
| # owner: context.repo.owner, | |
| # repo: context.repo.repo, | |
| # body: comment | |
| # }); | |
| - name: Check Test Results | |
| if: steps.sonarqube-quality-gate-check.outcome != 'success' || job.status != 'success' | |
| run: exit 1 |