Updated to add more tests for code coverage build

pull/182/head
Nick Maltbie 2022-04-17 11:01:24 -07:00
parent 8c539b2b05
commit a899b54084
7 changed files with 71 additions and 41 deletions

View File

@ -78,9 +78,6 @@ jobs:
- unity-project-with-correct-tests
unityVersion:
- 2019.2.11f1
enableCodeCovearge:
- true
- false
steps:
###########################
# Checkout #
@ -107,7 +104,6 @@ jobs:
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
enableCodeCovearge: ${{ matrix.enableCodeCovearge }}
testMode: all
# Test implicit artifactsPath, by not setting it
@ -213,6 +209,59 @@ jobs:
path: ${{ steps.playMode.outputs.artifactsPath }}
retention-days: 14
testCodeCoveragePermutations:
name: Test code coverage results procedurally
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
enableCodeCovearge:
- true
unityVersion:
- 2019.2.11f1
projectPath:
- unity-project-with-correct-tests
testMode:
- playmode
- editmode
- All
steps:
###########################
# Checkout #
###########################
- uses: actions/checkout@v3
with:
lfs: true
###########################
# Cache #
###########################
- uses: actions/cache@v3
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.projectPath }}-
Library-
# Configure test runner
- name: Run tests
id: codecovtests
uses: ./
with:
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
testMode: ${{ matrix.testMode }}
artifactsPath: codecoverage/${{ matrix.projectPath }}
# Upload artifacts
- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
name: Code coverage results (edit mode)
path: ${{ steps.codecovtests.outputs.coverageResultsPath }}
retention-days: 7
testEachModeSequentially:
name: Test each mode sequentially 👩‍👩‍👧‍👦 # don't try this at home (it's much slower)
runs-on: ubuntu-latest

20
dist/index.js generated vendored
View File

@ -66,6 +66,7 @@ function run() {
}
finally {
yield model_1.Output.setArtifactsPath(artifactsPath);
yield model_1.Output.setCoverageResultsPath(coverageResultsPath);
}
if (githubToken) {
const failedTestCount = yield model_1.ResultsCheck.createCheck(artifactsPath, githubToken, checkName);
@ -393,7 +394,7 @@ const Input = {
const testMode = ((0, core_1.getInput)('testMode') || 'all').toLowerCase();
const rawEnableCodeCoverage = (0, core_1.getInput)('enableCodeCoverage') || 'false';
const coverageAssemblyFilters = (0, core_1.getInput)('coverageAssemblyFilters') || '';
const rawCoverageResultsPath = (0, core_1.getInput)('coverageResultsPath') || '';
const rawCoverageResultsPath = (0, core_1.getInput)('coverageResultsPath') || 'CodeCoverage';
const rawArtifactsPath = (0, core_1.getInput)('artifactsPath') || 'artifacts';
const rawUseHostNetwork = (0, core_1.getInput)('useHostNetwork') || 'false';
const sshAgent = (0, core_1.getInput)('sshAgent') || '';
@ -407,18 +408,6 @@ const Input = {
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
}
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
}
if (rawEnableCodeCoverage !== 'true' && coverageAssemblyFilters !== '') {
throw new Error(`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`);
}
if (coverageAssemblyFilters !== '') {
throw new Error(`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`);
}
if (rawEnableCodeCoverage !== 'true' && rawCoverageResultsPath !== '') {
throw new Error(`coverageResultsPath should not be set if enableCodeCoverage is not enabled.`);
}
if (!this.isValidFolderName(rawCoverageResultsPath)) {
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
}
@ -503,6 +492,11 @@ const Output = {
yield core.setOutput('artifactsPath', artifactsPath);
});
},
setCoverageResultsPath(coverageResultsPath) {
return __awaiter(this, void 0, void 0, function* () {
yield core.setOutput('coverageResultsPath', coverageResultsPath);
});
},
};
exports["default"] = Output;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -45,6 +45,7 @@ async function run() {
});
} finally {
await Output.setArtifactsPath(artifactsPath);
await Output.setCoverageResultsPath(coverageResultsPath);
}
if (githubToken) {

View File

@ -21,7 +21,7 @@ const Input = {
const testMode = (getInput('testMode') || 'all').toLowerCase();
const rawEnableCodeCoverage = getInput('enableCodeCoverage') || 'false';
const coverageAssemblyFilters = getInput('coverageAssemblyFilters') || '';
const rawCoverageResultsPath = getInput('coverageResultsPath') || '';
const rawCoverageResultsPath = getInput('coverageResultsPath') || 'CodeCoverage';
const rawArtifactsPath = getInput('artifactsPath') || 'artifacts';
const rawUseHostNetwork = getInput('useHostNetwork') || 'false';
const sshAgent = getInput('sshAgent') || '';
@ -38,28 +38,6 @@ const Input = {
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
}
if (rawEnableCodeCoverage !== 'true' && rawEnableCodeCoverage !== 'false') {
throw new Error(`Invalid enableCodeCoverage "${rawEnableCodeCoverage}"`);
}
if (rawEnableCodeCoverage !== 'true' && coverageAssemblyFilters !== '') {
throw new Error(
`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`,
);
}
if (coverageAssemblyFilters !== '') {
throw new Error(
`coverageAssemblyFilters should not be set if enableCodeCoverage is not enabled.`,
);
}
if (rawEnableCodeCoverage !== 'true' && rawCoverageResultsPath !== '') {
throw new Error(
`coverageResultsPath should not be set if enableCodeCoverage is not enabled.`,
);
}
if (!this.isValidFolderName(rawCoverageResultsPath)) {
throw new Error(`Invalid coverageResultsPath "${rawCoverageResultsPath}"`);
}

View File

@ -6,4 +6,9 @@ describe('Output', () => {
await expect(Output.setArtifactsPath('')).resolves.not.toThrow();
});
});
describe('setCoverageResultsPath', () => {
it('does not throw', async () => {
await expect(Output.setCoverageResultsPath('')).resolves.not.toThrow();
});
});
});

View File

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