Added new powershell scripts to support windows invocation
parent
8e5895210d
commit
46ddff2c3b
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Create directory for license activation
|
||||
#
|
||||
|
||||
$ACTIVATE_LICENSE_PATH = "${env:GITHUB_WORKSPACE}/_activate-license"
|
||||
New-Item -Path "$ACTIVATE_LICENSE_PATH" -ItemType Directory
|
||||
|
||||
#
|
||||
# Run steps
|
||||
#
|
||||
|
||||
& $PSScriptRoot\steps\activate.ps1
|
||||
& $PSScriptRoot\steps\set_gitcredential.ps1
|
||||
& $PSScriptRoot\steps\run_tests.ps1
|
||||
& $PSScriptRoot\steps\return_license.ps1
|
||||
|
||||
#
|
||||
# Remove license activation directory
|
||||
#
|
||||
|
||||
Remove-Item "$ACTIVATE_LICENSE_PATH" -Recurse -Force
|
||||
|
||||
#
|
||||
# Instructions for debugging
|
||||
#
|
||||
|
||||
if ($TEST_RUNNER_EXIT_CODE -gt 0)
|
||||
{
|
||||
Write-Output ""
|
||||
Write-Output "###########################"
|
||||
Write-Output "# Failure #"
|
||||
Write-Output "###########################"
|
||||
Write-Output ""
|
||||
Write-Output "Please note that the exit code is not very descriptive."
|
||||
Write-Output "Most likely it will not help you solve the issue."
|
||||
Write-Output ""
|
||||
Write-Output "To find the reason for failure: please search for errors in the log above."
|
||||
Write-Output ""
|
||||
}
|
||||
|
||||
#
|
||||
# Exit with code from the build step.
|
||||
#
|
||||
|
||||
if ( ($USE_EXIT_CODE -eq "true") -and ($TEST_RUNNER_EXIT_CODE -ne 2) )
|
||||
{
|
||||
exit $TEST_RUNNER_EXIT_CODE
|
||||
}
|
|
@ -166,15 +166,15 @@ const Docker = {
|
|||
[
|
||||
'linux',
|
||||
new Map([
|
||||
['shell', '/bin/bash'],
|
||||
['shellCommand', '/bin/bash /dist/entrypoint.sh'],
|
||||
['sshAgent', '/ssh-agent'],
|
||||
['githubHome', '/root'],
|
||||
['githubWorkflow', '/github/workflow'],
|
||||
['githubWorkspace', '/github/workspace'],
|
||||
['stepsPathParent', `${actionFolder}/steps`],
|
||||
['stepsPathContainer', '/steps'],
|
||||
['entrypointPathParent', `${actionFolder}/entrypoint.sh`],
|
||||
['entrypointPathContainer', '/entrypoint.sh'],
|
||||
['entrypointPathParent', `${actionFolder}/`],
|
||||
['entrypointPathContainer', '/dist'],
|
||||
['knownHostsParent', ' /home/runner/.ssh/known_hosts'],
|
||||
['knownHostsContainer', '/root/.ssh/known_hosts'],
|
||||
]),
|
||||
|
@ -182,15 +182,15 @@ const Docker = {
|
|||
[
|
||||
'win32',
|
||||
new Map([
|
||||
['shell', 'powershell'],
|
||||
['shellCommand', 'powershell C:\\dist\\entrypoint.ps1'],
|
||||
['sshAgent', 'C:\\ssh-agent'],
|
||||
['githubHome', 'C:\\root'],
|
||||
['githubWorkflow', 'C:\\github\\workflow'],
|
||||
['githubWorkspace', 'C:\\github\\workspace'],
|
||||
['stepsPathParent', `${actionFolder}\\steps`],
|
||||
['stepsPathContainer', 'C:\\steps'],
|
||||
['entrypointPathParent', `${actionFolder}\\entrypoint.ps1`],
|
||||
['entrypointPathContainer', 'C:\\entrypoint.ps1'],
|
||||
['entrypointPathParent', `${actionFolder}\\`],
|
||||
['entrypointPathContainer', 'C:\\dist'],
|
||||
['knownHostsParent', 'C:\\Users\\Administrator\\.ssh\\known_hosts'],
|
||||
['knownHostsContainer', 'C:\\root\\.ssh\\known_hosts'],
|
||||
]),
|
||||
|
@ -222,7 +222,7 @@ const Docker = {
|
|||
--env GITHUB_HEAD_REF \
|
||||
--env GITHUB_BASE_REF \
|
||||
--env GITHUB_EVENT_NAME \
|
||||
--env GITHUB_WORKSPACE=/github/workspace \
|
||||
--env GITHUB_WORKSPACE="${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkspace')}" \
|
||||
--env GITHUB_ACTION \
|
||||
--env GITHUB_EVENT_PATH \
|
||||
--env RUNNER_OS \
|
||||
|
@ -231,11 +231,11 @@ const Docker = {
|
|||
--env RUNNER_WORKSPACE \
|
||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||
${sshAgent ? `--env SSH_AUTH_SOCK=${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('sshAgent')}` : ''} \
|
||||
--volume "${githubHome}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubHome')}${bindMountZ}" \
|
||||
--volume "${githubWorkflow}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkflow')}${bindMountZ}" \
|
||||
--volume "${workspace}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkspace')}${bindMountZ}" \
|
||||
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathParent')}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathContainer')}${bindMountZ}" \
|
||||
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathParent')}":"${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathContainer')}${bindMountZ}" \
|
||||
--volume "${githubHome}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubHome')}${bindMountZ}" \
|
||||
--volume "${githubWorkflow}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkflow')}${bindMountZ}" \
|
||||
--volume "${workspace}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('githubWorkspace')}${bindMountZ}" \
|
||||
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathParent')}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('stepsPathContainer')}${bindMountZ}" \
|
||||
--volume "${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathParent')}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathContainer')}${bindMountZ}" \
|
||||
${sshAgent ? `--volume ${sshAgent}:${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('sshAgent')}` : ''} \
|
||||
${sshAgent
|
||||
? `--volume ${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('knownHostParent')}${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('knownHostContainer')}${bindMountRO}`
|
||||
|
@ -243,7 +243,7 @@ const Docker = {
|
|||
${useHostNetwork ? '--net=host' : ''} \
|
||||
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
|
||||
${image} \
|
||||
${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('shell')} ${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('entrypointPathContainer')}`;
|
||||
${currentDockerPath === null || currentDockerPath === void 0 ? void 0 : currentDockerPath.get('shellCommand')}`;
|
||||
yield (0, exec_1.exec)(command, undefined, { silent });
|
||||
});
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,109 @@
|
|||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
Write-Output "Changing to $ACTIVATE_LICENSE_PATH directory."
|
||||
Push-Location "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if ( ($null -ne ${env:UNITY_LICENSE}) -or ($null -ne ${env:UNITY_LICENSE_FILE}) )
|
||||
{
|
||||
#
|
||||
# PERSONAL LICENSE MODE
|
||||
#
|
||||
# This will activate Unity, using a license file
|
||||
#
|
||||
# Note that this is the ONLY WAY for PERSONAL LICENSES in 2020.
|
||||
# * See for more details: https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/5#note_72815478
|
||||
#
|
||||
# The license file can be acquired using `game-ci/request-manual-activation-file` action.
|
||||
Write-Output "Requesting activation (personal license)"
|
||||
|
||||
# Set the license file path
|
||||
$FILE_PATH = "$ACTIVATE_LICENSE_PATH\UnityLicenseFile.ulf"
|
||||
|
||||
if ($null -ne ${env:UNITY_LICENSE})
|
||||
{
|
||||
# Copy license file from Github variables
|
||||
Add-Content -Path $FILE_PATH -Value ${env:UNITY_LICENSE}
|
||||
}
|
||||
elseif ($null -ne ${env:UNITY_LICENSE_FILE})
|
||||
{
|
||||
# Copy license file from file system
|
||||
Add-Content -Path $FILE_PATH -Value ${env:UNITY_LICENSE_FILE}
|
||||
}
|
||||
$convert = (Get-Content -Raw $FILE_PATH) -replace "`r`n","`n"
|
||||
[io.file]::WriteAllText($FILE_PATH, $convert)
|
||||
|
||||
# Activate license
|
||||
$ACTIVATION_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${env:UNITY_VERSION}\editor\Unity.exe" -ArgumentList "-batchmode -nographics -logFile $ACTIVATE_LICENSE_PATH\activate.log -quit -manualLicenseFile $FILE_PATH"
|
||||
|
||||
# Store the exit code from the verify command
|
||||
$UNITY_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode
|
||||
|
||||
# The exit code for personal activation is always 1;
|
||||
# Determine whether activation was successful.
|
||||
#
|
||||
# Successful output should include the following:
|
||||
#
|
||||
# "LICENSE SYSTEM [2020120 18:51:20] Next license update check is after 2019-11-25T18:23:38"
|
||||
#
|
||||
$ACTIVATION_SUCCESSFUL = (Get-Content $ACTIVATE_LICENSE_PATH\activate.log | Select-String 'Next license update check is after' | Measure-Object -line | Select-Object -Expand Lines)
|
||||
|
||||
# Set exit code to 0 if activation was successful
|
||||
if ($ACTIVATION_SUCCESSFUL -eq 1)
|
||||
{
|
||||
$UNITY_EXIT_CODE = 0
|
||||
}
|
||||
|
||||
# Remove license file
|
||||
Remove-Item -Force $FILE_PATH
|
||||
}
|
||||
elseif ( ($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}) )
|
||||
{
|
||||
#
|
||||
# PROFESSIONAL (SERIAL) LICENSE MODE
|
||||
#
|
||||
# This will activate unity, using the activating process.
|
||||
#
|
||||
# Note: This is the preferred way for PROFESSIONAL LICENSES.
|
||||
#
|
||||
Write-Output "Requesting activation (professional license)"
|
||||
|
||||
# Activate license
|
||||
$ACTIVATION_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${env:UNITY_VERSION}\editor\Unity.exe" -ArgumentList "-batchmode -nographics -logFile $ACTIVATE_LICENSE_PATH\activate.log -quit -serial ${env:UNITY_SERIAL} -username ${env:UNITY_EMAIL} -password ${env:UNITY_PASSWORD}"
|
||||
|
||||
# Store the exit code from the verify command
|
||||
$UNITY_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode
|
||||
}
|
||||
else
|
||||
{
|
||||
#
|
||||
# NO LICENSE ACTIVATION STRATEGY MATCHED
|
||||
#
|
||||
# This will exit since no activation strategies could be matched.
|
||||
#
|
||||
Write-Output "License activation strategy could not be determined."
|
||||
Write-Output ""
|
||||
Write-Output "Visit https://game.ci/docs/github/getting-started for more"
|
||||
Write-Output "details on how to set up one of the possible activation strategies."
|
||||
|
||||
# Immediately exit as no UNITY_EXIT_CODE can be derived.
|
||||
exit 1;
|
||||
}
|
||||
|
||||
#
|
||||
# Display information about the result
|
||||
#
|
||||
Get-Content $ACTIVATE_LICENSE_PATH\activate.log
|
||||
if ($UNITY_EXIT_CODE -eq 0)
|
||||
{
|
||||
# Activation was a success
|
||||
Write-Output "Activation complete."
|
||||
}
|
||||
else
|
||||
{
|
||||
# Activation failed so exit with the code from the license verification step
|
||||
Write-Output "Unclassified error occured while trying to activate license."
|
||||
Write-Output "Exit code was: $UNITY_EXIT_CODE"
|
||||
exit $UNITY_EXIT_CODE
|
||||
}
|
||||
|
||||
# Return to previous working directory
|
||||
Pop-Location
|
|
@ -0,0 +1,18 @@
|
|||
# Run in ACTIVATE_LICENSE_PATH directory
|
||||
Write-Output "Changing to $ACTIVATE_LICENSE_PATH directory."
|
||||
Push-Location "$ACTIVATE_LICENSE_PATH"
|
||||
|
||||
if ($null -ne ${env:UNITY_SERIAL})
|
||||
{
|
||||
#
|
||||
# PROFESSIONAL (SERIAL) LICENSE MODE
|
||||
#
|
||||
# This will return the license that is currently in use.
|
||||
#
|
||||
$RETURN_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${env:UNITY_VERSION}\editor\Unity.exe" -ArgumentList "-batchmode -nographics -logFile $FULL_ARTIFACTS_PATH\deactivate.log -quit -returnlicense"
|
||||
|
||||
Get-Content $FULL_ARTIFACTS_PATH\deactivate.log
|
||||
}
|
||||
|
||||
# Return to previous working directory
|
||||
Pop-Location
|
|
@ -0,0 +1,118 @@
|
|||
#
|
||||
# Set and display project path
|
||||
#
|
||||
|
||||
$UNITY_PROJECT_PATH = "${env:GITHUB_WORKSPACE}/${env:PROJECT_PATH}"
|
||||
Write-Output "Using project path $UNITY_PROJECT_PATH"
|
||||
|
||||
#
|
||||
# Set and display the artifacts path
|
||||
#
|
||||
|
||||
Write-Output "Using artifacts path ${env:ARTIFACTS_PATH} to save test results."
|
||||
$FULL_ARTIFACTS_PATH = "${env:GITHUB_WORKSPACE}\${env:ARTIFACTS_PATH}"
|
||||
|
||||
#
|
||||
# Set and display the coverage results path
|
||||
#
|
||||
|
||||
Write-Output "Using coverage results path ${env:COVERAGE_RESULTS_PATH} to save test coverage results."
|
||||
$FULL_COVERAGE_RESULTS_PATH = "${env:GITHUB_WORKSPACE}\${env:COVERAGE_RESULTS_PATH}"
|
||||
|
||||
#
|
||||
# Display custom parameters
|
||||
#
|
||||
|
||||
Write-Output "Using custom parameters ${env:CUSTOM_PARAMETERS}"
|
||||
|
||||
# The following tests are 2019 mode (requires Unity 2019.2.11f1 or later)
|
||||
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
|
||||
|
||||
#
|
||||
# Display the unity version
|
||||
#
|
||||
|
||||
Write-Output "Using Unity version ${env:UNITY_VERSION} to test."
|
||||
|
||||
#
|
||||
# Overall info
|
||||
#
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "###########################"
|
||||
Write-Output "# Artifacts folder #"
|
||||
Write-Output "###########################"
|
||||
Write-Output ""
|
||||
Write-Output "Creating $FULL_ARTIFACTS_PATH if it does not exist."
|
||||
New-Item -Path "$FULL_ARTIFACTS_PATH" -ItemType Directory
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "###########################"
|
||||
Write-Output "# Project directory #"
|
||||
Write-Output "###########################"
|
||||
Write-Output ""
|
||||
Get-ChildItem -Hidden -Path $UNITY_PROJECT_PATH
|
||||
|
||||
#
|
||||
# Testing for each platform
|
||||
#
|
||||
foreach ( $platform in ${env:TEST_PLATFORMS}.Split(";") )
|
||||
{
|
||||
Write-Output ""
|
||||
Write-Output "###########################"
|
||||
Write-Output "# Testing in $platform #"
|
||||
Write-Output "###########################"
|
||||
Write-Output ""
|
||||
|
||||
if ( $platform -ne "COMBINE_RESULTS" )
|
||||
{
|
||||
$runTests = "-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml"
|
||||
}
|
||||
else
|
||||
{
|
||||
$runTests = "-quit"
|
||||
}
|
||||
|
||||
$TEST_OUTPUT = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${env:UNITY_VERSION}\editor\Unity.exe" -ArgumentList "-batchmode -logFile $FULL_ARTIFACTS_PATH\$platform.log -projectPath $UNITY_PROJECT_PATH -coverageResultsPath $FULL_COVERAGE_RESULTS_PATH $runTests -enableCodeCoverage -debugCodeOptimization -coverageOptions ${env:COVERAGE_OPTIONS} ${env:CUSTOM_PARAMETERS}"
|
||||
|
||||
# Catch exit code
|
||||
$TEST_EXIT_CODE = $TEST_OUTPUT.ExitCode
|
||||
|
||||
# Print unity log output
|
||||
Get-Content "$FULL_ARTIFACTS_PATH/$platform.log"
|
||||
|
||||
# Display results
|
||||
if ($TEST_EXIT_CODE -eq 0)
|
||||
{
|
||||
Write-Output "Run succeeded, no failures occurred";
|
||||
}
|
||||
elseif ($TEST_EXIT_CODE -eq 2)
|
||||
{
|
||||
Write-Output "Run succeeded, some tests failed";
|
||||
}
|
||||
elseif ($TEST_EXIT_CODE -eq 3)
|
||||
{
|
||||
Write-Output "Run failure (other failure)";
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Unexpected exit code $TEST_EXIT_CODE";
|
||||
}
|
||||
|
||||
if ( $TEST_EXIT_CODE -ne 0)
|
||||
{
|
||||
$TEST_RUNNER_EXIT_CODE = $TEST_EXIT_CODE
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "###########################"
|
||||
Write-Output "# $platform Results #"
|
||||
Write-Output "###########################"
|
||||
Write-Output ""
|
||||
|
||||
if ($platform -ne "COMBINE_RESULTS")
|
||||
{
|
||||
Get-Content "$FULL_ARTIFACTS_PATH/$platform-results.xml"
|
||||
Get-Content "$FULL_ARTIFACTS_PATH/$platform-results.xml" | Select-String "test-run" | Select-String "Passed"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
if ($null -eq ${env:GIT_PRIVATE_TOKEN})
|
||||
{
|
||||
Write-Output "GIT_PRIVATE_TOKEN unset skipping"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "GIT_PRIVATE_TOKEN is set configuring git credentials"
|
||||
|
||||
git config --global credential.helper store
|
||||
git config --global --replace-all url.https://github.com/.insteadOf ssh://git@github.com/
|
||||
git config --global --add url.https://github.com/.insteadOf git@github.com
|
||||
|
||||
git config --global url."https://token:${env:GIT_PRIVATE_TOKEN}@github.com/".insteadOf "https://github.com/"
|
||||
git config --global url."https://ssh:${env:GIT_PRIVATE_TOKEN}@github.com/".insteadOf "ssh://git@github.com/"
|
||||
git config --global url."https://git:${env:GIT_PRIVATE_TOKEN}@github.com/".insteadOf "git@github.com:"
|
||||
}
|
||||
|
||||
Write-Output "---------- git config --list -------------"
|
||||
git config --list
|
||||
|
||||
Write-Output "---------- git config --list --show-origin -------------"
|
||||
git config --list --show-origin
|
Loading…
Reference in New Issue