Skip to content
Open
Show file tree
Hide file tree
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
129 changes: 129 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Choreo -> ChoreoLib Integration Test

on: [pull_request, push]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
generate:
name: "Generate trajectories for integration test"
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{secrets.GITHUB_TOKEN}}

- name: Install Linux dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y \
build-essential \
curl \
file \
libayatana-appindicator3-dev \
libgtk-3-dev \
librsvg2-dev \
libssl-dev \
libwebkit2gtk-4.0-dev \
wget

- name: Set up sccache
uses: mozilla-actions/[email protected]
- name: Cargo test Generate latest
run: cargo test -- --include-ignored integration_tests::generate::generate::generate_latest
- uses: actions/upload-artifact@v4
with:
name: swerve.traj
path: ./src-core/test-tmp-latest/swerve/swerve.traj
- uses: actions/upload-artifact@v4
with:
name: differential.traj
path: ./src-core/test-tmp-latest/differential/differential.traj

test-host:
needs: [generate]
env:
MACOSX_DEPLOYMENT_TARGET: 13.3
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
artifact-name: Windows-x86_64
build-options:
- os: ubuntu-22.04

# FIXME: Link failure on commands library
# - os: windows-2022
# artifact-name: Windows-aarch64
# build-options: -Pbuildwinarm64 -Ponlywindowsarm64

- os: macOS-13
artifact-name: macOS-x86_64
build-options:

- os: macOS-14
artifact-name: macOS-arm64
build-options:

name: "Test C++ and Java / ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
persist-credentials: false
token: ${{secrets.GITHUB_TOKEN}}

- name: Fetch all history and metadata
run: git fetch --prune --unshallow

- name: Download swerve trajectory
uses: actions/download-artifact@v4
with:
path: ./choreolib/src/test/resources/
pattern: "swerve.traj"
- name: Download differential trajectory
uses: actions/download-artifact@v4
with:
path: ./choreolib/src/test/resources/
pattern: "differential.traj"
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17

- name: Test with Gradle
working-directory: choreolib
run: ./gradlew test -Dprofile=integration ${{ matrix.build-options }}

test-python:
name: "Test Python"
needs: [generate]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
token: ${{secrets.GITHUB_TOKEN}}

- uses: actions/setup-python@v5
with:
python-version: 3.12

- run: pip3 install build wheel pytest

- run: python3 -m build
working-directory: ./choreolib/py
- run: pip3 install --no-cache-dir dist/*.whl
working-directory: ./choreolib/py
- run: pytest
working-directory: ./choreolib/py



3 changes: 3 additions & 0 deletions choreolib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ test {
events "failed"
exceptionFormat "full"
}
if (System.properties['profile'] != 'integration') {
exclude '**/IntegrationTest*'
}
}

if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
Expand Down
20 changes: 20 additions & 0 deletions choreolib/src/test/java/choreo/IntegrationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package choreo;

import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.IOException;

import org.junit.jupiter.api.Test;

import choreo.Choreo;
import choreo.trajectory.TrajectoryTestHelper;
import edu.wpi.first.wpilibj.Filesystem;

public class IntegrationTests {
@Test
void readDeployDirectory() throws IOException {
var swerveString = TrajectoryTestHelper.getResourceFileAsString("swerve.traj");
Choreo.loadTrajectoryString(swerveString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
package choreo.trajectory;

import edu.wpi.first.math.geometry.Pose2d;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.stream.Collectors;

public class TrajectoryTestHelper {
private static final double DT = 0.005;
Expand Down Expand Up @@ -58,4 +64,22 @@ Trajectory<SampleType> linearTrajectory(

return (Trajectory<SampleType>) trajectory;
}

/**
* Reads given resource file as a string.
*
* @param fileName path to the resource file
* @return the file's contents
* @throws IOException if read fails for any reason
*/
public static String getResourceFileAsString(String fileName) throws IOException {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
try (InputStream is = classLoader.getResourceAsStream(fileName)) {
if (is == null) return null;
try (InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr)) {
return reader.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
}
Loading
Loading