Skip to content

Commit

Permalink
Merge pull request #664 from Epic-Breakfast-Productions/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
GregJohnStewart authored Aug 22, 2024
2 parents c2236d0 + 1492b22 commit 6e9efca
Show file tree
Hide file tree
Showing 145 changed files with 5,863 additions and 248 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/plugin-alertMessenger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI - Plugin - Alert Messenger

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ "**" ]
paths:
- "software/plugins/alert-messenger/**"
- ".github/workflows/plugin-alertMessenger.yml"
pull_request:
branches: [ "**" ]
paths:
- "software/plugins/alert-messenger/**"
- ".github/workflows/plugin-alertMessenger.yml"
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
defaults:
run:
working-directory: "software/plugins/alert-messenger/"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
uses: ./.github/workflows/wf-gradleBuild.yaml
with:
path: "software/plugins/alert-messenger/"
unitTest:
uses: ./.github/workflows/wf-gradleUnitTest.yaml
with:
path: "software/plugins/alert-messenger/"
intTest:
uses: ./.github/workflows/wf-gradleQuarkusIntTest.yaml
strategy:
matrix:
containerBased: [ false ] # TODO:: enable true
with:
path: "software/plugins/alert-messenger/"
containerBased: ${{ matrix.containerBased }}

25 changes: 18 additions & 7 deletions deployment/Single Host/Station-Captain/src/lib/LogUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,36 @@ class LogUtils:

@staticmethod
def setupLogging(logFile:str, console:bool=False):
Path(LogUtils.logDir).mkdir(parents=True, exist_ok=True)
LogUtils.logFile = logFile
filePresent:bool = False
if not os.path.exists(logFile):
try:
Path(LogUtils.logDir).mkdir(parents=True, exist_ok=True)
os.mknod(logFile)
LogUtils.logFile = logFile
filePresent = True
except Exception as e:
LogUtils.logFile = False
filePresent = False
else:
filePresent = True
logging.basicConfig(level=logging.NOTSET)

if console:
LogUtils.logLevel = logging.DEBUG

@staticmethod
def setupLogger(name: str) -> logging.Logger:
fh = logging.handlers.RotatingFileHandler(LogUtils.logDir+LogUtils.logFile, maxBytes=10*1024*1024, backupCount=5)
fh.setLevel(logging.DEBUG)

# sh = logging.StreamHandler()
# sh.setLevel(LogUtils.logLevel)

logOut = logging.getLogger(name)
# print(LogUtils.logLevel == logging.DEBUG)
logOut.setLevel(LogUtils.logLevel)
logOut.addHandler(fh)

if not LogUtils.logFile:
fh = logging.handlers.RotatingFileHandler(LogUtils.logDir+LogUtils.logFile, maxBytes=10*1024*1024, backupCount=5)
fh.setLevel(logging.DEBUG)
logOut.addHandler(fh)

# logOut.addHandler(sh)
return logOut

14 changes: 13 additions & 1 deletion software/libs/core-api-lib-quarkus/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>tech.ebp.oqm.lib</groupId>
<artifactId>core-api-lib-quarkus-parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
</parent>
<artifactId>core-api-lib-quarkus-deployment</artifactId>
<name>Core Api Lib Quarkus - Deployment</name>
Expand Down Expand Up @@ -74,6 +74,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<version>1.20.1</version>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>redpanda</artifactId>
<version>1.20.1</version>
<!-- <scope>test</scope>-->
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public class CoreApiLibDevserviceConfig {
*/
@WithDefault("true")
public boolean enable;

/**
* Enables kafka.
*/
@ConfigItem(name="enableKafka")
@WithDefault("false")
public boolean enableKafka;

/**
* The path of the public key file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.quarkus.smallrye.health.deployment.spi.HealthBuildItem;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.redpanda.RedpandaContainer;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
import tech.ebp.oqm.lib.core.api.quarkus.runtime.Constants;
Expand All @@ -21,73 +22,102 @@
import java.util.Map;

class CoreApiLibQuarkusProcessor {

private static final String FEATURE = "core-api-lib-quarkus";
private static final String MONGODB_DEVSERVICE_HOSTNAME = "mongodbserver";

private static final String MONGODB_DEVSERVICE_HOSTNAME = "oqm-dev-mongodb-server";
private static final String KAFKA_DEVSERVICE_HOSTNAME = "oqm-dev-kafka-server";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
List<RunTimeConfigurationDefaultBuildItem> addRestConfiguration() {
return List.of(
new RunTimeConfigurationDefaultBuildItem("quarkus.rest-client."+Constants.CORE_API_CLIENT_NAME+".url", "${quarkus." + Constants.CONFIG_ROOT_NAME + ".coreApiBaseUri}"),
new RunTimeConfigurationDefaultBuildItem("quarkus.rest-client."+Constants.CORE_API_CLIENT_OIDC_NAME+".url", "${quarkus.oidc.auth-server-url:}")
new RunTimeConfigurationDefaultBuildItem("quarkus.rest-client." + Constants.CORE_API_CLIENT_NAME + ".url", "${quarkus." + Constants.CONFIG_ROOT_NAME + ".coreApiBaseUri}"),
new RunTimeConfigurationDefaultBuildItem("quarkus.rest-client." + Constants.CORE_API_CLIENT_OIDC_NAME + ".url", "${quarkus.oidc.auth-server-url:}")
);
}

@BuildStep
HealthBuildItem addHealthCheck(CoreApiLibBuildTimeConfig buildTimeConfig) {
return new HealthBuildItem(
"tech.ebp.oqm.lib.core.api.quarkus.runtime.CoreApiHealthCheck",
buildTimeConfig.healthEnabled
);
}

@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public List<DevServicesResultBuildItem> createContainer(
LaunchModeBuildItem launchMode,
CoreApiLibBuildTimeConfig config
) {
List<DevServicesResultBuildItem> output = new ArrayList<>();
Map<String, String> mongoConnectionInfo = new HashMap<>();
Map<String, String> kafkaConnectionInfo = new HashMap<>();
{//mongodb
DockerImageName mongoImageName = DockerImageName.parse("mongo:7");

MongoDBContainer mongoDBContainer = new MongoDBContainer(mongoImageName);
mongoDBContainer.addExposedPorts();
mongoDBContainer.withNetwork(Network.SHARED);
mongoDBContainer.withNetworkAliases(MONGODB_DEVSERVICE_HOSTNAME);
mongoDBContainer.start();

mongoConnectionInfo.put("quarkus.mongodb.connection-string", "mongodb://" + MONGODB_DEVSERVICE_HOSTNAME + ":27017");

output.add(new DevServicesResultBuildItem.RunningDevService(
FEATURE,
mongoDBContainer.getContainerId(),
mongoDBContainer::close,
Map.of()
)
.toBuildItem()
.toBuildItem()
);
}
if (config.devservice.enableKafka) {
RedpandaContainer kafka = new RedpandaContainer(DockerImageName.parse("docker.redpanda.com/redpandadata/redpanda:v23.1.2"))
.withNetwork(Network.SHARED)
.withAccessToHost(true)
.withNetworkAliases(KAFKA_DEVSERVICE_HOSTNAME)
.withListener(() -> KAFKA_DEVSERVICE_HOSTNAME + ":19092");
kafka.start();

kafkaConnectionInfo.putAll(Map.of(
"quarkus.reactive-messaging.health.enabled", "true",
"mp.messaging.outgoing.events-outgoing.bootstrap.servers", String.format("PLAINTEXT://%s:%d", KAFKA_DEVSERVICE_HOSTNAME, 19092),
"devservice.kafka.bootstrapServers", kafka.getBootstrapServers(),
"mp.messaging.outgoing.events-outgoing.connector", "smallrye-kafka",
"mp.messaging.outgoing.events-outgoing.broadcast", "true",
"mp.messaging.outgoing.events-outgoing.value.serializer", "io.quarkus.kafka.client.serialization.ObjectMapperSerializer"
));

output.add(
new DevServicesResultBuildItem.RunningDevService(
FEATURE,
kafka.getContainerId(),
kafka::close,
Map.of()
).toBuildItem()
);
}
{//Base Station
DockerImageName dockerImageName = DockerImageName.parse("ebprod/oqm-core-api:" + config.devservice.coreApiVersion);
// You might want to use Quarkus config here to customise the container
OqmCoreApiWebServiceContainer container = new OqmCoreApiWebServiceContainer(dockerImageName)
.withAccessToHost(true)
.withEnv(mongoConnectionInfo)
.withNetwork(Network.SHARED);
.withAccessToHost(true)
.withEnv(mongoConnectionInfo)
.withEnv(kafkaConnectionInfo)
.withNetwork(Network.SHARED);
;

if (
config.devservice.certKeyPath.isPresent() ||
config.devservice.certPath.isPresent()
config.devservice.certPath.isPresent()
) {
if(!(config.devservice.certKeyPath.isPresent() &&
config.devservice.certPath.isPresent())){
if (!(config.devservice.certKeyPath.isPresent() &&
config.devservice.certPath.isPresent())) {
throw new RuntimeException("Must specify both cert and key for core api devservice.");
}

Expand All @@ -105,23 +135,27 @@ public List<DevServicesResultBuildItem> createContainer(
container.withEnv("mp.jwt.verify.publickey.location", "/tmp/systemCert.pem");

}

container.start();

Map<String, String> props = new HashMap<>();
props.put("quarkus." + Constants.CONFIG_ROOT_NAME + ".coreApiBaseUri", "http://" + container.getHost() + ":" + container.getPort());
props.put("quarkus.rest-client.oqmCoreApi.url", "${quarkus." + Constants.CONFIG_ROOT_NAME + ".coreApiBaseUri}");


if (!kafkaConnectionInfo.isEmpty()) {
props.put("devservice.kafka.bootstrapServers", kafkaConnectionInfo.get("devservice.kafka.bootstrapServers"));
}

output.add(new DevServicesResultBuildItem.RunningDevService(
FEATURE,
container.getContainerId(),
container::close,
props
)
.toBuildItem()
.toBuildItem()
);
}

return output;
}
}
2 changes: 1 addition & 1 deletion software/libs/core-api-lib-quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>tech.ebp.oqm.lib</groupId>
<artifactId>core-api-lib-quarkus-parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Core Api Lib Quarkus - Parent</name>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion software/libs/core-api-lib-quarkus/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>tech.ebp.oqm.lib</groupId>
<artifactId>core-api-lib-quarkus-parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
</parent>
<artifactId>core-api-lib-quarkus</artifactId>
<name>Core Api Lib Quarkus - Runtime</name>
Expand Down
8 changes: 3 additions & 5 deletions software/oqm-core-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'io.quarkus'
id "io.freefair.lombok" version "8.6"
id "io.freefair.lombok" version "8.7.1"
}

group 'com.ebp.openQuarterMaster'
Expand Down Expand Up @@ -43,17 +43,15 @@ dependencies {
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'com.fasterxml.jackson.module:jackson-module-blackbird'

implementation 'com.itextpdf:html2pdf:5.0.4'

// https://mvnrepository.com/artifact/tech.units/indriya
// https://unitsofmeasurement.gitbook.io/uom-guide/getting-started/getting-started-with-indriya
implementation 'tech.units:indriya:2.2'
implementation 'systems.uom:systems-common:2.1'
// https://mvnrepository.com/artifact/tech.uom.lib/uom-lib-jackson
implementation 'tech.uom.lib:uom-lib-jackson:2.1'

implementation 'org.apache.commons:commons-lang3:3.15.0'
implementation 'org.apache.commons:commons-compress:1.26.2'
implementation 'org.apache.commons:commons-lang3:3.16.0'
implementation 'org.apache.commons:commons-compress:1.27.0'
implementation 'org.apache.commons:commons-csv:1.11.0'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'commons-codec:commons-codec:1.17.1'
Expand Down
23 changes: 23 additions & 0 deletions software/oqm-core-api/oqm-core-api-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions software/oqm-core-api/oqm-core-api-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: oqm-core-api-chart
description: A chart to stand up the core API component for Open QuarterMaster.

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
Loading

0 comments on commit 6e9efca

Please sign in to comment.