Skip to content

Commit

Permalink
fix: set default path for coverage file (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
prescottprue authored Apr 21, 2022
1 parent a9e2cea commit cd6a0cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 6 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14082,19 +14082,21 @@ async function downloadAndWriteArtifact(coveragePath) {
// Unzip
core.debug(`Unziping artifact file at path "${downloadPath}"`);
await (0, exec_1.exec)('unzip', [downloadPath, '-d', coverageFolder]);
core.debug('Successfully unzipped artifact file');
core.info('Successfully downloaded and unzipped coverage artifact');
}
/**
*
*/
async function run() {
const coveragePath = `${process.env.GITHUB_WORKSPACE}/${core.getInput('lcov-path')}`;
core.debug(`lcov-path input: ${core.getInput('lcov-path')}`);
// TODO: Handle a path passed which already contains workspace
const coveragePath = `${process.env.GITHUB_WORKSPACE}/${core.getInput('lcov-path') || 'coverage/lcov.info'}`;
// Use coverage file if it exists (Next builds), otherwise download artifact and write to disk (Node builds)
if ((0, fs_1.existsSync)(coveragePath)) {
core.debug(`Coverage file already exists at path "${coveragePath}"`);
core.info(`Using existing coverage file at path "${coveragePath}"`);
}
else {
core.debug(`Coverage file does not already exist at path "${coveragePath}", downloading from artifact`);
core.info(`Coverage file does not already exist at path "${coveragePath}", downloading from artifact`);
await downloadAndWriteArtifact(coveragePath);
}
// Report to Coveralls as base
Expand Down
14 changes: 8 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ async function downloadAndWriteArtifact(coveragePath: string) {
// Unzip
core.debug(`Unziping artifact file at path "${downloadPath}"`);
await exec('unzip', [downloadPath, '-d', coverageFolder]);
core.debug('Successfully unzipped artifact file');
core.info('Successfully downloaded and unzipped coverage artifact');
}

/**
*
*/
export async function run() {
const coveragePath = `${process.env.GITHUB_WORKSPACE}/${core.getInput(
'lcov-path',
)}`;
core.debug(`lcov-path input: ${core.getInput('lcov-path')}`);
// TODO: Handle a path passed which already contains workspace
const coveragePath = `${process.env.GITHUB_WORKSPACE}/${
core.getInput('lcov-path') || 'coverage/lcov.info'
}`;
// Use coverage file if it exists (Next builds), otherwise download artifact and write to disk (Node builds)
if (existsSync(coveragePath)) {
core.debug(`Coverage file already exists at path "${coveragePath}"`);
core.info(`Using existing coverage file at path "${coveragePath}"`);
} else {
core.debug(
core.info(
`Coverage file does not already exist at path "${coveragePath}", downloading from artifact`,
);
await downloadAndWriteArtifact(coveragePath);
Expand Down

0 comments on commit cd6a0cc

Please sign in to comment.