Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build and Test

on:
push:
tags:
- '*'
branches:
- master
- release-*


jobs:
Docker-build:
runs-on: ubuntu-latest

steps:
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

- name: Checkout code
uses: actions/checkout@v3

- name: Restore Maven cache
uses: actions/cache@v3
with:
path: ~/.m2
key: lern-jobs-dependency-cache-${{ hashFiles('pom.xml') }}
restore-keys: |
lern-jobs-dependency-cache-

- name: Install ImageMagick
run: |
sudo apt-get update || sudo apt-get update
sudo apt-get install -y imagemagick

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Build the code
run: mvn clean install -DskipTests

- name: Execute coverage report
run: mvn clean scoverage:report

- name: Save test results
if: always()
run: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: lern-jobs-dependency-cache-${{ hashFiles('pom.xml') }}

- name: Store test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ~/test-results

- name: Setup Maven Action
uses: s4u/setup-maven-action@v1.2.1
with:
maven-version: '3.6.3'
java-version: '11'

- name: Verify Maven version
run: mvn -v

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build Docker Image
run: |
cd jobs-distribution
mvn package -Pbuild-docker-image -Drelease-version=${{ github.ref_name }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Run SonarQube analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn verify -DskipTests=true sonar:sonar -Dlog4j.configuration=./logs sonar:sonar -Dsonar.projectKey=Sunbird-Lern_data-pipeline -Dsonar.organization=sunbird-lern -Dsonar.host.url=https://sonarcloud.io -Dsonar.java.binaries=$(find . -path '*/build/classes/java' | xargs | tr ' ' ',') -Dsonar.coverage.exclusions=**/notification-sdk/**,**/notification/domain/** -Dsonar.test.exclusions=**/notification-sdk/** -Dsonar.exclusions=**/**.java -Dsonar.scala.coverage.reportPaths=/home/circleci/lern/target/scoverage.xml
75 changes: 75 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build and Test

on:
pull_request:
types: [opened, synchronize]


jobs:
Run-test-cases:
runs-on: ubuntu-latest

steps:
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

- name: Checkout code
uses: actions/checkout@v3

- name: Restore Maven cache
uses: actions/cache@v3
with:
path: ~/.m2
key: lern-jobs-dependency-cache-${{ hashFiles('pom.xml') }}
restore-keys: |
lern-jobs-dependency-cache-

- name: Install ImageMagick
run: |
sudo apt-get update || sudo apt-get update
sudo apt-get install -y imagemagick

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Build the code
run: mvn clean install -DskipTests

- name: Execute coverage report
run: mvn clean scoverage:report

- name: Save test results
if: always()
run: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: lern-jobs-dependency-cache-${{ hashFiles('pom.xml') }}

- name: Store test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ~/test-results

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Run SonarQube analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn verify -DskipTests=true sonar:sonar -Dlog4j.configuration=./logs sonar:sonar -Dsonar.projectKey=Sunbird-Lern_data-pipeline -Dsonar.organization=sunbird-lern -Dsonar.host.url=https://sonarcloud.io -Dsonar.java.binaries=$(find . -path '*/build/classes/java' | xargs | tr ' ' ',') -Dsonar.coverage.exclusions=**/notification-sdk/**,**/notification/domain/** -Dsonar.test.exclusions=**/notification-sdk/** -Dsonar.exclusions=**/**.java -Dsonar.scala.coverage.reportPaths=/home/circleci/lern/target/scoverage.xml