API client for coveralls.io.
To use coveralls-api, you will need a personal token. Personal tokens can be created on the Coveralls account page.
Full documentation:
Installation
yarn add coveralls-api
npm install coveralls-api
API
Create Repo
Usage
import Coveralls from "coveralls-api";
const coveralls = new Coveralls(token);
coveralls.createRepo({
service: "github",
name: "my-repo-name"
}).then((response) => {
// ...
});
Types
function createRepo(args: CreateRepoArgs): Promise<CreateRepoResponse | undefined>;
type CreateRepoArgs = {
service: Service;
name: string;
comment_on_pull_requests?: boolean;
send_build_status?: boolean;
commit_status_fail_threshold?: number | null;
commit_status_fail_change_threshold?: number | null;
}
type CreateRepoResponse = {
service: Service;
name: string;
comment_on_pull_requests?: boolean;
send_build_status?: boolean;
commit_status_fail_threshold?: number | null;
commit_status_fail_change_threshold?: number | null;
created_at: string;
updated_at: string;
}
type Service = "github" | "bitbucket" | "gitlab" | "stash" | "manual";
Get Repo
Usage
import Coveralls from "coveralls-api";
const coveralls = new Coveralls(token);
coveralls.getRepo("github", "my-github-user", "my-repo-name").then((response) => {
// ...
});
Types
function updateRepo(
service: Service,
user: string,
name: string
): Promise<GetRepoReponse | undefined>
type GetRepoResponse = {
service: Service;
name: string;
comment_on_pull_requests?: boolean;
send_build_status?: boolean;
commit_status_fail_threshold?: number | null;
commit_status_fail_change_threshold?: number | null;
created_at: string;
updated_at: string;
id: number;
has_badge: boolean;
token?: string;
}
Update Repo
Usage
import Coveralls from "coveralls-api";
const coveralls = new Coveralls(token);
coveralls.updateRepo("github", "my-github-user", "my-repo-name", {
comment_on_pull_requests: true,
send_build_status: false
}).then((response) => {
// ...
});
Types
function updateRepo(
service: Service,
user: string,
name: string,
args: UpdateRepoArgs
): Promise<UpdateRepoReponse | undefined>
type UpdateRepoArgs = {
comment_on_pull_requests?: boolean;
send_build_status?: boolean;
commit_status_fail_threshold?: number | null;
commit_status_fail_change_threshold?: number | null;
}
type UpdateRepoResponse = {
service: Service;
name: string;
comment_on_pull_requests?: boolean;
send_build_status?: boolean;
commit_status_fail_threshold?: number | null;
commit_status_fail_change_threshold?: number | null;
created_at: string;
updated_at: string;
}
Post Job
Usage
import Coveralls from "coveralls-api";
const coveralls = new Coveralls(token);
// From LCOV file:
coveralls.postJob("github", "my-github-user", "my-repo-name", {
lcov_path: "coverage/lcov.info"
}).then((response) => {
// ...
});
// From source files:
coveralls.postJob("github", "my-github-user", "my-repo-name", {
source_files: [{
name: ...
}, ...]
}).then((response) => {
// ...
});
Types
function postJob(service: Service, user: string, name: string, args: PostJobArgs | PostJobFromLCOVArgs): Promise<PostJobResponse>;
export type PostJobFromLCOVArgs = {
lcov_path: string;
} & BaseJobArgs;
export type PostJobArgs = {
source_files: SourceFile[];
} & BaseJobArgs;
export type SourceFile = {
name: string;
source_digest: string;
coverage: (number | null)[];
branches?: number[];
source?: string;
}
type BaseJobArgs = {
service_name?: string;
service_number?: string;
service_job_id?: string;
service_pull_request?: string;
parallel?: boolean;
flag_name?: string;
git?: {
head?: {
id?: string;
committer_name?: string;
committer_email?: string;
message?: string;
author_name?: string;
author_email?: string;
};
branch?: string;
remotes?: {
name?: string;
url?: string;
}[];
};
commit_sha?: string;
run_at?: Date | string;
}
Dependencies
- @bconnorwhite/exec: Execute commands while keeping flags easily configurable as an object
- cross-fetch-json: Universal fetch API that only returns JSON
- form-data: A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.
- md5: Js function for hashing messages with MD5
- parse-json-object: Parse a typed JSON object
- read-file-safe: Read files without try catch.
- read-lcov-safe: Read and parse an lcov file without try catch
- stringify-json-object: Stringify and format a JSON object.
Dev Dependencies
- @bconnorwhite/bob: Bob is a toolkit for TypeScript projects
- @types/md5: TypeScript definitions for md5
- @types/node: TypeScript definitions for Node.js
- dotenv: Loads environment variables from .env file