Skip to content

Commit

Permalink
Merge pull request #97 from Sunbird-Obsrv/release-5.0.0
Browse files Browse the repository at this point in the history
Release 5.0.0 into master
  • Loading branch information
manjudr authored Jan 3, 2023
2 parents bf2c0f1 + 2520c21 commit ebad3d6
Show file tree
Hide file tree
Showing 76 changed files with 4,857 additions and 2,119 deletions.
43 changes: 38 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
version: 2.1
jobs:
analytics-service-build:
machine: true
machine:
image: ubuntu-2004:202008-01
steps:
- checkout
- run: git clone https://github.com/project-sunbird/sunbird-analytics-core -b $CIRCLE_BRANCH

- run:
name: clone analytics core
command: |
if [ -z $CIRCLE_PR_NUMBER ]; then
target_branch=$CIRCLE_BRANCH
else
prdata=$(curl -X GET -u $GITHUB_USER_TOKEN:x-oauth-basic https://api.github.com/repos/project-sunbird/sunbird-analytics-service/pulls/$CIRCLE_PR_NUMBER)
target_branch=$(echo "${prdata}" | jq -r '.base.ref')
fi
echo $target_branch
git clone https://github.com/project-sunbird/sunbird-analytics-core.git
branchExists=$(cd sunbird-analytics-core && git ls-remote --heads origin $target_branch)
echo $branchExists
if [ -z ${branchExists} ]; then
latest_branch=$(cd sunbird-analytics-core && git for-each-ref --count=1 --sort=-committerdate 'refs/remotes/**/release*' --format='%(refname:short)' | head -1)
echo $latest_branch
cd sunbird-analytics-core && git checkout $latest_branch
else
cd sunbird-analytics-core && git checkout $target_branch
fi
- restore_cache:
keys:
- dp-dependency-cache-{{ checksum "pom.xml" }}
- run: cd sunbird-analytics-core && mvn install -DskipTests

- run:
name: Build analytics-core dependency jar
command: |
java -version
cd sunbird-analytics-core && mvn install -DskipTests
- run:
name: lpa-api-build
command: mvn clean scoverage:report
command: |
java -version
mvn clean scoverage:report
- save_cache:
key: dp-dependency-cache-{{ checksum "pom.xml" }}
paths: ~/.m2

- run:
name: sonar
command: |
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
java -version
mvn -X sonar:sonar -Dsonar.projectKey=project-sunbird_sunbird-analytics-service -Dsonar.organization=project-sunbird -Dsonar.host.url=https://sonarcloud.io -Dsonar.scala.coverage.reportPaths=/home/circleci/project/target/scoverage.xml
##test
workflows:
version: 2.1
workflow:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ server.pid
joblog.log
**/target
**/logs
**access-log-*
**application-log-*
.idea
*.iml
80 changes: 41 additions & 39 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,52 @@ node('build-slave') {
String ANSI_YELLOW = "\u001B[33m"
ansiColor('xterm') {
stage('Checkout') {
cleanWs()
if(params.github_release_tag == ""){
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
branch_name = sh(script: 'git name-rev --name-only HEAD | rev | cut -d "/" -f1| rev', returnStdout: true).trim()
artifact_version = branch_name + "_" + commit_hash
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag not specified, using the latest commit hash: " + commit_hash + ANSI_NORMAL)
}
else {
def scmVars = checkout scm
checkout scm: [$class: 'GitSCM', branches: [[name: "refs/tags/$params.github_release_tag"]], userRemoteConfigs: [[url: scmVars.GIT_URL]]]
artifact_version = params.github_release_tag
println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from github_release_tag: " + params.github_release_tag + ANSI_NORMAL)
}
echo "artifact_version: "+ artifact_version
if (!env.hub_org) {
println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL)
error 'Please resolve the errors and rerun..'
} else
println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL)
}
}
stage('Pre-Build') {
sh '''
#sed -i "s/'replication_factor': '2'/'replication_factor': '1'/g" database/data.cql

cleanWs()
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim()
echo "build_tag: " + build_tag

stage('Build') {
env.NODE_ENV = "build"
print "Environment will be : ${env.NODE_ENV}"
sh '''
export JAVA_HOME=/usr/lib/jvm/jdk-11.0.2
export PATH=$JAVA_HOME/bin:$PATH
echo $(java -version)
mvn clean install -DskipTests
mvn play2:dist -pl analytics-api
'''
}
stage('Build') {
sh '''
sed -i "s#>logs<#>/mount/data/analytics/logs/api-service<#g" analytics-api/conf/log4j2.xml
sed -i 's#${application.home:-.}/logs#/mount/data/analytics/logs/api-service#g' analytics-api/conf/logback.xml
mvn clean install -DskipTests
mvn play2:dist -pl analytics-api
'''
}
stage('Archive artifacts'){
sh """
mkdir lpa_service_artifacts
cp analytics-api/target/analytics-api-2.0-dist.zip lpa_service_artifacts
zip -j lpa_service_artifacts.zip:${artifact_version} lpa_service_artifacts/*
"""
archiveArtifacts artifacts: "lpa_service_artifacts.zip:${artifact_version}", fingerprint: true, onlyIfSuccessful: true
sh """echo {\\"artifact_name\\" : \\"lpa_service_artifacts.zip\\", \\"artifact_version\\" : \\"${artifact_version}\\", \\"node_name\\" : \\"${env.NODE_NAME}\\"} > metadata.json"""
archiveArtifacts artifacts: 'metadata.json', onlyIfSuccessful: true
currentBuild.description = artifact_version
}
stage('Package') {
dir('sunbird-analytics-service-distribution') {
sh """
cp ../analytics-api/target/analytics-api-2.0-dist.zip .
/opt/apache-maven-3.6.3/bin/mvn3.6 package -Pbuild-docker-image -Drelease-version=${build_tag}
"""
}
}
stage('Retagging'){
sh """
docker tag sunbird-analytics-service:${build_tag} ${hub_org}/sunbird-analytics-service:${build_tag}
echo {\\"image_name\\" : \\"sunbird-analytics-service\\", \\"image_tag\\" : \\"${build_tag}\\", \\"node_name\\" : \\"${env.NODE_NAME}\\"} > metadata.json
"""
}
stage('ArchiveArtifacts') {
archiveArtifacts "metadata.json"
currentBuild.description = "${build_tag}"
}
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
}
}
97 changes: 90 additions & 7 deletions analytics-api-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

<dependency>
<groupId>org.scalikejdbc</groupId>
<artifactId>scalikejdbc_2.11</artifactId>
<artifactId>scalikejdbc_${scala.maj.version}</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
Expand All @@ -146,17 +146,17 @@
</dependency>
<dependency>
<groupId>com.sksamuel.elastic4s</groupId>
<artifactId>elastic4s-http_2.11</artifactId>
<artifactId>elastic4s-http_${scala.maj.version}</artifactId>
<version>${elastic4sVersion}</version>
</dependency>
<dependency>
<groupId>com.sksamuel.elastic4s</groupId>
<artifactId>elastic4s-core_2.11</artifactId>
<artifactId>elastic4s-core_${scala.maj.version}</artifactId>
<version>${elastic4sVersion}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.11</artifactId>
<artifactId>akka-testkit_${scala.maj.version}</artifactId>
<version>${akka.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -178,7 +178,87 @@
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>

<dependency>
<groupId>de.sciss</groupId>
<artifactId>fingertree_${scala.maj.version}</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>it.ozimov</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.manub</groupId>
<artifactId>scalatest-embedded-kafka_${scala.maj.version}</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.zonky.test</groupId>
<artifactId>embedded-postgres</artifactId>
<version>1.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pl.allegro.tech</groupId>
<artifactId>embedded-elasticsearch</artifactId>
<version>2.10.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.maj.version}</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>cloud-store-sdk</artifactId>
<version>1.4.0</version>
<exclusions>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.ing.wbaa.druid</groupId>
<artifactId>scruid_${scala.maj.version}</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.8</version>
<exclusions>
<exclusion>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand All @@ -190,9 +270,12 @@
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>11</source>
<target>11</target>
<checkMultipleScalaVersions>false</checkMultipleScalaVersions>
<args>
<arg>-nobootcp</arg>
</args>
</configuration>
<executions>
<execution>
Expand Down
Loading

0 comments on commit ebad3d6

Please sign in to comment.