Skip to content

Issue #SBCOSS-00: Add Redis Cache Cleanup to User Deletion Flink Job #16

Issue #SBCOSS-00: Add Redis Cache Cleanup to User Deletion Flink Job

Issue #SBCOSS-00: Add Redis Cache Cleanup to User Deletion Flink Job #16

Workflow file for this run

name: PR Code Coverage and SonarQube Analysis
# Trigger workflow on pull requests to any branch
# This workflow runs comprehensive testing and code quality analysis
on:
pull_request:
branches: ['**']
jobs:
# First job: Build root POM and test jobs-core module
# This job serves as the foundation for all other parallel jobs
# It builds the root POM, tests jobs-core, and uploads Maven repository
# All other jobs depend on this job and download the Maven repository from it
root-pom-build-and-coverage-job-core:
runs-on: ubuntu-latest
outputs:
# Output the Maven cache key for potential use by other jobs
maven-cache-key: ${{ steps.cache-maven.outputs.cache-primary-key }}
env:
# Environment variables for schema and blob paths
# These are used by the application during testing
SCHEMA_BASE_PATH: ${{ vars.SCHEMA_BASE_PATH }}
BLOB_IMAGE_CONTENT_PATH: ${{ vars.BLOB_IMAGE_CONTENT_PATH }}
BLOB_VIDEO_CONTENT_PATH: ${{ vars.BLOB_VIDEO_CONTENT_PATH }}
steps:
# Step 1: Checkout the source code from the PR
- uses: actions/checkout@v3
# Step 2: Set up Java 11 environment for building and testing
# Uses Temurin distribution for better performance and reliability
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven' # Additional Maven caching provided by setup-java
# Step 3: Cache Maven dependencies to speed up builds
# This caches the ~/.m2/repository directory between workflow runs
# The cache key is based on the hash of all pom.xml files
- name: Cache Maven packages
id: cache-maven
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step 4: Build root POM and test jobs-core module
# This step performs a comprehensive build and test of the jobs-core module
# including code coverage analysis with JaCoCo
- name: Build root POM and job-core
run: |
# First, build only the root POM (parent project) without building modules
# -N flag means "non-recursive" - only build the current project
mvn clean install -N -DskipTests
# Then build and test the jobs-core module with code coverage
# prepare-agent: Prepare JaCoCo agent for coverage
# test: Run unit tests
# report: Generate coverage report
# surefire-report:report: Generate test report
cd jobs-core
mvn clean install \
org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent \
test \
org.jacoco:jacoco-maven-plugin:0.8.8:report \
surefire-report:report
# Step 5: Generate test summary report
# This creates a nice test summary in the GitHub UI
# Shows which tests passed/failed and their details
- name: Test Summary
uses: dorny/test-reporter@v2.1.0
if: always() # Run even if tests fail
with:
name: Test Results
path: 'jobs-core/target/surefire-reports/*.xml' # Path to test results
reporter: java-junit
fail-on-error: false # Don't fail the workflow if test reporting fails
only-summary: false # Show detailed test information
list-tests: 'all' # List all tests in the summary
# Step 6: Set up Java 17 for SonarQube analysis
# SonarQube analysis requires Java 17 for better analysis capabilities
- name: Set up JDK17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Step 7: Run SonarQube code quality analysis
# This analyzes code quality, security, and maintainability
# Results are sent to SonarCloud for review
- name: Run SonarQube Analysis for jobs-core
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Authentication token for SonarCloud
working-directory: jobs-core
run: |
# SonarQube analysis with project configuration
# projectKey: SonarCloud project key
# organization: SonarCloud organization
# host.url: SonarCloud URL
# coverage.jacoco.xmlReportPaths: Coverage report path
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
# Step 8: Upload Maven repository as artifact
# This makes the built dependencies available to parallel jobs
# All other jobs will download this to avoid rebuilding dependencies
- name: Upload Maven local repository
uses: actions/upload-artifact@v4.6.2
with:
name: maven-repo
path: ~/.m2/repository
retention-days: 1 # Keep for 1 day to allow for debugging
# Parallel jobs: The following jobs run in parallel after the first job completes
# Each job follows the same pattern:
# 1. Download Maven repository from the first job
# 2. Set up Java environment
# 3. Build and test the specific module with coverage
# 4. Generate test summary
# 5. Run SonarQube analysis
coverage-notification:
needs: root-pom-build-and-coverage-job-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Install ImageMagick
run: |
sudo apt-get update
sudo apt-get install -y imagemagick
- name: Restore Maven local repository
uses: actions/download-artifact@v4.3.0
with:
name: maven-repo
path: ~/.m2/repository
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Generate Coverage Report
run: |
cd notification
mvn clean test \
org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent \
test \
org.jacoco:jacoco-maven-plugin:0.8.8:report \
surefire-report:report
- name: Test Summary
uses: dorny/test-reporter@v2.1.0
if: always()
with:
name: Test Results
path: 'notification/notification-job/target/surefire-reports/*.xml'
reporter: java-junit
fail-on-error: false
only-summary: false
list-tests: 'all'
- name: Set up JDK17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run SonarQube Analysis for notification
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: notification
run: |
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=notification-job/target/site/jacoco/jacoco.xml
coverage-lms-jobs:
needs: root-pom-build-and-coverage-job-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Restore Maven local repository
uses: actions/download-artifact@v4.3.0
with:
name: maven-repo
path: ~/.m2/repository
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Generate Coverage Report
run: |
cd lms-jobs
mvn clean test \
org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent \
test \
org.jacoco:jacoco-maven-plugin:0.8.8:report \
surefire-report:report
- name: Test Summary
uses: dorny/test-reporter@v2.1.0
if: always()
with:
name: Test Results
path: |
lms-jobs/*/target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: false
only-summary: false
list-tests: 'all'
- name: Set up JDK17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run SonarQube Analysis for lms-jobs
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: lms-jobs
run: |
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=*/target/site/jacoco/jacoco.xml
coverage-user-org-jobs:
needs: root-pom-build-and-coverage-job-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Restore Maven local repository
uses: actions/download-artifact@v4.3.0
with:
name: maven-repo
path: ~/.m2/repository
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Generate Coverage Report
run: |
cd user-org-jobs
mvn clean test \
org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent \
test \
org.jacoco:jacoco-maven-plugin:0.8.8:report \
surefire-report:report
- name: Test Summary
uses: dorny/test-reporter@v2.1.0
if: always()
with:
name: Test Results
path: 'user-org-jobs/*/target/surefire-reports/*.xml'
reporter: java-junit
fail-on-error: false
only-summary: false
list-tests: 'all'
- name: Set up JDK17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run SonarQube Analysis for user-org-jobs
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: user-org-jobs
run: |
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
coverage-ml-jobs:
needs: root-pom-build-and-coverage-job-core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Restore Maven local repository
uses: actions/download-artifact@v4.3.0
with:
name: maven-repo
path: ~/.m2/repository
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and Generate Coverage Report
run: |
cd ml-jobs
mvn clean test \
org.jacoco:jacoco-maven-plugin:0.8.8:prepare-agent \
test \
org.jacoco:jacoco-maven-plugin:0.8.8:report \
surefire-report:report
- name: Test Summary
uses: dorny/test-reporter@v2.1.0
if: always()
with:
name: Test Results
path: 'ml-jobs/*/target/surefire-reports/*.xml'
reporter: java-junit
fail-on-error: false
only-summary: false
list-tests: 'all'
- name: Set up JDK17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run SonarQube Analysis for ml-jobs
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: ml-jobs
run: |
mvn sonar:sonar \
-Dsonar.projectKey=sunbird-lern \
-Dsonar.organization=sunbird-lern \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml