Skip to content

Commit bd4ecb0

Browse files
committed
init project
1 parent 40e065a commit bd4ecb0

File tree

40 files changed

+1901
-1
lines changed

40 files changed

+1901
-1
lines changed

.github/workflows/build.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Build
7+
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- '!main'
13+
# - '*' # matches every branch that doesn't contain a '/'
14+
# - '*/*' # matches every branch containing a single '/'
15+
# - '**' # matches every branch
16+
# - '!main' # excludes main
17+
pull_request:
18+
branches:
19+
- '**'
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
test:
26+
runs-on: self-hosted
27+
# runs-on: ubuntu-latest
28+
env:
29+
# define Java options for both official sbt and sbt-extras
30+
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
31+
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
- name: Set up JDK 8
36+
uses: actions/setup-java@v3
37+
with:
38+
java-version: '8'
39+
distribution: 'temurin'
40+
# cache: 'sbt'
41+
- name: Run tests & Coverage Report
42+
run: sbt coverage test coverageReport
43+
- name: Upload coverage to Codecov
44+
uses: codecov/codecov-action@v3
45+
with:
46+
files: common/target/scala-2.12/coverage-report/cobertura.xml,core/target/scala-2.12/coverage-report/cobertura.xml,teskit/target/scala-2.12/coverage-report/cobertura.xml
47+
flags: unittests
48+
fail_ci_if_error: true
49+
verbose: true
50+
51+
lint:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v3
56+
- name: Set up JDK 8
57+
uses: actions/setup-java@v3
58+
with:
59+
java-version: '8'
60+
distribution: 'temurin'
61+
# cache: 'sbt'
62+
- name: Formatting
63+
run: sbt scalafmtSbtCheck scalafmtCheck test:scalafmtCheck

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Release
7+
# Run workflow on commits to the `main` branch
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- 'main'
13+
# - '*' # matches every branch that doesn't contain a '/'
14+
# - '*/*' # matches every branch containing a single '/'
15+
# - '**' # matches every branch
16+
# - '!main' # excludes main
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
release:
23+
runs-on: self-hosted
24+
# runs-on: ubuntu-latest
25+
env:
26+
# define Java options for both official sbt and sbt-extras
27+
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
28+
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
- name: Set up JDK 8
33+
uses: actions/setup-java@v3
34+
with:
35+
java-version: '8'
36+
distribution: 'temurin'
37+
# cache: 'sbt'
38+
- name: Run tests & publish
39+
run: sbt test publish

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
*.class
22
*.log
3+
.idea
4+
*.iml
5+
sbt.json
6+
target
7+
.metals
8+
actions-runner

.scalafmt.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version=3.0.2
2+
style = defaultWithAlign
3+
align.openParenCallSite = false
4+
align.openParenDefnSite = false
5+
align.tokens = [{code = "->"}, {code = "<-"}, {code = "=>", owner = "Case"}]
6+
continuationIndent.callSite = 2
7+
continuationIndent.defnSite = 2
8+
danglingParentheses = true
9+
indentOperator = spray
10+
maxColumn = 100
11+
indentOperator.preset = "spray"
12+
danglingParentheses.preset = true
13+
project.excludeFilters = [".*\\.sbt"]
14+
rewrite.rules = [RedundantParens, SortImports]
15+
spaces.inImportCurlyBraces = false
16+
unindentTopLevelOperators = true
17+
project.git = true

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
# generic-scheduler-api
1+
<!---
2+
This file is auto-generate by a github hook please modify r.md if you don't want to loose your work
3+
-->
4+
![Build Status](https://github.com///github.com/SOFTNETWORK-APP/generic-scheduler-api/workflows/Build/badge.svg)
5+
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
6+
[![codecov](https://codecov.io/gh///github.com/SOFTNETWORK-APP/generic-scheduler-api/branch/main/graph/badge.svg)](https://codecov.io/gh///github.com/SOFTNETWORK-APP/generic-scheduler-api/)
7+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/122252a6bdfb41c3af16d31f8cefaecc)](https://www.codacy.com/gh/SOFTNETWORK-APP/generic-scheduler-api/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=SOFTNETWORK-APP/generic-scheduler-api&amp;utm_campaign=Badge_Grade)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9+
10+
# generic-scheduler-api

api/build.sbt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import app.softnetwork.sbt.build.Versions
2+
import com.typesafe.sbt.packager.docker._
3+
4+
Compile / mainClass := Some("app.softnetwork.scheduler.api.SchedulerPostgresLauncher")
5+
6+
dockerBaseImage := "openjdk:8"
7+
8+
dockerEntrypoint := Seq(s"${(Docker / defaultLinuxInstallLocation).value}/bin/entrypoint.sh")
9+
10+
dockerExposedVolumes := Seq(
11+
s"${(Docker / defaultLinuxInstallLocation).value}/conf",
12+
s"${(Docker / defaultLinuxInstallLocation).value}/logs"
13+
)
14+
15+
dockerExposedPorts := Seq(
16+
9000,
17+
5000,
18+
8558,
19+
25520
20+
)
21+
22+
dockerRepository := Some("softnetwork.jfrog.io/default-docker-local")
23+
24+
bashScriptDefines / scriptClasspath ~= (cp => "../conf" +: cp)
25+
26+
organization := "app.softnetwork.scheduler"
27+
28+
name := "scheduler-api"
29+
30+
libraryDependencies ++= Seq(
31+
"app.softnetwork.persistence" %% "persistence-jdbc" % Versions.genericPersistence
32+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include "softnetwork-jdbc-persistence.conf"
2+
include "softnetwork-scheduler.conf"
3+
4+
softnetwork.api.server.port = 9000
5+
softnetwork.api.server.request-timeout = 120 s
6+
7+
akka.cluster.roles = [${softnetwork.scheduler.akka-node-role}]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package app.softnetwork.scheduler.api
2+
3+
import akka.actor.typed.ActorSystem
4+
import app.softnetwork.persistence.jdbc.query.JdbcSchema.SchemaType
5+
import app.softnetwork.persistence.jdbc.query.{JdbcJournalProvider, JdbcSchema, JdbcSchemaProvider}
6+
import app.softnetwork.scheduler.handlers.SchedulerHandler
7+
import app.softnetwork.scheduler.launch.SchedulerApplication
8+
import app.softnetwork.scheduler.persistence.query.Entity2SchedulerProcessorStream
9+
10+
trait SchedulerApi extends SchedulerApplication with JdbcSchemaProvider {
11+
12+
def jdbcSchemaType: SchemaType = this.schemaType
13+
14+
override def entity2SchedulerProcessorStream: ActorSystem[_] => Entity2SchedulerProcessorStream =
15+
sys =>
16+
new Entity2SchedulerProcessorStream()
17+
with SchedulerHandler
18+
with JdbcJournalProvider
19+
with JdbcSchemaProvider {
20+
override lazy val schemaType: JdbcSchema.SchemaType = jdbcSchemaType
21+
22+
override implicit def system: ActorSystem[_] = sys
23+
}
24+
25+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package app.softnetwork.scheduler.api
2+
3+
import app.softnetwork.persistence.jdbc.query.PostgresSchemaProvider
4+
5+
object SchedulerPostgresLauncher extends SchedulerApi with PostgresSchemaProvider
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -u
4+
set -o pipefail
5+
6+
SAVEIFS=$IFS
7+
IFS=$(echo -en "\n\b")
8+
9+
RED='\033[0;31m'
10+
GREEN='\033[0;32m'
11+
NC='\033[0m' # No Color
12+
13+
function printError() {
14+
echo -e "${RED}$1${NC}" 1>&2
15+
}
16+
17+
function printInfo() {
18+
echo -e "${GREEN}$1${NC}" 1>&2
19+
}
20+
21+
function clean() {
22+
IFS=$SAVEIFS
23+
exit "$1"
24+
}
25+
26+
export CLUSTER_IP=$(hostname -i | awk '{print $1}')
27+
28+
/opt/docker/bin/scheduler-api -DCLUSTER_MANAGEMENT_HOST="$CLUSTER_IP"

0 commit comments

Comments
 (0)