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

Peer config utilities #1358

Merged
merged 4 commits into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
@@ -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/version-increment@2023.9.3
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
@@ -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
@@ -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"

14 changes: 12 additions & 2 deletions src/main/java/org/myrobotlab/codec/CodecUtils.java
Original file line number Diff line number Diff line change
@@ -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;
@@ -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.
@@ -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);
}
}

/**
Loading