-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thibault Gouala
committed
Mar 1, 2018
1 parent
6a80017
commit b8b6cec
Showing
4 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Continuous Integration | ||
====================== | ||
|
||
.Peek was designed to provide a quick feedback to Unity users about the status of their project, but also to be nicely integrated | ||
on any Continuous Integration pipeline. | ||
|
||
Through the :ref:`doc_advanced_programmatic-control` of DotPeek, you can ensure that your CI run .DotPeek with consistant settings. | ||
|
||
Hereunder are more ways of optimizing .Peek usage on a CI machine. | ||
|
||
Getting informed when build report is ready | ||
------------------------------------------- | ||
|
||
For optimized performances, .Peek generate your build report on threads. It means that when you call Unity on the command line, | ||
you should not do it with the parameter `-quit`. This would quit the editor as soon as the Unity editor main thread finished | ||
the task it was assigned on the command line. | ||
|
||
To allow you to quit unity after the report was generated, .Peek provides you the interface `IDotPeekListener`. You first need | ||
to implement it : | ||
|
||
.. code-block:: c# | ||
private class DotPeekListener : IDotPeekListener | ||
{ | ||
public void DoBuildReportGenerated(string reportAbsolutePath) | ||
{ | ||
//do here what you want after the build is generated | ||
} | ||
} | ||
And then to provide this listener to .Peek : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Listener = new DotPeekListener(); | ||
Below is a whole functional usage example : | ||
|
||
.. code-block:: c# | ||
using UnityEditor; | ||
using WellFired.Peek.Application.Unity.Editor; | ||
[InitializeOnLoad] | ||
public static class DotPeekInitializer | ||
{ | ||
static DotPeekInitializer() | ||
{ | ||
DotPeek.Instance.Listener = new DotPeekListener(); | ||
} | ||
private class DotPeekListener : IDotPeekListener | ||
{ | ||
public void DoBuildReportGenerated(string reportAbsolutePath) | ||
{ | ||
//Will quit Unity with error code 0, indicating no error happened. | ||
EditorApplication.Exit(0); | ||
} | ||
} | ||
} | ||
The parameter ``reportAbsolutePath`` is the path to your freshly generated report. It can be useful if you want to send the report | ||
to an other machine for example (website server, NAS, ...) | ||
|
||
VCS Version | ||
----------- | ||
|
||
If .Peek option is enabled and your project versions are tracked through GIT or SVN, the commid id at build time will be | ||
automatically saved with your generated report. This is done through the terminal of your machine. | ||
|
||
If for any reason .Peek cannot access the terminal of the machine it is running on, you can provide an implementation of | ||
``IVCS`` and return to .Peek the value you want : | ||
|
||
.. code-block:: c# | ||
private interface IVCS | ||
{ | ||
string GetCommitId(); | ||
} | ||
This can be useful for example if the access to the commit id can be done only through the parameters passed to Unity through | ||
the command line. Here an illustration : | ||
|
||
The command being called : | ||
|
||
.. code-block:: c# | ||
/Applications/Unity/Unity.app/Contents/MacOS/Unity -VCS aa2e32w -batchmode -executeMethod MyEditorScript.PerformBuild | ||
The implementation of the static function being called in Unity : | ||
|
||
.. code-block:: c# | ||
using UnityEditor; | ||
class MyEditorScript | ||
{ | ||
static void PerformBuild () | ||
{ | ||
DotPeek.Instance.CustomVCS = new DotPeekVCS(); | ||
string[] scenes = { "Assets/MyScene.unity" }; | ||
BuildPipeline.BuildPlayer(scenes, ...); | ||
} | ||
} | ||
with ``DotPeekVCS`` implemented this way : | ||
|
||
.. code-block:: c# | ||
private class DotPeekVCS : IVCS | ||
{ | ||
public string GetCommitId() | ||
{ | ||
var args = Environment.GetCommandLineArgs().ToList(); | ||
var optionPosition = Environment.GetCommandLineArgs().ToList().IndexOf("-VCS"); | ||
var vcsCommitId = args[optionPosition + 1]; | ||
return vcsCommitId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. _doc_advanced_programmatic-control: | ||
|
||
Programmatic Control | ||
==================== | ||
|
||
Settings | ||
-------- | ||
|
||
All the settings you can access through .Peek UI are available through code and can be read or overwritten. | ||
|
||
To do so : | ||
|
||
1. Add the required using : | ||
|
||
.. code-block:: c# | ||
using WellFired.Peek.Application.Unity.Editor; | ||
2. Access and modify your .Peek personal options (stored on your computer only, see :ref:`doc_ui-overview_settings-page` for more information) : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Storage.PersonalOptions.BuildReportPath = "../DotPeekReports"; | ||
DotPeek.Instance.Storage.PersonalOptions.AutomaticallyShowReportAfterBuild = false; | ||
3. Access and modify your .Peek team-shared options : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Storage.TeamOptions.TrackVCSVersion = false; | ||
4. Save your changes to ensure .Peek can access updated settings : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Storage.Save(); | ||
.. warning:: Saving step cannot be ommited. Indeed, it will ensure settings that were modified are written to the disk and | ||
are accessible to the whole .Peek application. | ||
|
||
.. tip:: .Peek Storage is thread safe, so the thread you are accessing it from does not matter. | ||
|
||
Callbacks Order | ||
--------------- | ||
|
||
DotPeek build generation is driven by two callbacks automatically called by Unity when building : | ||
|
||
* `IPreprocessBuild.OnPreprocessBuild <https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuild.html>`_ which happens just | ||
before the build starts. | ||
|
||
When it is called, .Peek will start counting the time used to build and get the VCS commit ID of your project. | ||
Note that if beforehand some files were not commited, .Peek will add *-unsync* behind the commit ID. | ||
|
||
| | ||
* `IPostprocessBuild.OnPostprocessBuild <https://docs.unity3d.com/ScriptReference/Build.IPostprocessBuild.html>`_ which is | ||
called once the build is done. | ||
|
||
When it is called, the time elapsed to make the build is saved and the report generated. Note that at that moment, | ||
all the files that are in the project, but were not added to the build are considered as unused assets. | ||
|
||
Different modules in your project may use these callbacks, and Unity will decide which one to call first based on | ||
`IPreprocessBuild.callbackOrder and IPostprocessBuild.callbackOrder <https://docs.unity3d.com/ScriptReference/Build.IOrderedCallback.html>`_ | ||
|
||
.Peek by default try to be called as early as possible and as late as possible, but you can programmatically change this | ||
behaviour by : | ||
|
||
1. Adding the required using : | ||
|
||
.. code-block:: c# | ||
using WellFired.Peek.Application.Unity.Editor; | ||
2. Modifying the callback order : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Storage.TeamOptions.PrebuildCallbackOrder = int.MinValue + 1; | ||
DotPeek.Instance.Storage.TeamOptions.PostbuildCallbackOrder = int.MaxValue - 1; | ||
4. Saving your changes to ensure .Peek can access updated settings : | ||
|
||
.. code-block:: c# | ||
DotPeek.Instance.Storage.Save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters