mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-29 06:20:07 +08:00
Compare commits
8 Commits
v2.0-alpha
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f61055d56f | ||
|
|
79e50e3e4f | ||
|
|
576ef39bb6 | ||
|
|
a2b1ed6631 | ||
|
|
3e969f16b2 | ||
|
|
20387ae1e0 | ||
|
|
e13aeebe33 | ||
|
|
02c0e7b60c |
@@ -19,7 +19,7 @@ When fixing a bug it is fine to submit a pull request right away.
|
||||
|
||||
Steps to be performed to submit a pull request:
|
||||
|
||||
1. Fork the repository and create your branch from `master`.
|
||||
1. Fork the repository and create your branch from `main`.
|
||||
2. Run `yarn` in the repository root.
|
||||
3. If you've fixed a bug or added code that should be tested, add tests!
|
||||
4. Fill out the description, link any related issues and submit your pull request.
|
||||
|
||||
@@ -32,6 +32,11 @@ inputs:
|
||||
required: false
|
||||
default: ''
|
||||
description: 'SSH Agent path to forward to the container'
|
||||
gitPrivateToken:
|
||||
required: false
|
||||
default: ''
|
||||
description: >
|
||||
Github private token to pull from github
|
||||
githubToken:
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
@@ -12,6 +12,7 @@ mkdir -p "$ACTIVATE_LICENSE_PATH"
|
||||
#
|
||||
|
||||
source /steps/activate.sh
|
||||
source /steps/set_gitcredential.sh
|
||||
source /steps/run_tests.sh
|
||||
source /steps/return_license.sh
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -86,7 +86,7 @@ else
|
||||
#
|
||||
echo "License activation strategy could not be determined."
|
||||
echo ""
|
||||
echo "Visit https://github.com/webbertakken/unity-builder#usage for more"
|
||||
echo "Visit https://game.ci/docs/github/getting-started for more"
|
||||
echo "details on how to set up one of the possible activation strategies."
|
||||
|
||||
# Immediately exit as no UNITY_EXIT_CODE can be derived.
|
||||
|
||||
@@ -67,8 +67,8 @@ ls -alh $UNITY_PROJECT_PATH
|
||||
#
|
||||
# Testing in EditMode
|
||||
#
|
||||
|
||||
if [ $EDIT_MODE = true ]; then
|
||||
EDIT_MODE_EXIT_CODE=0
|
||||
if [ "$EDIT_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in EditMode #"
|
||||
@@ -104,8 +104,8 @@ fi
|
||||
#
|
||||
# Testing in PlayMode
|
||||
#
|
||||
|
||||
if [ $PLAY_MODE = true ]; then
|
||||
PLAY_MODE_EXIT_CODE=0
|
||||
if [ "$PLAY_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Testing in PlayMode #"
|
||||
@@ -149,7 +149,7 @@ echo "###########################"
|
||||
echo ""
|
||||
ls -alh $UNITY_PROJECT_PATH
|
||||
|
||||
if [ $EDIT_MODE = true ]; then
|
||||
if [ "$EDIT_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Edit Mode Results #"
|
||||
@@ -159,7 +159,7 @@ if [ $EDIT_MODE = true ]; then
|
||||
cat "$FULL_ARTIFACTS_PATH/editmode-results.xml" | grep test-run | grep Passed
|
||||
fi
|
||||
|
||||
if [ $PLAY_MODE = true ]; then
|
||||
if [ "$PLAY_MODE" = "true" ]; then
|
||||
echo ""
|
||||
echo "###########################"
|
||||
echo "# Play Mode Results #"
|
||||
|
||||
23
action/steps/set_gitcredential.sh
Normal file
23
action/steps/set_gitcredential.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${GIT_PRIVATE_TOKEN}" ]
|
||||
then
|
||||
echo "GIT_PRIVATE_TOKEN unset skipping"
|
||||
else
|
||||
echo "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:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/"
|
||||
git config --global url."https://ssh:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/"
|
||||
git config --global url."https://git:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com:"
|
||||
|
||||
fi
|
||||
|
||||
echo "---------- git config --list -------------"
|
||||
git config --list
|
||||
|
||||
echo "---------- git config --list --show-origin -------------"
|
||||
git config --list --show-origin
|
||||
@@ -28,6 +28,7 @@ class Docker {
|
||||
customParameters,
|
||||
sshAgent,
|
||||
githubToken,
|
||||
gitPrivateToken,
|
||||
} = parameters;
|
||||
|
||||
const command = `docker run \
|
||||
@@ -58,6 +59,7 @@ class Docker {
|
||||
--env RUNNER_TOOL_CACHE \
|
||||
--env RUNNER_TEMP \
|
||||
--env RUNNER_WORKSPACE \
|
||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
||||
--volume "/home/runner/work/_temp/_github_home":"/root" \
|
||||
|
||||
@@ -8,7 +8,7 @@ class Input {
|
||||
}
|
||||
|
||||
static isValidFolderName(folderName) {
|
||||
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([_-]?[\w~]+)*\/?)*$/);
|
||||
const validFolderName = new RegExp(/^(\.|\.\/)?(\.?[\w~]+([ _-]?[\w~]+)*\/?)*$/);
|
||||
|
||||
return validFolderName.test(folderName);
|
||||
}
|
||||
@@ -25,6 +25,7 @@ class Input {
|
||||
const sshAgent = getInput('sshAgent') || '';
|
||||
const githubToken = getInput('githubToken') || '';
|
||||
const checkName = getInput('checkName') || 'Test Results';
|
||||
const gitPrivateToken = getInput('gitPrivateToken') || '';
|
||||
|
||||
// Validate input
|
||||
if (!includes(this.testModes, testMode)) {
|
||||
@@ -62,6 +63,7 @@ class Input {
|
||||
sshAgent,
|
||||
githubToken,
|
||||
checkName,
|
||||
gitPrivateToken,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class ResultsParser {
|
||||
}
|
||||
|
||||
static convertTestCase(suite, testCase) {
|
||||
const { _attributes, failure } = testCase;
|
||||
const { _attributes, failure, output } = testCase;
|
||||
const { name, fullname, result, duration } = _attributes;
|
||||
const testMeta = new TestMeta(suite, name);
|
||||
testMeta.result = result;
|
||||
@@ -96,6 +96,14 @@ class ResultsParser {
|
||||
return testMeta;
|
||||
}
|
||||
|
||||
const rawDetails = [trace];
|
||||
|
||||
if (output && output._cdata) {
|
||||
rawDetails.unshift(output._cdata);
|
||||
} else {
|
||||
core.debug(`No console output for test case: ${fullname}`);
|
||||
}
|
||||
|
||||
testMeta.annotation = {
|
||||
path: point.path,
|
||||
start_line: point.line,
|
||||
@@ -103,7 +111,7 @@ class ResultsParser {
|
||||
annotation_level: 'failure',
|
||||
title: fullname,
|
||||
message: failure.message._cdata ? failure.message._cdata : 'Test Failed!',
|
||||
raw_details: trace,
|
||||
raw_details: rawDetails.join('\n'),
|
||||
};
|
||||
core.info(
|
||||
`- ${testMeta.annotation.path}:${testMeta.annotation.start_line} - ${testMeta.annotation.title}`,
|
||||
|
||||
@@ -149,7 +149,7 @@ describe('ResultsParser', () => {
|
||||
expect(result.annotation).toBeUndefined();
|
||||
});
|
||||
|
||||
test('prepare annotation', () => {
|
||||
test('prepare annotation without console output', () => {
|
||||
const result = ResultsParser.convertTestCase('Test Suite', {
|
||||
_attributes: {
|
||||
name: 'Test Name',
|
||||
@@ -179,6 +179,40 @@ describe('ResultsParser', () => {
|
||||
title: 'Test Full Name',
|
||||
});
|
||||
});
|
||||
|
||||
test('prepare annotation with console output', () => {
|
||||
const result = ResultsParser.convertTestCase('Test Suite', {
|
||||
_attributes: {
|
||||
name: 'Test Name',
|
||||
fullname: 'Test Full Name',
|
||||
duration: '3.14',
|
||||
},
|
||||
output: {
|
||||
_cdata: '[Warning] This is a warning',
|
||||
},
|
||||
failure: {
|
||||
message: { _cdata: 'Message CDATA' },
|
||||
'stack-trace': {
|
||||
_cdata:
|
||||
'at Tests.SetupFailedTest.SetUp () [0x00000] in /github/workspace/unity-project/Assets/Tests/SetupFailedTest.cs:10',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.suite).toBe('Test Suite');
|
||||
expect(result.title).toBe('Test Name');
|
||||
expect(result.duration).toBe(3.14);
|
||||
expect(result.annotation).toMatchObject({
|
||||
annotation_level: 'failure',
|
||||
end_line: 10,
|
||||
message: 'Message CDATA',
|
||||
path: '/github/workspace/unity-project/Assets/Tests/SetupFailedTest.cs',
|
||||
raw_details:
|
||||
'[Warning] This is a warning\nat Tests.SetupFailedTest.SetUp () [0x00000] in /github/workspace/unity-project/Assets/Tests/SetupFailedTest.cs:10',
|
||||
start_line: 10,
|
||||
title: 'Test Full Name',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('findAnnotationPoint', () => {
|
||||
|
||||
18
yarn.lock
18
yarn.lock
@@ -1589,9 +1589,9 @@ ansi-escapes@^4.2.1, ansi-escapes@^4.3.0:
|
||||
type-fest "^0.11.0"
|
||||
|
||||
ansi-regex@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
|
||||
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
|
||||
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
|
||||
|
||||
ansi-styles@^3.2.1:
|
||||
version "3.2.1"
|
||||
@@ -5304,9 +5304,9 @@ semver-compare@^1.0.0:
|
||||
integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w=
|
||||
|
||||
semver-regex@^3.1.2:
|
||||
version "3.1.2"
|
||||
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.2.tgz#34b4c0d361eef262e07199dbef316d0f2ab11807"
|
||||
integrity sha512-bXWyL6EAKOJa81XG1OZ/Yyuq+oT0b2YLlxx7c+mrdYPaPbnj6WgVULXhinMIeZGufuUBu/eVRqXEhiv4imfwxA==
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.3.tgz#b2bcc6f97f63269f286994e297e229b6245d0dc3"
|
||||
integrity sha512-Aqi54Mk9uYTjVexLnR67rTyBusmwd04cLkHy9hNvk3+G3nT2Oyg7E0l4XVbOaNwIvQ3hHeYxGcyEy+mKreyBFQ==
|
||||
|
||||
"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
|
||||
version "5.7.1"
|
||||
@@ -5737,9 +5737,9 @@ through@^2.3.8:
|
||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||
|
||||
tmpl@1.0.x:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
|
||||
integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc"
|
||||
integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==
|
||||
|
||||
to-fast-properties@^2.0.0:
|
||||
version "2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user