Skip to content

Commit

Permalink
test of new build
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 3, 2024
1 parent 8f64e84 commit a698341
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 45 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build, Test, and Deploy

on:
push:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven

- name: Increment version and build with Maven
id: increment-version
run: |
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Current version: $CURRENT_VERSION"
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F '.' '{print $1"."$2"."$3+1}')
echo "New version: $NEW_VERSION"
echo "artifact-version=$NEW_VERSION" >> $GITHUB_ENV
- name: Build and test with Maven
run: mvn clean install --batch-mode -Dartifact.version=${{ env.artifact-version }}

deploy:
runs-on: ubuntu-latest
needs: build-and-test
if: success()

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "us-east-1"
run: |
FILE_PATH=$(find target -name "*.jar" | head -n 1)
if [ -z "$FILE_PATH" ]; then
echo "Artifact not found!" && exit 1
fi
S3_URI="s3://your-bucket-name/maven-repo/path/to/artifact/"
aws s3 cp "$FILE_PATH" "$S3_URI"
- name: Verify artifact upload
run: |
aws s3 ls s3://your-bucket-name/maven-repo/path/to/artifact/
78 changes: 37 additions & 41 deletions InMoov2.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
# import org.myrobotlab.framework.Platform as Platform
# import org.myrobotlab.service.Runtime as Runtime

def printx(format_string, *args):
import datetime
current_time = datetime.datetime.now().strftime("%H:%M:%S")
formatted_message = format_string % args # Using old % formatting suitable for Python 2.7
print("%s: %s" % (current_time, formatted_message))



def onPythonMessage(msg):
"""Initial processing and routing for all messages.
Expand All @@ -76,6 +83,7 @@ def onPythonMessage(msg):
Args:
msg (_type_): tunnelled message, with data message
"""
# print("onPythonMessage", msg)
try:
if not isinstance(msg, dict):
# From Jython msg is a java object
Expand All @@ -96,6 +104,10 @@ def onPythonMessage(msg):
# first parameter will always be InMoov2 name
params_array.insert(0, name)

# filter out chatty heartbeat and peak
if method_name != "onHeartbeat" and method_name != "onPeak":
printx("%s", method_name)

# Check if the method exists in the global namespace
if method_name in globals() and callable(globals()[method_name]):
cmd = "result = {}(*params_array)".format(method_name)
Expand Down Expand Up @@ -139,6 +151,8 @@ def onAudioEnd(name, data):


def onStartSpeaking(name, text):
print("onStartSpeaking", text)

global runtime

# print("onStartSpeaking", text)
Expand All @@ -162,7 +176,7 @@ def onStartSpeaking(name, text):


def onEndSpeaking(name, text):
# print("onEndSpeaking", text)
print("onEndSpeaking", text)
robot = runtime.getService(name)
robot.disableRandom()

Expand Down Expand Up @@ -197,41 +211,33 @@ def onEndSpeaking(name, text):

# Sensor events begin ========================================

def onSense(name, sensed):
"""onSense is a pir sensor event
which is rebroadcasted from InMoov2
SensorData.
Args:
sensed (boolean): True or False
"""
print("onSense", sensed)


def onPirOn(name):
print('onPirOn("{}")'.format(name))
current_time = datetime.now().strftime("%H:%M:%S")
print('onPirOn("{}") at {}'.format(name, current_time))
robot = runtime.getService(name)
robot.setPredicate(name + ".pir", True)
if robot:
robot.setPredicate(name + ".pir", True)

# sleeping
if "sleep" == robot.getState():
robot.fire("wake")
# sleeping
if "sleep" == robot.getState():
robot.fire("wake")

# FIXME - chatBot.getResponse("SYSTEM_EVENT onPirOn")
# robot.speak("I feel your presence")
# FIXME - chatBot.getResponse("SYSTEM_EVENT onPirOn")
# robot.speak("I feel your presence")

# FIXME - "remove" this is custom
neoPixel = robot.getPeer("neoPixel")
if neoPixel:
neoPixel.setPixel(130, 120, 200, 150)
neoPixel.setPixel(131, 120, 200, 170)
neoPixel.setPixel(140, 120, 200, 150)
neoPixel.setPixel(141, 120, 200, 170)
neoPixel.writeMatrix()
# FIXME - "remove" this is custom
neoPixel = robot.getPeer("neoPixel")
if neoPixel:
neoPixel.setPixel(130, 120, 200, 150)
neoPixel.setPixel(131, 120, 200, 170)
neoPixel.setPixel(140, 120, 200, 150)
neoPixel.setPixel(141, 120, 200, 170)
neoPixel.writeMatrix()


def onPirOff(name):
print('onPirOff("{}")'.format(name))
current_time = datetime.now().strftime("%H:%M:%S")
print('onPirOff("{}") at {}'.format(name, current_time))
robot = runtime.getService(name)
robot.setPredicate(name + ".pir", False)
# FIXME - chatBot.getResponse("SYSTEM_EVENT onPirOff")
Expand Down Expand Up @@ -264,14 +270,14 @@ def onTopic(topic_event):
Args:
topic (_type_): _description_
"""
print("onTopic", topic_event.topic)
# FIXME - find a solution for the hardcoded name !
# route through inmoov add name as field
robot = runtime.getService(topic_event.src)
mouth = robot.getPeer("mouth")
if mouth:
# mouth.speak("New topic, the topic is " + topic_event.topic)
pass
print("onTopic", topic_event.topic)


# Topic events end ==========================================
Expand Down Expand Up @@ -519,17 +525,6 @@ def onSession(session_event):
# chatBot.setTopic("new_user")


def onMessage(msg):
print("onMessage", msg)
robot = runtime.getService(msg.sender)
print("onMessage.method", msg.method)
print("onMessage.data", msg.data)
robot.info("onMessage.method " + msg.method)
robot.info("onMessage.data " + str(msg.data))
# eval(msg.method)(msg.data
# auto invoke method
# expand parameters ?


def on_new_user(data):
print("on_new_user", data)
Expand Down Expand Up @@ -568,6 +563,7 @@ def onHeartbeat(name, heartbeat):
time_in_idle = current_time - int(robot.getPredicate("idle.start"))
# FIXME - this should be a configurable value 15 minutes
# print("time_in_idle", time_in_idle)
# FIXME - configurable value
if time_in_idle > 900000:
robot.fire("sleep")

Expand Down Expand Up @@ -608,7 +604,7 @@ def onHeartbeat(name, heartbeat):


def onPeak(name, volume):
print("onPeak", name, volume)
# print("onPeak", name, volume)
robot = runtime.getService(name)

# FIXME - remove this custom
Expand Down
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.inmoov</groupId>
<artifactId>inmoov2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>InMoov2</name>
<!-- TODO: make this project depend on myrobotlab and have it's own unit tests / custom code -->
<!-- Add the assembly plugin. -->

<properties>
<finalName>inmoov2-${version}</finalName>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<finalName>${finalName}</finalName>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
Expand All @@ -35,4 +42,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

0 comments on commit a698341

Please sign in to comment.