Updated parameter names and default values for code coverage

pull/182/head
Nick Maltbie 2022-04-19 23:37:24 -04:00
parent 2e6c7ac4f3
commit 7c0f210aae
10 changed files with 61 additions and 61 deletions

View File

@ -105,8 +105,7 @@ jobs:
projectPath: ${{ matrix.projectPath }} projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: all testMode: all
coverageParameters: 'enableCyclomaticComplexity;generateHtmlReport;generateBadgeReport;assemblyFilters:+MyScripts' coverageOptions: 'enableCyclomaticComplexity;generateHtmlReport;generateBadgeReport;assemblyFilters:+MyScripts'
coverageResultsPath: 'artifacts'
# Test implicit artifactsPath, by not setting it # Test implicit artifactsPath, by not setting it
# Upload artifacts # Upload artifacts
@ -117,6 +116,14 @@ jobs:
path: ${{ steps.allTests.outputs.artifactsPath }} path: ${{ steps.allTests.outputs.artifactsPath }}
retention-days: 14 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: testRunnerInEditMode:
name: Test edit mode 📝 name: Test edit mode 📝
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -164,6 +171,14 @@ jobs:
path: ${{ steps.editMode.outputs.artifactsPath }} path: ${{ steps.editMode.outputs.artifactsPath }}
retention-days: 14 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
testRunnerInPlayMode: testRunnerInPlayMode:
name: Test play mode 📺 name: Test play mode 📺
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -211,6 +226,14 @@ jobs:
path: ${{ steps.playMode.outputs.artifactsPath }} path: ${{ steps.playMode.outputs.artifactsPath }}
retention-days: 14 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
testEachModeSequentially: testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower) name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -248,7 +271,6 @@ jobs:
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: editmode testMode: editmode
artifactsPath: artifacts/editmode artifactsPath: artifacts/editmode
coverageResultsPath: artifacts/editmode
# Configure second test runner # Configure second test runner
- name: Tests in playmode 📺 - name: Tests in playmode 📺
@ -258,7 +280,6 @@ jobs:
unityVersion: ${{ matrix.unityVersion }} unityVersion: ${{ matrix.unityVersion }}
testMode: playmode testMode: playmode
artifactsPath: artifacts/playmode artifactsPath: artifacts/playmode
coverageResultsPath: artifacts/playmode
# Upload combined artifacts # Upload combined artifacts
- name: Upload combined test results - name: Upload combined test results

View File

@ -20,14 +20,10 @@ inputs:
required: false required: false
default: 'all' default: 'all'
description: 'The type of tests to be run by the test runner.' description: 'The type of tests to be run by the test runner.'
coverageParameters: coverageOptions:
required: false required: false
default: 'enableCyclomaticComplexity;generateHtmlReport;generateBadgeReport' default: 'enableCyclomaticComplexity;generateHtmlReport;generateBadgeReport'
description: 'Optional coverage parameters for the -coverageOptions argument.' description: 'Optional coverage parameters for the -coverageOptions argument.'
coverageResultsPath:
required: false
default: 'coverage'
description: 'Path to write coverage results to when collecting code coverage.'
artifactsPath: artifactsPath:
required: false required: false
default: 'artifacts' default: 'artifacts'
@ -55,7 +51,7 @@ inputs:
outputs: outputs:
artifactsPath: artifactsPath:
description: 'Path where the artifacts are stored.' description: 'Path where the artifacts are stored.'
coverageResultsPath: coveragePath:
description: 'Path where the code coverage results are stored.' description: 'Path where the code coverage results are stored.'
branding: branding:
icon: 'box' icon: 'box'

27
dist/index.js generated vendored
View File

@ -42,7 +42,7 @@ function run() {
try { try {
model_1.Action.checkCompatibility(); model_1.Action.checkCompatibility();
const { workspace, actionFolder } = model_1.Action; const { workspace, actionFolder } = model_1.Action;
const { editorVersion, customImage, projectPath, customParameters, testMode, coverageParameters, coverageResultsPath, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser(); const { editorVersion, customImage, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, checkName, } = model_1.Input.getFromUser();
const baseImage = new model_1.ImageTag({ editorVersion, customImage }); const baseImage = new model_1.ImageTag({ editorVersion, customImage });
const runnerTemporaryPath = process.env.RUNNER_TEMP; const runnerTemporaryPath = process.env.RUNNER_TEMP;
try { try {
@ -53,8 +53,7 @@ function run() {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -65,7 +64,7 @@ function run() {
} }
finally { finally {
yield model_1.Output.setArtifactsPath(artifactsPath); yield model_1.Output.setArtifactsPath(artifactsPath);
yield model_1.Output.setCoverageResultsPath(coverageResultsPath); yield model_1.Output.setCoveragePath('CodeCoverage');
} }
if (githubToken) { if (githubToken) {
const failedTestCount = yield model_1.ResultsCheck.createCheck(artifactsPath, githubToken, checkName); const failedTestCount = yield model_1.ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
@ -155,7 +154,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
const Docker = { const Docker = {
run(image, parameters, silent = false) { run(image, parameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageParameters, coverageResultsPath, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters; const { actionFolder, editorVersion, workspace, projectPath, customParameters, testMode, coverageOptions, artifactsPath, useHostNetwork, sshAgent, gitPrivateToken, githubToken, runnerTemporaryPath, } = parameters;
const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home'); const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home');
if (!(0, fs_1.existsSync)(githubHome)) if (!(0, fs_1.existsSync)(githubHome))
(0, fs_1.mkdirSync)(githubHome); (0, fs_1.mkdirSync)(githubHome);
@ -175,8 +174,8 @@ const Docker = {
--env PROJECT_PATH="${projectPath}" \ --env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \ --env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \ --env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageParameters}" \ --env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \ --env COVERAGE_RESULTS_PATH="CodeCoverage" \
--env ARTIFACTS_PATH="${artifactsPath}" \ --env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \ --env GITHUB_REF \
--env GITHUB_SHA \ --env GITHUB_SHA \
@ -391,8 +390,7 @@ const Input = {
const rawProjectPath = (0, core_1.getInput)('projectPath') || '.'; const rawProjectPath = (0, core_1.getInput)('projectPath') || '.';
const customParameters = (0, core_1.getInput)('customParameters') || ''; const customParameters = (0, core_1.getInput)('customParameters') || '';
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase(); const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
const coverageParameters = (0, core_1.getInput)('coverageParameters') || ''; const coverageOptions = (0, core_1.getInput)('coverageOptions') || '';
const rawCoverageResultsPath = (0, core_1.getInput)('coverageResultsPath') || 'CodeCoverage';
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts'; const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false'; const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
const sshAgent = (0, core_1.getInput)('sshAgent') || ''; const sshAgent = (0, core_1.getInput)('sshAgent') || '';
@ -403,9 +401,6 @@ const Input = {
if (!this.testModes.includes(testMode)) { if (!this.testModes.includes(testMode)) {
throw new Error(`Invalid testMode ${testMode}`); throw new Error(`Invalid testMode ${testMode}`);
} }
if (!this.isValidFolderName(rawCoverageResultsPath)) {
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
}
if (!this.isValidFolderName(rawProjectPath)) { if (!this.isValidFolderName(rawProjectPath)) {
throw new Error(`Invalid projectPath "${rawProjectPath}"`); throw new Error(`Invalid projectPath "${rawProjectPath}"`);
} }
@ -419,7 +414,6 @@ const Input = {
const projectPath = rawProjectPath.replace(/\/$/, ''); const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, ''); const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true'; const useHostNetwork = rawUseHostNetwork === 'true';
const coverageResultsPath = rawCoverageResultsPath.replace(/\/$/, '');
const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion; const editorVersion = unityVersion === 'auto' ? unity_version_parser_1.default.read(projectPath) : unityVersion;
// Return sanitised input // Return sanitised input
return { return {
@ -428,8 +422,7 @@ const Input = {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -485,9 +478,9 @@ const Output = {
yield core.setOutput('artifactsPath', artifactsPath); yield core.setOutput('artifactsPath', artifactsPath);
}); });
}, },
setCoverageResultsPath(coverageResultsPath) { setCoveragePath(coveragePath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield core.setOutput('coverageResultsPath', coverageResultsPath); yield core.setOutput('coveragePath', coveragePath);
}); });
}, },
}; };

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -99,7 +99,7 @@ for platform in ${TEST_PLATFORMS//;/ }; do
echo "Unexpected exit code $TEST_EXIT_CODE"; echo "Unexpected exit code $TEST_EXIT_CODE";
fi fi
if [ $TEST_EXIT_CODE -gt 0 ]; then if [ $TEST_EXIT_CODE -ne 0 ]; then
TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE TEST_RUNNER_EXIT_CODE=$TEST_EXIT_CODE
fi fi

View File

@ -12,8 +12,7 @@ async function run() {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -32,8 +31,7 @@ async function run() {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -43,7 +41,7 @@ async function run() {
}); });
} finally { } finally {
await Output.setArtifactsPath(artifactsPath); await Output.setArtifactsPath(artifactsPath);
await Output.setCoverageResultsPath(coverageResultsPath); await Output.setCoveragePath('CodeCoverage');
} }
if (githubToken) { if (githubToken) {

View File

@ -11,8 +11,7 @@ const Docker = {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,
@ -41,8 +40,8 @@ const Docker = {
--env PROJECT_PATH="${projectPath}" \ --env PROJECT_PATH="${projectPath}" \
--env CUSTOM_PARAMETERS="${customParameters}" \ --env CUSTOM_PARAMETERS="${customParameters}" \
--env TEST_PLATFORMS="${testPlatforms}" \ --env TEST_PLATFORMS="${testPlatforms}" \
--env COVERAGE_OPTIONS="${coverageParameters}" \ --env COVERAGE_OPTIONS="${coverageOptions}" \
--env COVERAGE_RESULTS_PATH="${coverageResultsPath}" \ --env COVERAGE_RESULTS_PATH="CodeCoverage" \
--env ARTIFACTS_PATH="${artifactsPath}" \ --env ARTIFACTS_PATH="${artifactsPath}" \
--env GITHUB_REF \ --env GITHUB_REF \
--env GITHUB_SHA \ --env GITHUB_SHA \

View File

@ -19,8 +19,7 @@ const Input = {
const rawProjectPath = getInput('projectPath') || '.'; const rawProjectPath = getInput('projectPath') || '.';
const customParameters = getInput('customParameters') || ''; const customParameters = getInput('customParameters') || '';
const testMode = (getInput('testMode') || 'all').toLowerCase(); const testMode = (getInput('testMode') || 'all').toLowerCase();
const coverageParameters = getInput('coverageParameters') || ''; const coverageOptions = getInput('coverageOptions') || '';
const rawCoverageResultsPath = getInput('coverageResultsPath') || 'CodeCoverage';
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts'; const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
const rawUseHostNetwork = getInput('useHostNetwork') || 'false'; const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const sshAgent = getInput('sshAgent') || ''; const sshAgent = getInput('sshAgent') || '';
@ -33,10 +32,6 @@ const Input = {
throw new Error(`Invalid testMode ${testMode}`); throw new Error(`Invalid testMode ${testMode}`);
} }
if (!this.isValidFolderName(rawCoverageResultsPath)) {
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
}
if (!this.isValidFolderName(rawProjectPath)) { if (!this.isValidFolderName(rawProjectPath)) {
throw new Error(`Invalid projectPath "${rawProjectPath}"`); throw new Error(`Invalid projectPath "${rawProjectPath}"`);
} }
@ -53,7 +48,6 @@ const Input = {
const projectPath = rawProjectPath.replace(/\/$/, ''); const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, ''); const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
const useHostNetwork = rawUseHostNetwork === 'true'; const useHostNetwork = rawUseHostNetwork === 'true';
const coverageResultsPath = rawCoverageResultsPath.replace(/\/$/, '');
const editorVersion = const editorVersion =
unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion; unityVersion === 'auto' ? UnityVersionParser.read(projectPath) : unityVersion;
@ -64,8 +58,7 @@ const Input = {
projectPath, projectPath,
customParameters, customParameters,
testMode, testMode,
coverageParameters, coverageOptions,
coverageResultsPath,
artifactsPath, artifactsPath,
useHostNetwork, useHostNetwork,
sshAgent, sshAgent,

View File

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

View File

@ -4,8 +4,8 @@ const Output = {
async setArtifactsPath(artifactsPath) { async setArtifactsPath(artifactsPath) {
await core.setOutput('artifactsPath', artifactsPath); await core.setOutput('artifactsPath', artifactsPath);
}, },
async setCoverageResultsPath(coverageResultsPath) { async setCoveragePath(coveragePath) {
await core.setOutput('coverageResultsPath', coverageResultsPath); await core.setOutput('coveragePath', coveragePath);
}, },
}; };