Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Build Pipeline to Support Multiple Java Versions #352

Open
wants to merge 77 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
40cded4
Dependency analysis
gmkumar2005 Aug 20, 2024
13e0d1d
pojos upgraded to spring-boot-332 and jdk21
gmkumar2005 Aug 21, 2024
1484069
middleware-commons upgraded. Test and lombok dependencies moved to pa…
gmkumar2005 Aug 21, 2024
7b14a33
Replaced javax with jakarta in pojos and middleware-commons, standard…
gmkumar2005 Aug 21, 2024
60d4b69
Replaced javax with jakarta in middleware-bom > Authorization. Disabl…
gmkumar2005 Aug 22, 2024
034f31b
Replaced javax with jakarta in middleware-bom > Authorization. Disabl…
gmkumar2005 Aug 22, 2024
2b532eb
auth0 and identity provider migrated
gmkumar2005 Aug 22, 2024
c292ad8
generic-iam migrated
gmkumar2005 Aug 22, 2024
16af6d7
keycloak migrated
gmkumar2005 Aug 22, 2024
9b20895
validation migrated
gmkumar2005 Aug 22, 2024
ad8a5e9
elastic-search migrated
gmkumar2005 Aug 22, 2024
c573e3f
elastic-search migrated
gmkumar2005 Aug 22, 2024
2d04a74
workflow migrated
gmkumar2005 Aug 22, 2024
659f85c
validators migrated
gmkumar2005 Aug 22, 2024
efdbd40
apitest migrated
gmkumar2005 Aug 22, 2024
6412994
view-templates migrated
gmkumar2005 Aug 22, 2024
06f6d72
registry-interceptor migrated
gmkumar2005 Aug 22, 2024
43c99e0
actor and actors migrated
gmkumar2005 Aug 22, 2024
02feeb9
boosted versions fixed compile issues in registry. Test case migrated…
gmkumar2005 Aug 23, 2024
a60fccc
182 passing
gmkumar2005 Aug 23, 2024
524a9b0
243 passing
gmkumar2005 Aug 25, 2024
9c6beee
245 passing
gmkumar2005 Aug 25, 2024
13d2a28
250 passing
gmkumar2005 Aug 26, 2024
adf1732
255 passing
gmkumar2005 Aug 26, 2024
507e2ff
255 passing
gmkumar2005 Aug 26, 2024
fafe79f
claims all passing
gmkumar2005 Aug 26, 2024
0e47539
api test upgraded
gmkumar2005 Aug 26, 2024
440ebe8
fixed maven install
gmkumar2005 Aug 27, 2024
f3a97f9
Fixed cyclic dependencies, boosted few versions, added packaging mave…
gmkumar2005 Aug 27, 2024
d930cdb
Updated janusgraph. Added source levels
gmkumar2005 Aug 27, 2024
a8d2525
Added maven-enforcer-plugin
gmkumar2005 Aug 27, 2024
19ca38b
Github actions upgraded to jdk21
gmkumar2005 Aug 27, 2024
43c5325
Dockerfile upgraded to eclipse-temurin:21-jdk
gmkumar2005 Aug 27, 2024
427fe13
version numbers moved to main pom
gmkumar2005 Sep 3, 2024
e38a887
Akka upgraded. POM Cleanup
gmkumar2005 Sep 13, 2024
3dcdacc
Sync test scenarios in karate are working
gmkumar2005 Sep 18, 2024
70523f9
Sync test scenarios in karate are working
gmkumar2005 Sep 18, 2024
bb650e0
github autobuild upgraded to jdk21
gmkumar2005 Oct 3, 2024
e8a6495
github autobuild upgraded to jdk21
gmkumar2005 Oct 3, 2024
05d6934
mvn wrapper upgraded and api-test upgraded
gmkumar2005 Oct 3, 2024
37a7b48
debug maven
gmkumar2005 Oct 3, 2024
8426bcb
debug maven with -X
gmkumar2005 Oct 3, 2024
7399e70
maven wrapper
gmkumar2005 Oct 3, 2024
74ddc68
DockerFile fixes
gmkumar2005 Oct 3, 2024
c134698
Issue #SBCOSS-211 : Refactor Build Pipeline to Support Multiple Java …
aimansharief Oct 17, 2024
9522ee9
Issue #SBCOSS-211 : Update Maven CI workflow to build legacy services
aimansharief Oct 17, 2024
5381d3d
Issue #SBCOSS-211 : Changing the order of build
aimansharief Oct 17, 2024
457094d
Issue #SBCOSS-211 : Update workflow to configure dependencies before …
aimansharief Oct 17, 2024
fd48a6d
Issue #SBCOSS-211 : Update workflow to build each job sequentially
aimansharief Oct 17, 2024
a6e1dc6
Issue #SBCOSS-211 : Added maven-compiler-plugin so that it uses the c…
aimansharief Oct 17, 2024
84e7c90
Issue #SBCOSS-211 fix: Updated pom file to use the maven compiler
aimansharief Oct 17, 2024
cf0066a
Issue #SBCOSS-211 fix: Updated build workflow to build claim with jav…
aimansharief Oct 17, 2024
f62f647
Restored services to revision fe7b98d5e566754df9a96f3bc3241ae5a2628b06
gmkumar2005 Oct 22, 2024
1c49bac
Merge branch 'spring_boot_332' into refactor_build
aimansharief Oct 22, 2024
a0b3673
Reverted the pom
aimansharief Oct 22, 2024
9eb49e1
Setting java version 21 while running tests
aimansharief Oct 22, 2024
273c332
fix : Updating lombok version
aimansharief Oct 24, 2024
393bb68
fix : Reverting the lombok version
aimansharief Oct 25, 2024
5b5f7e7
fix : Updating lombok version
aimansharief Oct 25, 2024
0891523
fix : Splitting the tests for services using jdk11 and jdk21
aimansharief Oct 28, 2024
dbdfbe6
Revert "fix : Splitting the tests for services using jdk11 and jdk21"
aimansharief Nov 5, 2024
24bcfb0
fix : Running test independent of the build
aimansharief Nov 5, 2024
2a786ba
fix: Updating maven compiler property to use java 21
aimansharief Nov 6, 2024
4124069
Fixed false positives in codeQL
gmkumar2005 Nov 7, 2024
fc388c2
Merge branch 'Sunbird-RC:main' into refactor_build
aimansharief Nov 8, 2024
6891c3f
Merge branch 'Sunbird-RC:main' into spring_boot_332
aimansharief Nov 8, 2024
cf3b1f1
Merge branch 'spring_boot_332' into refactor_build
aimansharief Nov 8, 2024
bdafee7
Upgraded codeql to v3
gmkumar2005 Nov 8, 2024
12f6532
Merge remote-tracking branch 'origin/spring_boot_332' into spring_boo…
gmkumar2005 Nov 8, 2024
a9ddd71
Merge branch 'spring_boot_332' into refactor_build
aimansharief Nov 8, 2024
39621cf
added query-filters
gmkumar2005 Nov 8, 2024
f797253
Merge branch 'spring_boot_332' into refactor_build
aimansharief Nov 9, 2024
d31a8c8
added spring-disabled-csrf-protection, unvalidated-url-forward
gmkumar2005 Nov 9, 2024
3c7424f
Merge branch 'spring_boot_332' into refactor_build
aimansharief Nov 10, 2024
5afdb72
syntax error fixed
gmkumar2005 Nov 11, 2024
eebdc73
removed config file
gmkumar2005 Nov 11, 2024
93eeeb0
Merge branch 'spring_boot_332' into refactor_build
aimansharief Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 21 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,29 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config: |
query-filters:
- exclude:
id: java/URL-forward-from-remote-source
- exclude:
id: java/Disabled-Spring-CSRF-protection
- exclude:
id: java/unvalidated-url-forward
- exclude:
id: java/spring-disabled-csrf-protection


# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
Expand All @@ -53,7 +71,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +85,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
6 changes: 3 additions & 3 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs: # This workflow contains a single job called "greet"
steps: # Runs a single command using the runners shell
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Setup Golang
uses: actions/setup-go@v3
Expand Down
100 changes: 82 additions & 18 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,109 @@ on:
branches: [ main ]

jobs:
build:
build-java-21:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'

- name: Set up properties
run: sh configure-dependencies.sh

- name: Check disk space before freeing up space
run: df -h

- name: Free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/.ghcup/ghc/9.6.4

- name: Check disk space before build
run: df -h

- name: Install Docker Compose
run: |
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

- name: Build
run: make build-main
env:
JAVA_HOME: ${{ steps.setup-java.outputs.java-home }}

- name: Check disk space after build
run: df -h

build-java-11:
runs-on: ubuntu-latest
needs: build-java-21 # This ensures that Java 21 build runs first
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
cache: 'maven'

- name: Set up properties
run: sh configure-dependencies.sh
- name: Check space before free up the space

- name: Check disk space before freeing up space
run: df -h

- name: Free up space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/.ghcup/ghc/9.6.4
- name: Check space before tests

- name: Check disk space before build
run: df -h

- name: Install Docker Compose
run: |
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
# debug step
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
# with:
# ## limits ssh access and adds the ssh public key for the user which triggered the workflow ie holashchand
# limit-access-to-actor: true
- name: Build and test
run: make test
- name: Check space after tests

- name: Build
run: make build-legacy-services
env:
JAVA_HOME: ${{ steps.setup-java.outputs.java-home }}

- name: Check disk space after build
run: df -h
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Run all the containers and test
# run : make test

test:
needs: [build-java-11]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Install Docker Compose
run: |
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
## debug step
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
# with:
# ## limits ssh access and adds the ssh public key for the user which triggered the workflow
# limit-access-to-actor: true

- name: Run tests
run: make test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ out
db-data*
vault-data
es-data*
keycloak-mobile*.jar
keycloak-mobile*.jar
.lh
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
29 changes: 21 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
.PHONY: show-dir
show-dir:
@echo "Current directory: $$(pwd)"
@echo "Files in current directory:"
@ls -l

#SOURCES = $(wildcard java/**/*.java)
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SOURCES := $(call rwildcard,java/,*.java)
RELEASE_VERSION = v2.0.1
RELEASE_VERSION = 2.0.4-SNAPSHOT
IMAGES := ghcr.io/sunbird-rc/sunbird-rc-core ghcr.io/sunbird-rc/sunbird-rc-claim-ms \
ghcr.io/sunbird-rc/sunbird-rc-notification-service ghcr.io/sunbird-rc/sunbird-rc-metrics \
ghcr.io/sunbird-rc/id-gen-service ghcr.io/sunbird-rc/encryption-service \
ghcr.io/sunbird-rc/sunbird-rc-identity-service ghcr.io/sunbird-rc/sunbird-rc-credential-schema \
ghcr.io/sunbird-rc/sunbird-rc-credentials-service
build: java/registry/target/registry.jar
echo ${SOURCES}

build: build-main build-legacy-services

build-legacy-services:
make -C services/id-gen-service docker
make -C services/encryption-service docker

build-main: java/registry/target/registry.jar
#echo ${SOURCES}
rm -rf java/claim/target/*.jar
cd target && rm -rf * && jar xvf ../java/registry/target/registry.jar && cp ../java/Dockerfile ./ && docker build -t ghcr.io/sunbird-rc/sunbird-rc-core .
@$(MAKE) show-dir
mkdir -p target
cd target && rm -rf * &&cp ../java/registry/target/registry-$(RELEASE_VERSION).jar ./registry.jar && cp ../java/Dockerfile ./ && docker build -t ghcr.io/sunbird-rc/sunbird-rc-core .
make -C java/claim
make -C services/notification-service docker
make -C services/metrics docker
make -C services/id-gen-service docker
make -C services/encryption-service docker
make -C services/identity-service/ docker
make -C services/credential-schema docker
make -C services/credentials-service/ docker


java/registry/target/registry.jar: $(SOURCES)
echo $(SOURCES)
#echo $(SOURCES)
sh configure-dependencies.sh
cd java && ./mvnw clean install

test: build
test:
@docker-compose -f docker-compose-v1.yml down
@sudo rm -rf db-data* es-data* || echo "no permission to delete"
# test with distributed definition manager and native search
Expand Down
3 changes: 2 additions & 1 deletion java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ hs_err_pid*
target
mvn*
.mvn*
deps/keycloak/providers/keycloak-mobile-number-login-spi-1.0-SNAPSHOT.jar
deps/keycloak/providers/keycloak-mobile-number-login-spi-1.0-SNAPSHOT.jar
.lh
1 change: 1 addition & 0 deletions java/.mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static void main(String args[]) {
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
Expand Down
Binary file added java/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
Loading
Loading