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
This commit is contained in:
Nick Maltbie
2022-04-21 04:50:37 -04:00
committed by GitHub
parent ec4f39253f
commit 96562463cf
11 changed files with 117 additions and 110 deletions

View File

@@ -11,6 +11,7 @@ const Docker = {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,
@@ -23,6 +24,9 @@ const Docker = {
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 \
@@ -35,7 +39,9 @@ const Docker = {
--env UNITY_VERSION="${editorVersion}" \
--env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_MODE="${testMode}" \
--env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="CodeCoverage" \
--env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \
--env GITHUB_SHA \

View File

@@ -19,6 +19,7 @@ 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') || '';
@@ -57,6 +58,7 @@ const Input = {
projectPath,
customParameters,
testMode,
coverageOptions,
artifactsPath,
useHostNetwork,
sshAgent,

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;