mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-28 21:59:06 +08:00
* 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
80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import { existsSync, mkdirSync } from 'fs';
|
|
import { exec } from '@actions/exec';
|
|
import path from 'path';
|
|
|
|
const Docker = {
|
|
async run(image, parameters, silent = false) {
|
|
const {
|
|
actionFolder,
|
|
editorVersion,
|
|
workspace,
|
|
projectPath,
|
|
customParameters,
|
|
testMode,
|
|
coverageOptions,
|
|
artifactsPath,
|
|
useHostNetwork,
|
|
sshAgent,
|
|
gitPrivateToken,
|
|
githubToken,
|
|
runnerTemporaryPath,
|
|
} = 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_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}" \
|
|
${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`;
|
|
|
|
await exec(command, undefined, { silent });
|
|
},
|
|
};
|
|
|
|
export default Docker;
|