An open API service indexing awesome lists of open source software.

https://github.com/bconnorwhite/coveralls-api

API client for coveralls.io
https://github.com/bconnorwhite/coveralls-api

coveralls-api lcov stringify typescript typescript-definitions

Last synced: about 1 year ago
JSON representation

API client for coveralls.io

Awesome Lists containing this project

README

          


coveralls-api



npm


typescript


Coverage Status


GitHub stars


Twitter Follow


> API client for [coveralls.io](https://coveralls.io/).

To use coveralls-api, you will need a personal token. Personal tokens can be created on the [Coveralls account page](https://coveralls.io/account).

Full documentation:
- Repos: https://coveralls.io/api/docs
- Jobs: https://docs.coveralls.io/api-reference

## Installation

```bash
yarn add coveralls-api
```

```bash
npm install coveralls-api
```

## API

- [Create Repo](#create-repo)
- [Get Repo](#get-repo)
- [Update Repo](#update-repo)
- [Post Job](#post-job)

### Create Repo

#### Usage

```ts
import Coveralls from "coveralls-api";

const coveralls = new Coveralls(token);

coveralls.createRepo({
service: "github",
name: "my-repo-name"
}).then((response) => {
// ...
});
```

#### Types
```ts
function createRepo(args: CreateRepoArgs): Promise;

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

```ts
import Coveralls from "coveralls-api";

const coveralls = new Coveralls(token);

coveralls.getRepo("github", "my-github-user", "my-repo-name").then((response) => {
// ...
});
```

#### Types
```ts
function updateRepo(
service: Service,
user: string,
name: string
): Promise

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

```ts
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
```ts
function updateRepo(
service: Service,
user: string,
name: string,
args: UpdateRepoArgs
): Promise

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
```ts
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
```ts
function postJob(service: Service, user: string, name: string, args: PostJobArgs | PostJobFromLCOVArgs): Promise;

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;
}
```


Dependenciesdependencies

- [@bconnorwhite/exec](https://www.npmjs.com/package/@bconnorwhite/exec): Execute commands while keeping flags easily configurable as an object
- [cross-fetch-json](https://www.npmjs.com/package/cross-fetch-json): Universal fetch API that only returns JSON
- [form-data](https://www.npmjs.com/package/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](https://www.npmjs.com/package/md5): Js function for hashing messages with MD5
- [parse-json-object](https://www.npmjs.com/package/parse-json-object): Parse a typed JSON object
- [read-file-safe](https://www.npmjs.com/package/read-file-safe): Read files without try catch.
- [read-lcov-safe](https://www.npmjs.com/package/read-lcov-safe): Read and parse an lcov file without try catch
- [stringify-json-object](https://www.npmjs.com/package/stringify-json-object): Stringify and format a JSON object.


Dev DependenciesDavid

- [@bconnorwhite/bob](https://www.npmjs.com/package/@bconnorwhite/bob): Bob is a toolkit for TypeScript projects
- [@types/md5](https://www.npmjs.com/package/@types/md5): TypeScript definitions for md5
- [@types/node](https://www.npmjs.com/package/@types/node): TypeScript definitions for Node.js
- [dotenv](https://www.npmjs.com/package/dotenv): Loads environment variables from .env file


License license

[MIT](https://opensource.org/licenses/MIT)