Compare commits

...

5 Commits

Author SHA1 Message Date
Skjalg S. Mæhre
3d5d2f5834 Add chownFilesTo (#187)
* add chownFilesTo

* added missing newline

* added more chownFilesTo
2022-06-24 12:59:01 +02:00
Matthew Shiroma
e8774f3837 Added Windows Support (#184)
* Modifying js files to account for win support

* Added new powershell scripts to support windows invocation

* Fixed undefined error in stack trace logic

* Added new func for resolving image tag default

* Changed structure of docker.js to match new standard
2022-05-24 01:41:36 +02:00
Nick Maltbie
d95f760d49 Changed eableCyclomaticComplexity to generateAdditionalMetrics (#183)
* Changed eableCyclomaticComplexity to generateAdditionalMetrics for coverageOptions

* updated codecoverage to version 1.1.1
2022-04-22 01:08:44 +02:00
Nick Maltbie
96562463cf Code Coverage Support (#182)
* Added basic framework for enable code coverage

* Added basic coverage results building and combination

* fixed ENABLE_CODE_COVERAGE to be `true` or `false`

* Added code coverage project to manifest

* Updated to add more tests for code coverage build

* Updated coverage parameter documentation

* Fixed small syntax error

* Enabled code coverage flag for code coverage tests

* Fixed error in test file build

* Updated project run settings

* Fixed error when creating combined code coverage results

* Updated testing workflows

* updated test workflows

* Updated parameters and added tests

* Updated tests and bash script for running

* Updated run_tests.sh script to simplfy some parameters

* Updated run_tests to remove incorrect ';'

* Updated run_tests script

* Fixed small syntax error

* Fixed for loop in run_tests.sh

* Updated run_tests syntax error for '=' operator

* Fixed runTests variable assignment

* Fixed parameters for running tests via bash

* Corrected bash arguments

* Updated test cases in main.yml

* Updated parameter names and default values for code coverage

* Fixed broken paths for coverage results upload in main.yml

* Corrected names of coverage results artifacts
2022-04-21 10:50:37 +02:00
dependabot[bot]
ec4f39253f Bump actions/upload-artifact from 2 to 3 (#180)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 12:24:59 +02:00
21 changed files with 3387 additions and 2819 deletions

View File

@@ -62,7 +62,7 @@ jobs:
testMode: ${{ matrix.testMode }}
artifactsPath: ${{ matrix.testMode }}-artifacts
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: Test results for ${{ matrix.testMode }}
path: ${{ steps.tests.outputs.artifactsPath }}
@@ -105,16 +105,25 @@ jobs:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: all
coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+MyScripts'
# Test implicit artifactsPath, by not setting it
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Test results (all)
path: ${{ steps.allTests.outputs.artifactsPath }}
retention-days: 14
# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Coverage results (all)
path: ${{ steps.allTests.outputs.coveragePath }}
retention-days: 14
testRunnerInEditMode:
name: Test edit mode 📝
runs-on: ubuntu-latest
@@ -156,12 +165,20 @@ jobs:
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Test results (edit mode)
path: ${{ steps.editMode.outputs.artifactsPath }}
retention-days: 14
# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Coverage results (edit mode)
path: ${{ steps.editMode.outputs.coveragePath }}
retention-days: 14
testRunnerInPlayMode:
name: Test play mode 📺
runs-on: ubuntu-latest
@@ -203,12 +220,20 @@ jobs:
# Upload artifacts
- name: Upload test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Test results (play mode)
path: ${{ steps.playMode.outputs.artifactsPath }}
retention-days: 14
# Upload coverage
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: Coverage results (play mode)
path: ${{ steps.playMode.outputs.coveragePath }}
retention-days: 14
testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest
@@ -258,7 +283,7 @@ jobs:
# Upload combined artifacts
- name: Upload combined test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Test results (combined)
path: artifacts/

View File

@@ -20,6 +20,10 @@ inputs:
required: false
default: 'all'
description: 'The type of tests to be run by the test runner.'
coverageOptions:
required: false
default: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport'
description: 'Optional coverage parameters for the -coverageOptions argument.'
artifactsPath:
required: false
default: 'artifacts'
@@ -44,9 +48,15 @@ inputs:
required: false
default: 'Test Results'
description: 'Name for the check run that is created when a github token is provided.'
chownFilesTo:
required: false
default: ''
description: 'User and optionally group (user or user:group or uid:gid) to give ownership of the resulting build artifacts'
outputs:
artifactsPath:
description: 'Path where the artifacts are stored'
description: 'Path where the artifacts are stored.'
coveragePath:
description: 'Path where the code coverage results are stored.'
branding:
icon: 'box'
color: 'gray-dark'

48
dist/entrypoint.ps1 vendored Normal file
View File

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

5433
dist/index.js generated vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

110
dist/steps/activate.ps1 vendored Normal file
View File

@@ -0,0 +1,110 @@
# 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)
Get-ChildItem -Path $FILE_PATH
# 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

18
dist/steps/return_license.ps1 vendored Normal file
View File

@@ -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

118
dist/steps/run_tests.ps1 vendored Normal file
View File

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

View File

@@ -14,27 +14,18 @@ echo "Using project path \"$UNITY_PROJECT_PATH\"."
echo "Using artifacts path \"$ARTIFACTS_PATH\" to save test results."
FULL_ARTIFACTS_PATH=$GITHUB_WORKSPACE/$ARTIFACTS_PATH
#
# Set and display the coverage results path
#
echo "Using coverage results path \"$COVERAGE_RESULTS_PATH\" to save test coverage results."
FULL_COVERAGE_RESULTS_PATH=$GITHUB_WORKSPACE/$COVERAGE_RESULTS_PATH
#
# Display custom parameters
#
echo "Using custom parameters $CUSTOM_PARAMETERS."
# Set the modes for testing
case $TEST_MODE in
editmode)
echo "Edit mode selected for testing."
EDIT_MODE=true
;;
playmode)
echo "Play mode selected for testing."
PLAY_MODE=true
;;
*)
echo "All modes selected for testing."
EDIT_MODE=true
PLAY_MODE=true
;;
esac
echo "Using custom parameters $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
@@ -65,118 +56,77 @@ echo ""
ls -alh $UNITY_PROJECT_PATH
#
# Testing in EditMode
# Testing for each platform
#
EDIT_MODE_EXIT_CODE=0
if [ "$EDIT_MODE" = "true" ]; then
for platform in ${TEST_PLATFORMS//;/ }; do
echo ""
echo "###########################"
echo "# Testing in EditMode #"
echo "# Testing in $platform #"
echo "###########################"
echo ""
if [[ "$platform" != "COMBINE_RESULTS" ]]; then
runTests="-runTests -testPlatform $platform -testResults $FULL_ARTIFACTS_PATH/$platform-results.xml"
else
runTests="-quit"
fi
unity-editor \
-batchmode \
-logFile "$FULL_ARTIFACTS_PATH/editmode.log" \
-logFile "$FULL_ARTIFACTS_PATH/$platform.log" \
-projectPath "$UNITY_PROJECT_PATH" \
-runTests \
-testPlatform editmode \
-testResults "$FULL_ARTIFACTS_PATH/editmode-results.xml" \
-coverageResultsPath "$FULL_COVERAGE_RESULTS_PATH" \
$runTests \
-enableCodeCoverage \
-debugCodeOptimization \
-coverageOptions "$COVERAGE_OPTIONS" \
$CUSTOM_PARAMETERS
# Catch exit code
EDIT_MODE_EXIT_CODE=$?
TEST_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/editmode.log"
cat "$FULL_ARTIFACTS_PATH/$platform.log"
# Display results
if [ $EDIT_MODE_EXIT_CODE -eq 0 ]; then
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $EDIT_MODE_EXIT_CODE -eq 2 ]; then
elif [ $TEST_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $EDIT_MODE_EXIT_CODE -eq 3 ]; then
elif [ $TEST_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $EDIT_MODE_EXIT_CODE";
echo "Unexpected exit code $TEST_EXIT_CODE";
fi
fi
#
# Testing in PlayMode
#
PLAY_MODE_EXIT_CODE=0
if [ "$PLAY_MODE" = "true" ]; then
echo ""
echo "###########################"
echo "# Testing in PlayMode #"
echo "###########################"
echo ""
unity-editor \
-batchmode \
-logFile "$FULL_ARTIFACTS_PATH/playmode.log" \
-projectPath "$UNITY_PROJECT_PATH" \
-runTests \
-testPlatform playmode \
-testResults "$FULL_ARTIFACTS_PATH/playmode-results.xml" \
$CUSTOM_PARAMETERS
# Catch exit code
PLAY_MODE_EXIT_CODE=$?
# Print unity log output
cat "$FULL_ARTIFACTS_PATH/playmode.log"
# Display results
if [ $PLAY_MODE_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $PLAY_MODE_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $PLAY_MODE_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $PLAY_MODE_EXIT_CODE";
if [ $TEST_EXIT_CODE -ne 0 ]; then
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE
fi
fi
#
# Results
#
echo ""
echo "###########################"
echo "# Project directory #"
echo "###########################"
echo ""
ls -alh $UNITY_PROJECT_PATH
if [ "$EDIT_MODE" = "true" ]; then
echo ""
echo "###########################"
echo "# Edit Mode Results #"
echo "# $platform Results #"
echo "###########################"
echo ""
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml"
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
fi
if [ "$PLAY_MODE" = "true" ]; then
echo ""
echo "###########################"
echo "# Play Mode Results #"
echo "###########################"
echo ""
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml"
cat "$FULL_ARTIFACTS_PATH/playmode-results.xml" | grep test-run | grep Passed
fi
if [[ "$platform" != "COMBINE_RESULTS" ]]; then
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml"
cat "$FULL_ARTIFACTS_PATH/$platform-results.xml" | grep test-run | grep Passed
fi
done
#
# Exit
# Permissions
#
if [ $EDIT_MODE_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$EDIT_MODE_EXIT_CODE
# Make a given user owner of all artifacts
if [[ -n "$CHOWN_FILES_TO" ]]; then
chown -R "$CHOWN_FILES_TO" "$UNITY_PROJECT_PATH"
chown -R "$CHOWN_FILES_TO" "$FULL_ARTIFACTS_PATH"
chown -R "$CHOWN_FILES_TO" "$FULL_COVERAGE_RESULTS_PATH"
fi
if [ $PLAY_MODE_EXIT_CODE -gt 0 ]; then
TEST_RUNNER_EXIT_CODE=$PLAY_MODE_EXIT_CODE
fi
# Add read permissions for everyone to all artifacts
chmod -R a+r "$UNITY_PROJECT_PATH"
chmod -R a+r "$FULL_ARTIFACTS_PATH"
chmod -R a+r "$FULL_COVERAGE_RESULTS_PATH"

22
dist/steps/set_gitcredential.ps1 vendored Normal file
View File

@@ -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

View File

@@ -12,12 +12,14 @@ async function run() {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
checkName,
chownFilesTo,
} = Input.getFromUser();
const baseImage = new ImageTag({ editorVersion, customImage });
const runnerTemporaryPath = process.env.RUNNER_TEMP;
@@ -30,15 +32,18 @@ async function run() {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
runnerTemporaryPath,
chownFilesTo,
});
} finally {
await Output.setArtifactsPath(artifactsPath);
await Output.setCoveragePath('CodeCoverage');
}
if (githubToken) {

View File

@@ -4,8 +4,8 @@ import path from 'path';
describe('Action', () => {
describe('compatibility check', () => {
it('throws for anything other than linux', () => {
if (process.platform !== 'linux') {
it('throws for anything other than linux or windows', () => {
if (process.platform !== 'linux' && process.platform !== 'win32') {
expect(() => Action.checkCompatibility()).toThrow();
} else {
expect(() => Action.checkCompatibility()).not.toThrow();

View File

@@ -2,7 +2,7 @@ import path from 'path';
const Action = {
get supportedPlatforms() {
return ['linux'];
return ['linux', 'win32'];
},
get isRunningLocally() {

View File

@@ -4,6 +4,21 @@ import path from 'path';
const Docker = {
async run(image, parameters, silent = false) {
let runCommand = '';
switch (process.platform) {
case 'linux':
runCommand = this.getLinuxCommand(image, parameters);
break;
case 'win32':
runCommand = this.getWindowsCommand(image, parameters);
break;
default:
throw new Error(`Operation system, ${process.platform}, is not supported yet.`);
}
await exec(runCommand, undefined, { silent });
},
getLinuxCommand(image, parameters): string {
const {
actionFolder,
editorVersion,
@@ -11,62 +26,146 @@ const Docker = {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
runnerTemporaryPath,
chownFilesTo,
} = parameters;
const githubHome = path.join(runnerTemporaryPath, '_github_home');
if (!existsSync(githubHome)) mkdirSync(githubHome);
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
const testPlatforms = (
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
).join(';');
const command = `docker run \
--workdir /github/workspace \
--rm \
--env UNITY_LICENSE \
--env UNITY_LICENSE_FILE \
--env UNITY_EMAIL \
--env UNITY_PASSWORD \
--env UNITY_SERIAL \
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \
--env GITHUB_SHA \
--env GITHUB_REPOSITORY \
--env GITHUB_ACTOR \
--env GITHUB_WORKFLOW \
--env GITHUB_HEAD_REF \
--env GITHUB_BASE_REF \
--env GITHUB_EVENT_NAME \
--env GITHUB_WORKSPACE=/github/workspace \
--env GITHUB_ACTION \
--env GITHUB_EVENT_PATH \
--env RUNNER_OS \
--env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \
--env RUNNER_WORKSPACE \
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "${githubHome}":"/root:z" \
--volume "${githubWorkflow}":"/github/workflow:z" \
--volume "${workspace}":"/github/workspace:z" \
--volume "${actionFolder}/steps":"/steps:z" \
--volume "${actionFolder}/entrypoint.sh":"/entrypoint.sh:z" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${useHostNetwork ? '--net=host' : ''} \
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
${image} \
/bin/bash /entrypoint.sh`;
return `docker run \
--workdir /github/workspace \
--rm \
--env UNITY_LICENSE \
--env UNITY_LICENSE_FILE \
--env UNITY_EMAIL \
--env UNITY_PASSWORD \
--env UNITY_SERIAL \
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \
--env GITHUB_SHA \
--env GITHUB_REPOSITORY \
--env GITHUB_ACTOR \
--env GITHUB_WORKFLOW \
--env GITHUB_HEAD_REF \
--env GITHUB_BASE_REF \
--env GITHUB_EVENT_NAME \
--env GITHUB_WORKSPACE="/github/workspace" \
--env GITHUB_ACTION \
--env GITHUB_EVENT_PATH \
--env RUNNER_OS \
--env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \
--env RUNNER_WORKSPACE \
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
--env CHOWN_FILES_TO="${chownFilesTo}" \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "${githubHome}:/root:z" \
--volume "${githubWorkflow}:/github/workflow:z" \
--volume "${workspace}:/github/workspace:z" \
--volume "${actionFolder}/steps:/steps:z" \
--volume "${actionFolder}/entrypoint.sh:/entrypoint.sh:z" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${
sshAgent ? `--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro` : ''
} \
${useHostNetwork ? '--net=host' : ''} \
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
${image} \
/bin/bash -c /entrypoint.sh`;
},
await exec(command, undefined, { silent });
getWindowsCommand(image, parameters): string {
const {
actionFolder,
editorVersion,
workspace,
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
runnerTemporaryPath,
chownFilesTo,
} = parameters;
const githubHome = path.join(runnerTemporaryPath, '_github_home');
if (!existsSync(githubHome)) mkdirSync(githubHome);
const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow');
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
const testPlatforms = (
testMode === 'all' ? ['playmode', 'editmode', 'COMBINE_RESULTS'] : [testMode]
).join(';');
return `docker run \
--workdir /github/workspace \
--rm \
--env UNITY_LICENSE \
--env UNITY_LICENSE_FILE \
--env UNITY_EMAIL \
--env UNITY_PASSWORD \
--env UNITY_SERIAL \
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \
--env GITHUB_SHA \
--env GITHUB_REPOSITORY \
--env GITHUB_ACTOR \
--env GITHUB_WORKFLOW \
--env GITHUB_HEAD_REF \
--env GITHUB_BASE_REF \
--env GITHUB_EVENT_NAME \
--env GITHUB_WORKSPACE="/github/workspace" \
--env GITHUB_ACTION \
--env GITHUB_EVENT_PATH \
--env RUNNER_OS \
--env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \
--env RUNNER_WORKSPACE \
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
--env CHOWN_FILES_TO="${chownFilesTo}" \
${sshAgent ? '--env SSH_AUTH_SOCK=c:/ssh-agent' : ''} \
--volume "${githubHome}":"c:/root" \
--volume "${githubWorkflow}":"c:/github/workflow" \
--volume "${workspace}":"c:/github/workspace" \
--volume "${actionFolder}/steps":"c:/steps" \
--volume "${actionFolder}":"c:/dist" \
${sshAgent ? `--volume ${sshAgent}:c:/ssh-agent` : ''} \
${
sshAgent
? `--volume c:/Users/Administrator/.ssh/known_hosts:c:/root/.ssh/known_hosts`
: ''
} \
${useHostNetwork ? '--net=host' : ''} \
${githubToken ? '--env USE_EXIT_CODE=false' : '--env USE_EXIT_CODE=true'} \
${image} \
powershell c:/dist/entrypoint.ps1`;
},
};

View File

@@ -13,7 +13,7 @@ class ImageTag {
constructor(imageProperties) {
const {
editorVersion = '2019.2.11f1',
targetPlatform = Platform.types.StandaloneLinux64,
targetPlatform = ImageTag.getImagePlatformType(process.platform),
customImage,
} = imageProperties;
@@ -43,7 +43,7 @@ class ImageTag {
generic: '',
webgl: 'webgl',
mac: 'mac-mono',
windows: 'windows-mono',
windows: 'windows-il2cpp',
linux: 'base',
linuxIl2cpp: 'linux-il2cpp',
android: 'android',
@@ -56,8 +56,25 @@ class ImageTag {
switch (platform) {
case 'linux':
return 'ubuntu';
case 'win32':
return 'windows';
default:
throw new Error('The Operating System of this runner is not yet supported.');
throw new Error(
`The Operating System of this runner, "${platform}", is not yet supported.`,
);
}
}
static getImagePlatformType(platform) {
switch (platform) {
case 'linux':
return Platform.types.StandaloneLinux64;
case 'win32':
return Platform.types.StandaloneWindows;
default:
throw new Error(
`The Operating System of this runner, "${platform}", is not yet supported.`,
);
}
}

View File

@@ -19,12 +19,14 @@ const Input = {
const rawProjectPath = getInput('projectPath') || '.';
const customParameters = getInput('customParameters') || '';
const testMode = (getInput('testMode') || 'all').toLowerCase();
const coverageOptions = getInput('coverageOptions') || '';
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const sshAgent = getInput('sshAgent') || '';
const gitPrivateToken = getInput('gitPrivateToken') || '';
const githubToken = getInput('githubToken') || '';
const checkName = getInput('checkName') || 'Test Results';
const chownFilesTo = getInput('chownFilesTo') || '';
// Validate input
if (!this.testModes.includes(testMode)) {
@@ -57,12 +59,14 @@ const Input = {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
gitPrivateToken,
githubToken,
checkName,
chownFilesTo,
};
},
};

View File

@@ -6,4 +6,19 @@ describe('Output', () => {
await expect(Output.setArtifactsPath('')).resolves.not.toThrow();
});
});
describe('setCoveragePath', () => {
it('does not throw', async () => {
await expect(Output.setCoveragePath('')).resolves.not.toThrow();
await expect(Output.setCoveragePath('artifacts')).resolves.not.toThrow();
await expect(Output.setCoveragePath('coverage')).resolves.not.toThrow();
await expect(Output.setCoveragePath('CodeCoverage')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./artifacts')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./coverage')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./CodeCoverage')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./artifacts/coverage')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./coverage/')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./CodeCoverage/')).resolves.not.toThrow();
await expect(Output.setCoveragePath('./artifacts/coverage/')).resolves.not.toThrow();
});
});
});

View File

@@ -4,6 +4,9 @@ const Output = {
async setArtifactsPath(artifactsPath) {
await core.setOutput('artifactsPath', artifactsPath);
},
async setCoveragePath(coveragePath) {
await core.setOutput('coveragePath', coveragePath);
},
};
export default Output;

View File

@@ -114,6 +114,24 @@ describe('ResultsParser', () => {
expect(result.annotation).toBeUndefined();
});
test('no cdata in stack trace', () => {
const result = ResultsParser.convertTestCase('Test Suite', {
_attributes: {
name: 'Test Name',
duration: '3.14',
},
failure: {
message: { _cdata: 'Message CDATA' },
'stack-trace': {},
},
});
expect(result.suite).toBe('Test Suite');
expect(result.title).toBe('Test Name');
expect(result.duration).toBe(3.14);
expect(result.annotation).toBeUndefined();
});
test('no annotation path', () => {
const result = ResultsParser.convertTestCase('Test Suite', {
_attributes: {

View File

@@ -90,6 +90,10 @@ const ResultsParser = {
}
const trace = failure['stack-trace']._cdata;
if (trace === undefined) {
core.warning(`No cdata in stack trace for test case: ${fullname}`);
return testMeta;
}
const point = ResultsParser.findAnnotationPoint(trace);
if (!point.path || !point.line) {
core.warning(`Not able to find annotation point for failed test! Test trace: ${trace}`);

View File

@@ -6,6 +6,7 @@
"com.unity.ide.vscode": "1.1.2",
"com.unity.package-manager-ui": "2.2.0",
"com.unity.test-framework": "1.0.13",
"com.unity.testtools.codecoverage": "1.1.1",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.1.0",
"com.unity.ugui": "1.0.0",