Skip to content

SBCOSS-468: Sunbird Groups service - create Github actions to publish docker image to GHCR #2

SBCOSS-468: Sunbird Groups service - create Github actions to publish docker image to GHCR

SBCOSS-468: Sunbird Groups service - create Github actions to publish docker image to GHCR #2

Workflow file for this run

name: PR Code Coverage and SonarQube Analysis
on:
pull_request:
# Trigger this workflow on pull requests to any branch
branches: ['**']
jobs:
pr-coverage:
runs-on: ubuntu-latest
steps:
# Checkout the code from the pull request
- uses: actions/checkout@v3
# Set up JDK 11 for running tests and generating code coverage
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
# Cache Maven dependencies to speed up builds
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Build the project and generate the JaCoCo coverage report
- name: Build and Generate Jacoco reports and Surefire reports
run: |
mvn clean install -DskipTests
cd service
mvn clean verify jacoco:report surefire-report:report
# Generate and display a detailed test report in the GitHub Actions UI
# This step uses dorny/test-reporter to parse XML reports and create an interactive test summary
- name: Test Summary
uses: dorny/[email protected]
if: always()
with:
name: Test Results
path: '**/surefire-reports/*.xml'
reporter: java-junit
fail-on-error: false
only-summary: false
list-tests: 'all'
# Set up JDK 17 for running SonarQube analysis (required by plugins)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Run SonarQube analysis using the generated JaCoCo coverage report
- name: Run SonarQube Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=service/target/site/jacoco/jacoco.xml