AIRO-405 Adding Yamato boilerplate to Robotics Hub (#144)

* Adding testing boilerplate

* Adding tests to run after message generation

* Tweaks to ensure run works in Bokken image

* Enabling audio by default, but disabling it in yamato config
This commit is contained in:
Devin Miller (Unity) 2021-02-16 13:39:20 -08:00 коммит произвёл Devin Miller
Родитель e9f67e0783
Коммит 71af832ca0
19 изменённых файлов: 306 добавлений и 3 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,5 @@
.DS_Store
.swp
.idea
.vscode/
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json

30
.yamato/yamato-config.yml Normal file
Просмотреть файл

@ -0,0 +1,30 @@
name: Robotics Hub Tests
agent:
type: Unity::VM
image: robotics/ci-ubuntu20:latest
flavor: i1.large
variables:
PATH: /root/.local/bin:/home/bokken/bin:/home/bokken/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/home/bokken/.npm-global/bin
commands:
- git submodule update --init --recursive
# TODO: Fix this hack - our bokken image is missing a .NET dependency (System.CodeDom) without which causes compilation to fail
- rm ./tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.*
# This is another hack to ensure audio is disabled. Unity built-in audio fails to initialize in our Bokken image.
- "sed -i -e '/m_DisableAudio/ s/: .*/: 1/' ./tutorials/pick_and_place/PickAndPlaceProject/ProjectSettings/AudioManager.asset"
- python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
- unity-downloader-cli -u 2020.2.0b9 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published
- git clone git@github.cds.internal.unity3d.com:unity/utr.git utr
- utr/utr --testproject=./tutorials/pick_and_place/PickAndPlaceProject --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --editorTestsCategories MessageGeneration
- mkdir -p ./tutorials/pick_and_place/PickAndPlaceProject/Assets/Scripts && cp ./tutorials/pick_and_place/Scripts/*.cs ./tutorials/pick_and_place/PickAndPlaceProject/Assets
- utr/utr --testproject=./tutorials/pick_and_place/PickAndPlaceProject --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --editorTestsCategories BuildTests
triggers:
cancel_old_ci: true
expression: |
(pull_request.target eq "main" AND
NOT pull_request.push.changes.all match ["**/*.md","**/*.jpg","**/*.jpeg","**/*.gif","**/*.pdf"]) OR
(push.branch eq "dev" AND
NOT push.changes.all match ["**/*.md","**/*.jpg","**/*.jpeg","**/*.gif","**/*.pdf"])
artifacts:
logs:
paths:
- "test-results/**/*"

Просмотреть файл

@ -9,6 +9,8 @@
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
/[Aa]ssets/[Rr]os[Mm]essages/
/[Aa]ssets/[Rr]os[Mm]essages.meta
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data

Просмотреть файл

@ -1,14 +1,14 @@
#if UNITY_EDITOR
using Microsoft.CSharp;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf.Editor;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using RosSharp;
using RosSharp.Control;
using RosSharp.Urdf.Editor;
using UnityEditor;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

Просмотреть файл

@ -0,0 +1,20 @@
{
"name": "DemoScripts",
"rootNamespace": "",
"references": [
"GUID:625bfc588fb96c74696858f2c467e978",
"GUID:b1ef917f7a8a86a4eb639ec2352edbf8",
"GUID:465c1207fffb96245a352265e7622205"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 80312ba658e2b5f41bf853abe51fbe2f
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8ab3f0793a13742c58ee40e7c1bf73e4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57c9a6ed3fa4a4e42ab47f690e44db03
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,25 @@
{
"name": "EditMode",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Unity.Robotics.ROSTCPConnector.Editor",
"Unity.Robotics.ROSTCPConnector"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a430adad278b44ebb8b3bc6d4181a527
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Unity.Robotics.ROSTCPConnector.MessageGeneration;
using Unity.Robotics.ROSTCPConnector.Editor.MessageGeneration;
using UnityEditor;
[TestFixture]
[Category("MessageGeneration")]
public class PickAndPlaceMessageGenerationTests
{
// Relative path to the directory containing the catkin packages
static readonly string k_ROSDirectory = Path.GetFullPath(Path.Combine("..", "ROS", "src"));
static string m_MessageGenOutputPath => MessageGenBrowserSettings.Get().outputPath;
// Define more individual messages to run generation on within this test case enumerable
static IEnumerable<TestCaseData> IndividualMessages()
{
yield return new TestCaseData(Path.Combine(k_ROSDirectory, "moveit_msgs", "msg", "RobotTrajectory.msg"));
}
// Define directories of message files to be generated here
static IEnumerable<TestCaseData> MessageDirectories()
{
yield return new TestCaseData(Path.Combine(k_ROSDirectory, "niryo_moveit", "msg"));
}
// Define directories of service files to be generated here
static IEnumerable<TestCaseData> ServiceDirectories()
{
yield return new TestCaseData(Path.Combine(k_ROSDirectory, "niryo_moveit", "srv"));
}
[Test]
[TestCaseSource(nameof(IndividualMessages))]
public void TestMessageBuildSingle_ThrowsNoExceptions(string messageToBuild)
{
MessageAutoGen.GenerateSingleMessage(messageToBuild, m_MessageGenOutputPath);
AssetDatabase.Refresh();
}
[Test]
[TestCaseSource(nameof(MessageDirectories))]
public void TestMessageBuildDirectory_ThrowsNoExceptions(string directoryToBuild)
{
MessageAutoGen.GenerateDirectoryMessages(directoryToBuild, m_MessageGenOutputPath);
AssetDatabase.Refresh();
}
[Test]
[TestCaseSource(nameof(ServiceDirectories))]
public void TestServiceBuildDirectory_ThrowsNoExceptions(string directoryToBuild)
{
ServiceAutoGen.GenerateDirectoryServices(directoryToBuild, m_MessageGenOutputPath);
AssetDatabase.Refresh();
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a84ef41da4c4a4fd881173d43b570892
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEditor.TestTools;
using UnityEngine;
using UnityEngine.TestTools;
namespace BuildTests
{
[TestFixture]
[Category("BuildTests")]
public class PlayerBuilder
{
List<EditorBuildSettingsScene> m_EditorBuildSettingsScenes = new List<EditorBuildSettingsScene>();
BuildSummary m_Summary;
string m_BuildPath = "Build";
[UnityPlatform(RuntimePlatform.WindowsEditor)]
[RequirePlatformSupport(BuildTarget.StandaloneWindows64)]
[Test]
public void BuildPlayerStandaloneWindows64()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, " BuildTarget.StandaloneWindows64 failed to build");
}
[RequirePlatformSupport(BuildTarget.StandaloneLinux64)]
[Test]
public void BuildPlayerLinux()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}
[UnityPlatform(RuntimePlatform.OSXEditor)]
[RequirePlatformSupport(BuildTarget.StandaloneOSX)]
[Test]
public void BuildPlayerOSX()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}
void BuildPlayer(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string buildOutputPath, BuildOptions buildOptions,
out BuildReport buildReport, out BuildSummary buildSummary)
{
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.locationPathName = buildOutputPath;
buildPlayerOptions.target = buildTarget;
buildPlayerOptions.options = buildOptions;
buildPlayerOptions.targetGroup = buildTargetGroup;
buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);
buildSummary = buildReport.summary;
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67261ab008654224e8e9827b63f6eaa1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: af49543032ae6465eab1b4d935a78a72
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class ExamplePlayModeTests
{
// A Test behaves as an ordinary method
[Test]
public void ExamplePlayModeTestsSimplePasses()
{
// Use the Assert class to test conditions
}
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame.
[UnityTest]
public IEnumerator ExamplePlayModeTestsWithEnumeratorPasses()
{
// Use the Assert class to test conditions.
// Use yield to skip a frame.
yield return null;
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 098c56433a9ff4552bcc76f884bbb828
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,6 @@
{
"name": "PlayMode",
"optionalUnityReferences": [
"TestAssemblies"
]
}

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a75a5b773e30f42b1b6b03e2cc7ab0dd
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: