Skip to content

Commit 006d6e4

Browse files
Ruo-Ping DongChris Elion
andauthored
Backport AcademyStepper fix in #4532 to verified branch (#4637)
* bring in bugfix from #4532 * add meta files * remove extra file * update yamato tests * use v2 action and pin python version (#4568) * update changelog Co-authored-by: Chris Elion <[email protected]>
1 parent e67bc08 commit 006d6e4

File tree

17 files changed

+564
-5
lines changed

17 files changed

+564
-5
lines changed

.github/workflows/pre-commit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v1
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.7.x
1416
- uses: actions/setup-ruby@v1
1517
with:
1618
ruby-version: '2.6'

.yamato/com.unity.ml-agents-test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ test_editors:
33
# 2018.4 doesn't support code-coverage
44
coverageOptions:
55
minCoveragePct: 0
6+
# We want some scene tests to run in the DevProject, but packages there only support 2019+
7+
testProject: Project
68
- version: 2019.3
79
coverageOptions: --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+Unity.ML-Agents'
810
minCoveragePct: 72
11+
testProject: DevProject
912
- version: 2020.1
1013
coverageOptions: --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+Unity.ML-Agents'
1114
minCoveragePct: 72
15+
testProject: DevProject
1216
- version: 2020.2
1317
coverageOptions: --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+Unity.ML-Agents'
1418
minCoveragePct: 72
19+
testProject: DevProject
1520
trunk_editor:
1621
- version: trunk
1722
coverageOptions: --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+Unity.ML-Agents'
1823
minCoveragePct: 72
24+
testProject: DevProject
1925
test_platforms:
2026
- name: win
2127
type: Unity::VM
@@ -61,7 +67,7 @@ test_{{ platform.name }}_{{ editor.version }}:
6167
flavor: {{ platform.flavor}}
6268
commands:
6369
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
64-
- upm-ci package test -u {{ editor.version }} --package-path com.unity.ml-agents {{ editor.coverageOptions }}
70+
- upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} {{ editor.coverageOptions }} --extra-utr-arg "reruncount=2"
6571
- python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ editor.minCoveragePct }}
6672
artifacts:
6773
logs:
@@ -75,6 +81,7 @@ test_{{ platform.name }}_{{ editor.version }}:
7581
changes:
7682
only:
7783
- "com.unity.ml-agents/**"
84+
- "{{ editor.testProject }}/**"
7885
- "ml-agents/tests/yamato/**"
7986
- ".yamato/com.unity.ml-agents-test.yml"
8087
{% endif %}
@@ -96,7 +103,7 @@ test_{{ platform.name }}_trunk:
96103
{% if platform.name == "win" %}
97104
- upm-ci package test -u "C:\build\output\Unity-Technologies\ml-agents\.Editor" --package-path com.unity.ml-agents {{ editor.coverageOptions }}
98105
{% else %}
99-
- upm-ci package test -u {{ editor.version }} --package-path com.unity.ml-agents {{ editor.coverageOptions }}
106+
- upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} {{ editor.coverageOptions }} --extra-utr-arg "reruncount=2"
100107
{% endif %}
101108
- python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ editor.minCoveragePct }}
102109
artifacts:

DevProject/Assets/ML-Agents.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DevProject/Assets/ML-Agents/Scripts.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DevProject/Assets/ML-Agents/Scripts/Tests.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DevProject/Assets/ML-Agents/Scripts/Tests/Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DevProject/Assets/ML-Agents/Scripts/Tests/Runtime/AcademyTest.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections;
2+
using NUnit.Framework;
3+
using UnityEngine.TestTools;
4+
using UnityEngine;
5+
using UnityEngine.SceneManagement;
6+
using Unity.MLAgents;
7+
#if UNITY_EDITOR
8+
using UnityEditor.SceneManagement;
9+
#endif
10+
11+
namespace Tests
12+
{
13+
public class AcademyStepperTest
14+
{
15+
[SetUp]
16+
public void Setup()
17+
{
18+
SceneManager.LoadScene("ML-Agents/Scripts/Tests/Runtime/AcademyTest/AcademyStepperTestScene");
19+
}
20+
21+
/// <summary>
22+
/// Verify in each update, the Academy is only stepped once.
23+
/// </summary>
24+
[UnityTest]
25+
public IEnumerator AcademyStepperCleanupPasses()
26+
{
27+
var academy = Academy.Instance;
28+
int initStepCount = academy.TotalStepCount;
29+
for (var i = 0; i < 5; i++)
30+
{
31+
yield return new WaitForFixedUpdate();
32+
Assert.True(academy.TotalStepCount - initStepCount == i + 1);
33+
}
34+
}
35+
}
36+
}

DevProject/Assets/ML-Agents/Scripts/Tests/Runtime/AcademyTest/AcademyStepperTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)