4 Commits

3 changed files with 70 additions and 21 deletions

View File

@@ -1,8 +1,9 @@
name: Java CI with Maven
on:
workflow_dispatch:
push:
branches: [ "main" ]
branches: [ "dev", "cleanup" ]
tags:
- 'v*.*.*'
pull_request:
@@ -11,51 +12,93 @@ on:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
working-directory: main
- name: Upload built JAR
uses: actions/upload-artifact@v4
with:
name: package
path: main/target/*.jar
- name: Generate dependency graph
run: mvn -B -f main/pom.xml com.github.ferstl:depgraph-maven-plugin:4.0.1:graph
- name: Upload dependency graph artifact
uses: actions/upload-artifact@v4
with:
name: dependency-graph
path: main/target/**
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven (Skip Tests)
run: mvn -B package -DskipTests
working-directory: main
- name: Create JPackage App Image
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "dist"
jpackage --name "DTSS" `
--input main/target `
--main-jar main-1.0-SNAPSHOT.jar `
--dest dist `
--type app-image `
--win-console
- name: Inject java.exe
shell: pwsh
run: |
$javaPath = (Get-Command java).Source
Copy-Item -Path $javaPath -Destination "dist/DTSS/runtime/bin/"
- name: Zip Windows Release
shell: pwsh
run: |
Compress-Archive -Path "dist/DTSS" -DestinationPath "dist/DTSS-Windows.zip"
- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: windows-package
path: dist/DTSS-Windows.zip
publish-release:
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/')
needs: [build, build-windows]
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
permissions:
contents: write
steps:
- name: Download built JAR
- name: Download Linux JAR
uses: actions/download-artifact@v4
with:
name: package
path: main/target/
- name: Download Windows Zip
uses: actions/download-artifact@v4
with:
name: windows-package
path: windows-dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: main/target/*.jar
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'snapshot-build' }}
name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Manual Snapshot Build' }}
draft: false
prerelease: true
make_latest: false
files: |
main/target/*.jar
windows-dist/*.zip

View File

@@ -95,18 +95,24 @@ public class SimulationProcessManager {
builder = new ProcessBuilder(javaBin, "-cp", classpath, className);
}
// this is a linux thing - not sure about windows
// get the OS temp folder
// Linux: /tmp/
// Windows: %AppData%\Local\Temp\
String tempDir = System.getProperty("java.io.tmpdir");
String logName = className.substring(className.lastIndexOf('.') + 1) + (arg != null ? "-" + arg : "") + ".log";
File logFile = new File("/tmp/" + logName);
// use the (File parent, String child) constructor to handle slash/backslash
// automatically
File logFile = new File(tempDir, logName);
builder.redirectOutput(logFile);
builder.redirectError(logFile);
Process process = builder.start();
runningProcesses.add(process);
System.out.println("Started " + className + (arg != null ? " " + arg : ""));
}
public boolean isSimulationRunning() {
return !runningProcesses.isEmpty() && runningProcesses.stream().anyMatch(Process::isAlive);
// print where the logs are actually going
System.out.println("Logs redirected to: " + logFile.getAbsolutePath());
}
}

View File

@@ -133,8 +133,8 @@ public class TrafficLightCoordinationTest {
List<TrafficLight> lights = intersectionProcess.getIntersection().getTrafficLights();
boolean[] hasBeenGreen = new boolean[lights.size()];
// Monitor for 60 seconds (enough time for all lights to cycle: 18+18+12 = 48s)
long endTime = System.currentTimeMillis() + 60000;
// Monitor for 10 seconds (enough time for all lights to cycle: 18+18+12 = 48s)
long endTime = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < endTime) {
for (int i = 0; i < lights.size(); i++) {