Skip to content

Commit 1ad9874

Browse files
authored
Travis windows (#46)
* yaml -> yml * travis * node version * Restore clocks in tests * Ensure files created before test * Added badge
1 parent 0712e8e commit 1ad9874

File tree

9 files changed

+35
-33
lines changed

9 files changed

+35
-33
lines changed

.travis.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js: 12
3+
env:
4+
- NODE_ENV=test
5+
jobs:
6+
include:
7+
- os: windows
8+
env: NODE_ENV=test DOTENV_CONFIG_PATH=.\\test\\fixtures\\.env.test
9+
- os: linux
10+
env: NODE_ENV=test DOTENV_CONFIG_PATH=./test/fixtures/.env.test
11+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# MATLAB-ci
2+
[![Build Status](https://travis-ci.com/cortex-lab/matlab-ci.svg?branch=master)](https://travis-ci.com/cortex-lab/matlab-ci)
23

34
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.
45

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A small set of modules written in Node.js for running automated tests of MATLAB and Python code in response to GitHub events. Also submits code coverage to the Coveralls API.",
55
"main": "main.js",
66
"scripts": {
7-
"test": "NODE_ENV=test DOTENV_CONFIG_PATH=.\\\\test\\\\fixtures\\\\.env.test mocha -r dotenv/config ./test --recursive --reporter spec",
7+
"test": "mocha -r dotenv/config ./test",
88
"start": "node -r dotenv/config main.js"
99
},
1010
"repository": {
@@ -41,12 +41,5 @@
4141
},
4242
"engines": {
4343
"node": ">=12.19.0"
44-
},
45-
"mocha": {
46-
"env": {
47-
"dotenv_config_path": "./test/fixtures/.env.test",
48-
"NODE_ENV": "test"
49-
},
50-
"require": "dotenv/config"
5144
}
5245
}

queue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Queue extends EventEmitter {
5050
// generate 16 digit job id
5151
let d = Date.now().toString()
5252
let r = Math.floor(Math.random() * 1000).toString()
53-
let id = Number(r.padStart(3, '0').concat(d))
53+
let id = Number(r.padStart(3, '0') + d)
5454
this.pile.push(new Job(id, data)); // add to bottom of pile
5555
console.log('Job added (' + this.pile.length + ' on pile)')
5656
this.next(); // Start next job if idle

serve.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ srv.get(`/${ENDPOINT}/records/:id`, function (req, res) {
132132
id: req.params.id
133133
};
134134
let endpoint = `GET /repos/:owner/:repo/${isSHA ? 'commits' : 'branches'}/:id`;
135-
log('request to endpoint %s', endpoint);
136135
request(endpoint, data)
137136
.then(response => {
138137
let id = isSHA ? response.data.sha : response.data.commit.sha;

test/lib.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('Test updateJobFromRecord:', function() {
9898
describe('Test startJobTimer:', function() {
9999
var clock;
100100

101-
beforeEach(function () {
101+
before(function () {
102102
clock = sinon.useFakeTimers();
103103
});
104104

test/queue.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('Test Queue constructor:', function() {
3939
assert.strictEqual(this.Q.pile.length, 2, 'failed to add more than one job')
4040
let id = this.Q.pile[0].id
4141
let isInt16 = Number.isInteger(id) && id.toString().length === 16
42-
assert(isInt16, 'unexpected id')
42+
assert(isInt16, `unexpected id ${id}`)
4343

4444
// Check the set is unique
4545
var ids = this.Q.pile.map((job) => { return job.id; })

test/serve.test.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ describe('setAccessToken', () => {
4646

4747
before(function () {
4848
expiry.setTime(expiry.getTime() + 60e3); // 60s in the future
49-
});
50-
51-
beforeEach(function() {
5249
// https://runkit.com/gr2m/reproducable-jwt
5350
clock = sinon.useFakeTimers({
5451
now: 0,
5552
toFake: ['Date']
5653
});
54+
});
55+
56+
beforeEach(function() {
5757
// Mock for App.installationAccessToken
5858
scope = nock('https://api.github.com', {
5959
reqheaders: {
@@ -133,11 +133,8 @@ describe('setAccessToken', () => {
133133
});
134134
});
135135

136-
afterEach(function() {
137-
clock.restore();
138-
});
139-
140136
after(async function() {
137+
clock.restore();
141138
await resetToken();
142139
})
143140
});
@@ -571,25 +568,26 @@ describe('records endpoint', () => {
571568
*/
572569
describe('coverage endpoint', () => {
573570

574-
before(function() {
571+
before(function(done) {
575572
let reportsDir = path.join(config.dataPath, 'reports', SHA);
576-
fs.mkdir(reportsDir, { recursive: true }, (err) => {
573+
fs.mkdir(reportsDir, { recursive: true }, async (err) => {
577574
if (err) throw err;
578-
fs.writeFile(path.join(reportsDir, 'foobar.log'), '', (err) => { if (err) throw err; })
579-
fs.writeFile(path.join(reportsDir, 'index.html'), '', (err) => { if (err) throw err; })
575+
await fs.writeFile(path.join(reportsDir, 'foobar.log'), '', (err) => { if (err) throw err; })
576+
await fs.writeFile(path.join(reportsDir, 'index.html'), '', (err) => { if (err) throw err; })
577+
done()
580578
});
581579
})
582580

583581
it('expect root not found', (done) => {
584582
request(srv)
585583
.get(`/${ENDPOINT}/coverage/`) // trailing slash essential
586584
.expect(404)
587-
.end(function (err, res) {
585+
.end(err => {
588586
err? done(err) : done();
589587
});
590588
});
591589

592-
it('expect dir served found', (done) => {
590+
it('expect dir to be served', (done) => {
593591
request(srv)
594592
.get(`/${ENDPOINT}/coverage/${SHA}/`) // trailing slash essential
595593
.expect(200)
@@ -718,12 +716,15 @@ describe('srv github/', () => {
718716
var scope; // Our server mock
719717
var clock; // Our clock mock for replicable JWT
720718

721-
beforeEach(function() {
719+
before(function() {
722720
// https://runkit.com/gr2m/reproducable-jwt
723721
clock = sinon.useFakeTimers({
724722
now: 0,
725723
toFake: ['Date']
726724
});
725+
});
726+
727+
beforeEach(function() {
727728
// Mock for App.installationAccessToken
728729
scope = nock('https://api.github.com', {
729730
reqheaders: {
@@ -771,4 +772,8 @@ describe('srv github/', () => {
771772
});
772773
});
773774

775+
after(function () {
776+
clock.restore();
777+
});
778+
774779
});

0 commit comments

Comments
 (0)