forked from xamarin/xamarin-macios
-
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
Showing
16 changed files
with
221 additions
and
45 deletions.
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 |
---|---|---|
|
@@ -5,20 +5,34 @@ on: | |
types: [created] | ||
|
||
jobs: | ||
launchBackportBuild: | ||
setupBackport: | ||
runs-on: ubuntu-latest | ||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/sudo backport') | ||
|
||
if: github.event.issue.pull_request != '' && startswith(github.event.comment.body, '/sudo backport') | ||
outputs: | ||
target_branch: ${{ steps.parse_comment.outputs.target_branch }} | ||
steps: | ||
- uses: xamarin/[email protected] | ||
with: | ||
pull_request_url: ${{ github.event.issue.pull_request.url }} | ||
comment_body: ${{ github.event.comment.body }} | ||
comment_author: ${{ github.actor }} | ||
github_repository: ${{ github.repository }} | ||
ado_organization: ${{ secrets.ADO_PROJECTCOLLECTION }} | ||
ado_project: ${{ secrets.ADO_PROJECT }} | ||
backport_pipeline_id: ${{ secrets.BACKPORT_PIPELINEID }} | ||
ado_build_pat: ${{ secrets.ADO_BUILDPAT }} | ||
github_account_pat: ${{ secrets.SERVICEACCOUNT_PAT }} | ||
use_fork: true | ||
- name: Parse Comment | ||
id: parse_comment | ||
run: | | ||
Write-Host "Parsing $env:COMMENT" | ||
($botName, $backport, $backportTargetBranch) = [System.Text.RegularExpressions.Regex]::Split("$env:COMMENT", "\s+") | ||
echo "::set-output name=target_branch::$backportTargetBranch" | ||
shell: pwsh | ||
env: | ||
COMMENT: "${{ github.event.comment.body }}" | ||
|
||
launchBackportBuild: | ||
needs: setupBackport | ||
uses: xamarin/backport-bot-action/.github/workflows/[email protected] | ||
with: | ||
pull_request_url: ${{ github.event.issue.pull_request.url }} | ||
target_branch: ${{ needs.setupBackport.outputs.target_branch }} | ||
comment_author: ${{ github.actor }} | ||
github_repository: ${{ github.repository }} | ||
use_fork: true | ||
secrets: | ||
ado_organization: ${{ secrets.ADO_PROJECTCOLLECTION }} | ||
ado_project: ${{ secrets.ADO_PROJECT }} | ||
backport_pipeline_id: ${{ secrets.BACKPORT_PIPELINEID }} | ||
ado_build_pat: ${{ secrets.ADO_BUILDPAT }} | ||
github_account_pat: ${{ secrets.SERVICEACCOUNT_PAT }} |
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
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
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
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,97 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Diagnostics; | ||
using System.Text; | ||
|
||
using Mono.Cecil; | ||
|
||
using Xamarin.Tests; | ||
|
||
#nullable enable | ||
|
||
namespace Xamarin.Tests { | ||
[TestFixture] | ||
public class MlaunchTest : TestBaseClass { | ||
[Test] | ||
[TestCase (ApplePlatform.iOS, "ios-arm64")] | ||
[TestCase (ApplePlatform.TVOS, "tvos-arm64")] | ||
public void GetMlaunchInstallArguments (ApplePlatform platform, string runtimeIdentifiers) | ||
{ | ||
var project = "MySimpleApp"; | ||
Configuration.IgnoreIfIgnoredPlatform (platform); | ||
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||
|
||
var outputPath = Path.Combine (Cache.CreateTemporaryDirectory (), "install.sh"); | ||
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); | ||
var properties = GetDefaultProperties (runtimeIdentifiers); | ||
properties ["EnableCodeSigning"] = "false"; // Skip code signing, since that would require making sure we have code signing configured on bots. | ||
|
||
// Create the app manifest first, since it's required to compute the mlaunch install arguments | ||
DotNet.Execute ("build", project_path, properties, target: "_DetectSdkLocations;_DetectAppManifest;_CompileAppManifest;_WriteAppManifest"); | ||
|
||
properties ["MlaunchInstallScript"] = outputPath; | ||
var rv = DotNet.Execute ("build", project_path, properties, target: "ComputeMlaunchInstallArguments"); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchInstallArguments", out var mlaunchInstallArguments)) | ||
Assert.Fail ("Could not find the property 'MlaunchInstallArguments' in the binlog."); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchPath", out var mlaunchPath)) | ||
Assert.Fail ("Could not find the property 'MlaunchPath' in the binlog."); | ||
Assert.That (mlaunchPath, Does.Exist, "mlaunch existence"); | ||
|
||
var expectedArguments = new StringBuilder (); | ||
expectedArguments.Append ("--installdev "); | ||
expectedArguments.Append (appPath.Substring (Path.GetDirectoryName (project_path)!.Length + 1)).Append ('/'); | ||
expectedArguments.Append ($" --wait-for-exit:false"); | ||
Assert.AreEqual (expectedArguments.ToString (), mlaunchInstallArguments); | ||
|
||
var scriptContents = File.ReadAllText (outputPath).Trim ('\n'); | ||
var expectedScriptContents = mlaunchPath + " " + expectedArguments.ToString (); | ||
Assert.AreEqual (expectedScriptContents, scriptContents, "Script contents"); | ||
} | ||
|
||
[Test] | ||
[TestCase (ApplePlatform.iOS, "iossimulator-x64;iossimulator-arm64", ":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-16-4,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro")] | ||
[TestCase (ApplePlatform.iOS, "ios-arm64", "")] | ||
[TestCase (ApplePlatform.TVOS, "tvossimulator-arm64", ":v2:runtime=com.apple.CoreSimulator.SimRuntime.tvOS-16-4,devicetype=com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-1080p")] | ||
public void GetMlaunchRunArguments (ApplePlatform platform, string runtimeIdentifiers, string device) | ||
{ | ||
var project = "MySimpleApp"; | ||
Configuration.IgnoreIfIgnoredPlatform (platform); | ||
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); | ||
|
||
var outputPath = Path.Combine (Cache.CreateTemporaryDirectory (), "launch.sh"); | ||
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); | ||
var properties = GetDefaultProperties (runtimeIdentifiers); | ||
properties ["EnableCodeSigning"] = "false"; // Skip code signing, since that would require making sure we have code signing configured on bots. | ||
|
||
// Create the app manifest first, since it's required to compute the mlaunch run arguments | ||
DotNet.Execute ("build", project_path, properties, target: "_DetectSdkLocations;_DetectAppManifest;_CompileAppManifest;_WriteAppManifest"); | ||
|
||
properties ["MlaunchRunScript"] = outputPath; | ||
var rv = DotNet.Execute ("build", project_path, properties, target: "ComputeMlaunchRunArguments"); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchRunArguments", out var mlaunchRunArguments)) | ||
Assert.Fail ("Could not find the property 'MlaunchRunArguments' in the binlog."); | ||
|
||
if (!BinLog.TryFindPropertyValue (rv.BinLogPath, "MlaunchPath", out var mlaunchPath)) | ||
Assert.Fail ("Could not find the property 'MlaunchPath' in the binlog."); | ||
Assert.That (mlaunchPath, Does.Exist, "mlaunch existence"); | ||
|
||
var expectedArguments = new StringBuilder (); | ||
var isSim = runtimeIdentifiers.Contains ("simulator"); | ||
expectedArguments.Append (isSim ? "--launchsim " : "--launchdev "); | ||
expectedArguments.Append (appPath.Substring (Path.GetDirectoryName (project_path)!.Length + 1)).Append ('/'); | ||
if (isSim) { | ||
expectedArguments.Append (" --device \""); | ||
expectedArguments.Append (device); | ||
expectedArguments.Append ('"'); | ||
} | ||
expectedArguments.Append ($" --wait-for-exit:true"); | ||
Assert.AreEqual (expectedArguments.ToString (), mlaunchRunArguments); | ||
|
||
var scriptContents = File.ReadAllText (outputPath).Trim ('\n'); | ||
var expectedScriptContents = mlaunchPath + " " + expectedArguments.ToString (); | ||
Assert.AreEqual (expectedScriptContents, scriptContents, "Script contents"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.