Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,43 @@ describe('main.js security - single file path validation', () => {
});
});

describe('coverage file discovery logging', () => {
it('logs found coverage file paths for a single file', async () => {
const previousCwd = process.cwd();
process.chdir(tmpDir);

try {
await fs.writeFile('lcov.info', 'TN:\nSF:src/test.js\nDA:1,5\nend_of_record\n');
mockGetInput.mockReturnValue('lcov.info');

await run();

expect(mockInfo).toHaveBeenCalledWith('Found 1 coverage file(s) at path(s) \n\tlcov.info');
} finally {
process.chdir(previousCwd);
}
});

it('logs found coverage file paths for multiple files', async () => {
const previousCwd = process.cwd();
process.chdir(tmpDir);

try {
await fs.writeFile('lcov1.info', 'TN:\nSF:src/a.js\nDA:1,5\nend_of_record\n');
await fs.writeFile('lcov2.info', 'TN:\nSF:src/b.js\nDA:1,3\nend_of_record\n');
mockGetInput.mockReturnValue('lcov1.info lcov2.info');

await run();

expect(mockInfo).toHaveBeenCalledWith(
'Found 2 coverage file(s) at path(s) \n\tlcov1.info\n\tlcov2.info',
);
} finally {
process.chdir(previousCwd);
}
});
});

describe('valid single file path', () => {
it('accepts and processes valid relative single file path', async () => {
const previousCwd = process.cwd();
Expand Down Expand Up @@ -242,6 +279,12 @@ describe('main.js security - single file path validation', () => {
expect(headers['Content-Type']).toBe('application/json');
expect(headers['Content-Encoding']).toBeUndefined();

expect(mockInfo).not.toHaveBeenCalledWith(
`Uploading coverage report for branch haahah to Aikido...`,
);
expect(mockInfo).toHaveBeenCalledWith(
`Uploading coverage report for branch main to Aikido...`,
);
expect(mockInfo).toHaveBeenCalledWith('Upload succeeded.');
} finally {
process.chdir(previousCwd);
Expand Down
8 changes: 6 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ async function run() {
throw new Error(`No lcov file(s) provided. Specify at least one path.`);
}

core.info(`Found ${inputs.lcovFilePaths.length} coverage file(s):`);
core.info(
`Found ${inputs.lcovFilePaths.length} coverage file(s) at path(s) \n\t${inputs.lcovFilePaths.join('\n\t')}`,
);

let codeCoverageFileContent = null;

Expand All @@ -50,7 +52,9 @@ async function run() {
throw new Error('Something went wrong while validating the coverage file(s)');
}

core.info('Uploading coverage report to Aikido...');
core.info(
`Uploading coverage report for branch ${process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME} to Aikido...`,
);
Comment thread
aikido-autofix[bot] marked this conversation as resolved.
await uploadCoverage(codeCoverageFileContent);

core.info(`Upload succeeded.`);
Expand Down