Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
fix: check for coveralls response before erroring (#15)
Browse files Browse the repository at this point in the history
prescottprue authored Jul 18, 2022
1 parent 10c93b9 commit 343c8d4
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -14021,17 +14021,17 @@ async function reportToCoveralls(lcovPath) {
branch,
},
};
core.debug(`Uploading base coverage to Coveralls with settings: ${JSON.stringify(jobSettings, null, 2)}`);
core.info(`Uploading base coverage to Coveralls with settings: ${JSON.stringify(jobSettings, null, 2)}`);
try {
const coveralls = new coveralls_api_1.default(core.getInput('coveralls-token', { required: true }));
const response = await coveralls.postJob('github', owner, repo, jobSettings);
core.debug(`Response from coveralls: ${JSON.stringify(response)}`);
const response = (await coveralls.postJob('github', owner, repo, jobSettings));
core.info(`Response from coveralls: ${JSON.stringify(response)}`);
// Casting is because current library types are incorrect about error not being on response
if (response.error) {
if (response?.error) {
throw new Error(response.message);
}
core.info(`Successfully uploaded base coverage to Coveralls for branch "${branch}": ${response.url}`);
core.setOutput('coverage-url', response.url);
core.info(`Successfully uploaded base coverage to Coveralls for branch "${branch}". Coveralls URL: ${response?.url}`);
core.setOutput('coverage-url', response?.url);
}
catch (err) {
const error = err;
16 changes: 8 additions & 8 deletions src/coveralls.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import * as core from '@actions/core';
import { context } from '@actions/github';
import Coveralls, { PostJobFromLCOVArgs, PostJobResponse } from 'coveralls-api';

type ActualPostJobResponse = PostJobResponse & { error: boolean };
type ActualPostJobResponse = (PostJobResponse & { error: boolean }) | null;

/**
* Report coverage to Coveralls for base branch
@@ -24,7 +24,7 @@ export async function reportToCoveralls(lcovPath: string) {
branch,
},
};
core.debug(
core.info(
`Uploading base coverage to Coveralls with settings: ${JSON.stringify(
jobSettings,
null,
@@ -35,21 +35,21 @@ export async function reportToCoveralls(lcovPath: string) {
const coveralls = new Coveralls(
core.getInput('coveralls-token', { required: true }),
);
const response = await coveralls.postJob(
const response = (await coveralls.postJob(
'github',
owner,
repo,
jobSettings,
);
core.debug(`Response from coveralls: ${JSON.stringify(response)}`);
)) as ActualPostJobResponse;
core.info(`Response from coveralls: ${JSON.stringify(response)}`);
// Casting is because current library types are incorrect about error not being on response
if ((response as ActualPostJobResponse).error) {
if (response?.error) {
throw new Error(response.message);
}
core.info(
`Successfully uploaded base coverage to Coveralls for branch "${branch}": ${response.url}`,
`Successfully uploaded base coverage to Coveralls for branch "${branch}". Coveralls URL: ${response?.url}`,
);
core.setOutput('coverage-url', response.url);
core.setOutput('coverage-url', response?.url);
} catch (err) {
const error = err as Error;
core.error(`Error uploading lcov to Coveralls: ${error.message}`);

0 comments on commit 343c8d4

Please sign in to comment.