浏览代码

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
/devin-main-fix
Devin Miller 4 年前
当前提交
8c627e74
共有 23 个文件被更改,包括 306 次插入3 次删除
  1. 1
      .gitignore
  2. 2
      tutorials/pick_and_place/PickAndPlaceProject/.gitignore
  3. 6
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs
  4. 20
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/DemoScripts.asmdef
  5. 7
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/DemoScripts.asmdef.meta
  6. 8
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests.meta
  7. 30
      .yamato/yamato-config.yml
  8. 8
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode.meta
  9. 25
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/EditMode.asmdef
  10. 7
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/EditMode.asmdef.meta
  11. 57
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PickAndPlaceMessageGenerationtests.cs
  12. 11
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PickAndPlaceMessageGenerationtests.cs.meta
  13. 59
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PlayerBuildTests.cs
  14. 11
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PlayerBuildTests.cs.meta
  15. 8
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode.meta
  16. 25
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/ExamplePlayModeTests.cs
  17. 11
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/ExamplePlayModeTests.cs.meta
  18. 6
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/PlayMode.asmdef
  19. 7
      tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/PlayMode.asmdef.meta

1
.gitignore


.DS_Store
.swp
.idea
.vscode/
tutorials/pick_and_place/PickAndPlaceProject/Packages/packages-lock.json

2
tutorials/pick_and_place/PickAndPlaceProject/.gitignore


/[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

6
tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs


#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 RosSharp;
using RosSharp.Control;
using RosSharp.Urdf.Editor;
using UnityEditor;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;

20
tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/DemoScripts.asmdef


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

7
tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/DemoScripts.asmdef.meta


fileFormatVersion: 2
guid: 80312ba658e2b5f41bf853abe51fbe2f
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests.meta


fileFormatVersion: 2
guid: 8ab3f0793a13742c58ee40e7c1bf73e4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

30
.yamato/yamato-config.yml


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/**/*"

8
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode.meta


fileFormatVersion: 2
guid: 57c9a6ed3fa4a4e42ab47f690e44db03
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

25
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/EditMode.asmdef


{
"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
}

7
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/EditMode.asmdef.meta


fileFormatVersion: 2
guid: a430adad278b44ebb8b3bc6d4181a527
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

57
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PickAndPlaceMessageGenerationtests.cs


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();
}
}

11
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PickAndPlaceMessageGenerationtests.cs.meta


fileFormatVersion: 2
guid: a84ef41da4c4a4fd881173d43b570892
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

59
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PlayerBuildTests.cs


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;
}
}
}

11
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/EditMode/PlayerBuildTests.cs.meta


fileFormatVersion: 2
guid: 67261ab008654224e8e9827b63f6eaa1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode.meta


fileFormatVersion: 2
guid: af49543032ae6465eab1b4d935a78a72
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

25
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/ExamplePlayModeTests.cs


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;
}
}

11
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/ExamplePlayModeTests.cs.meta


fileFormatVersion: 2
guid: 098c56433a9ff4552bcc76f884bbb828
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

6
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/PlayMode.asmdef


{
"name": "PlayMode",
"optionalUnityReferences": [
"TestAssemblies"
]
}

7
tutorials/pick_and_place/PickAndPlaceProject/Assets/Tests/PlayMode/PlayMode.asmdef.meta


fileFormatVersion: 2
guid: a75a5b773e30f42b1b6b03e2cc7ab0dd
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存