Skip to content

Commit

Permalink
Merge pull request #50 from cortex-lab/coverage
Browse files Browse the repository at this point in the history
Added coverage
  • Loading branch information
k1o0 authored Feb 5, 2021
2 parents 3edec0a + 7aa45f5 commit 5a6bb88
Show file tree
Hide file tree
Showing 9 changed files with 1,249 additions and 50 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog

## [Latest](https://github.com/cortex-lab/matlab-ci/commits/master) [2.1.0]
## [Latest](https://github.com/cortex-lab/matlab-ci/commits/master) [2.2.0]

## Added
- nyc dependency for manual coverage of matlab-ci

## Modified

- removed old dependencies
- support for short ids and branch names for all endpoints

## [2.1.0]

### Modified
- More generic handling of submodules
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# MATLAB-ci
[![Build Status](https://travis-ci.com/cortex-lab/matlab-ci.svg?branch=master)](https://travis-ci.com/cortex-lab/matlab-ci)
[![Coverage](https://img.shields.io/badge/coverage-81.07-green)](https://img.shields.io/badge/coverage-72.35-yellowgreen)

A small set of modules written in Node.js for running automated tests of MATLAB code in response to GitHub events. Also submits code coverage to the Coveralls API.

Currently unsupported:
* Running tests on forked repositories
* Testing multiple repos (unless they are submodules)
* Testing multiple repos (unless they are submodules)

## Getting Started

Expand Down Expand Up @@ -59,9 +60,18 @@ chmod u+x ./prep_env.BAT
```

## Running the tests

Before running the tests ensure the dev dependencies are installed.
On Windows:
```
set "DOTENV_CONFIG_PATH=./test/fixtures/.env.test" & npm test
```
On Linux:
```
DOTENV_CONFIG_PATH=./test/fixtures/.env.test & npm test
```
Coverage:
```
mocha ./test
DOTENV_CONFIG_PATH=./test/fixtures/.env.test & npm run coverage
```

## Deployment
Expand Down
6 changes: 3 additions & 3 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function compareCoverage(job) {
}
log('Comparing coverage for %g -> %g', job.data.sha, job.data.base);
var records;
if (!job.coverage) {
if (!job.data.coverage) {
log('No coverage in job data; loading from records');
records = loadTestRecords([job.data.sha, job.data.base]);
// Filter duplicates just in case
Expand All @@ -341,7 +341,7 @@ function compareCoverage(job) {
records = [curr, loadTestRecords(job.data.base)];
}
log('The following records were found: %O', records);
const has_coverage = records.every(o => (typeof o.coverage !== 'undefined' && o.coverage > 0));
const hasCoverage = records.every(o => (o.coverage > 0));

// Check if any errored or failed to update coverage
if (records.filter(o => o.status === 'error').length > 0) {
Expand All @@ -350,7 +350,7 @@ function compareCoverage(job) {
job.data.description = 'Failed to determine coverage as tests incomplete due to errors';

// Both records present and they have coverage
} else if (records.length === 2 && has_coverage) {
} else if (records.length === 2 && hasCoverage) {
log('Calculating coverage difference');
// Ensure first record is for head commit
if (records[0].commit === job.data.base) { records.reverse() }
Expand Down
Loading

0 comments on commit 5a6bb88

Please sign in to comment.