Skip to content

Commit

Permalink
Peer config utilities (#1358)
Browse files Browse the repository at this point in the history
* Peer config utilities

* adding build and ignore

* start of InMoov2Test

* Add StaticType-based generic bounds for peer config utils (#1359)

---------

Co-authored-by: Branden Butler <[email protected]>
  • Loading branch information
supertick and AutonomicPerfectionist authored Oct 22, 2023
1 parent ef9e25b commit daf9f63
Show file tree
Hide file tree
Showing 15 changed files with 379 additions and 170 deletions.
39 changes: 2 additions & 37 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Java CI

#on: [push]

on:
push:
branches:
- develop
on: [push]

jobs:
build:
Expand All @@ -20,37 +15,7 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'

- name: Dependency Test
run: mvn test -Dtest=org.myrobotlab.framework.DependencyTest -q

- name: Build and Test with Maven
- name: Build with Maven
run: mvn --batch-mode -Dtest=!**/OpenCV* test -q

- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: semver
increment: patch

- name: Package with Maven
run: "mvn package -DskipTests -Dversion=${{ steps.version.outputs.version }} -q"

# - name: Fake Build
# run: |
# mkdir -p target
# echo ${{ github.sha }} > ./target/myrobotlab.zip

- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
files: |
./target/myrobotlab.zip
./target/myrobotlab.jar
name: "${{ steps.version.outputs.version }} Nixie"
tag_name: ${{ steps.version.outputs.version }}
generate_release_notes: true
body_path: ./release-template.md
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,7 @@ build/
/lastRestart.py
/.factorypath
start.yml
config
src/main/resources/resource/InMoov2
src/main/resources/resource/ProgramAB
*.iml
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# fast build
mvn -DskipTests package -o
# execute
mvn exec:java -Dexec.mainClass=org.myrobotlab.service.Runtime -Dexec.args="-s webgui WebGui intro Intro python Python"
# specific test
mvn test -Dtest="org.myrobotlab.service.WebGuiTest#postTest"
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/myrobotlab/codec/CodecUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidObjectException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
Expand Down Expand Up @@ -1481,6 +1482,10 @@ public static boolean isLocal(String name, String id) {
return name.substring(name.indexOf("@") + 1).equals(id);
}

public static ServiceConfig readServiceConfig(String filename) throws IOException {
return readServiceConfig(filename, new StaticType<>() {});
}

/**
* Read a YAML file given by the filename and convert it into a ServiceConfig
* object by deserialization.
Expand All @@ -1491,10 +1496,15 @@ public static boolean isLocal(String name, String id) {
* @throws IOException
* if reading the file fails
*/
public static ServiceConfig readServiceConfig(String filename) throws IOException {
public static <C extends ServiceConfig> C readServiceConfig(String filename, StaticType<C> type) throws IOException {
String data = Files.readString(Paths.get(filename));
Yaml yaml = new Yaml();
return yaml.load(data);
C parsed = yaml.load(data);
if (type.asClass().isAssignableFrom(parsed.getClass())) {
return parsed;
} else {
throw new InvalidObjectException("Deserialized type was " + parsed.getClass() + ", expected " + type + ". Deserialized object: " + parsed);
}
}

/**
Expand Down
Loading

0 comments on commit daf9f63

Please sign in to comment.