Skip to content

Commit 19f44e5

Browse files
authored
chore: migrate to travis for ci (ipfs#41)
1 parent 25843c9 commit 19f44e5

File tree

10 files changed

+86
-21
lines changed

10 files changed

+86
-21
lines changed

.travis.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
language: node_js
2+
cache: npm
3+
stages:
4+
- check
5+
- test
6+
- cov
7+
8+
node_js:
9+
- '10'
10+
11+
os:
12+
- linux
13+
- osx
14+
- windows
15+
16+
script: npx nyc -s npm run test:node -- --bail
17+
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
18+
19+
jobs:
20+
include:
21+
- stage: check
22+
script:
23+
- npx aegir commitlint --travis
24+
- npx aegir dep-check
25+
- npm run lint
26+
27+
- stage: test
28+
name: chrome
29+
addons:
30+
chrome: stable
31+
script: npx aegir test -t browser
32+
33+
- stage: test
34+
name: webworker
35+
addons:
36+
chrome: stable
37+
script: npx aegir test -t webworker
38+
39+
- stage: test
40+
name: firefox
41+
addons:
42+
firefox: latest
43+
script: npx aegir test -t browser -- --browsers FirefoxHeadless
44+
45+
notifications:
46+
email: false

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
55
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
66
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
7-
[![Build Status](https://ci.ipfs.team/buildStatus/icon?job=ipfs/js-ipfs-mfs/master)](https://ci.ipfs.team/job/ipfs/job/js-ipfs-mfs/job/master/)
7+
[![Build Status](https://flat.badgen.net/travis/ipfs/js-ipfs-mfs)](https://travis-ci.com/ipfs/js-ipfs-mfs)
88
[![Code Coverage](https://codecov.io/gh/ipfs/js-ipfs-mfs/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-ipfs-mfs)
99
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-mfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-mfs)
1010
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

ci/Jenkinsfile

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"ipld-in-memory": "^2.0.0",
4747
"multihashes": "~0.4.14",
4848
"pull-buffer-stream": "^1.0.1",
49-
"pull-traverse": "^1.0.3"
49+
"pull-traverse": "^1.0.3",
50+
"temp-write": "^3.4.0"
5051
},
5152
"dependencies": {
5253
"async": "^2.6.1",

test/fixtures/large-file.jpg

-479 KB
Binary file not shown.

test/fixtures/small-file.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/helpers/random-bytes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
const crypto = require('crypto')
4+
const MAX_BYTES = 65536
5+
6+
// One day this will be merged: https://github.com/crypto-browserify/randombytes/pull/16
7+
module.exports = function randomBytes (num) {
8+
const bytes = Buffer.allocUnsafe(num)
9+
10+
for (let offset = 0; offset < num; offset += MAX_BYTES) {
11+
let size = MAX_BYTES
12+
13+
if ((offset + size) > num) {
14+
size = num - offset
15+
}
16+
17+
crypto.randomFillSync(bytes, offset, size)
18+
}
19+
20+
return bytes
21+
}

test/read.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44
const chai = require('chai')
55
chai.use(require('dirty-chai'))
66
const expect = chai.expect
7-
const path = require('path')
8-
const loadFixture = require('aegir/fixtures')
97
const bufferStream = require('pull-buffer-stream')
108
const pull = require('pull-stream/pull')
119
const collect = require('pull-stream/sinks/collect')
1210
const {
1311
createMfs,
1412
createShardedDirectory
1513
} = require('./helpers')
14+
const randomBytes = require('./helpers/random-bytes')
1615

1716
describe('read', () => {
1817
let mfs
19-
let smallFile = loadFixture(path.join('test', 'fixtures', 'small-file.txt'))
18+
let smallFile = randomBytes(13)
2019

2120
before(async () => {
2221
mfs = await createMfs()

test/stat.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
const chai = require('chai')
55
chai.use(require('dirty-chai'))
66
const expect = chai.expect
7-
const path = require('path')
8-
const loadFixture = require('aegir/fixtures')
7+
const randomBytes = require('./helpers/random-bytes')
98

109
const {
1110
createMfs,
@@ -16,8 +15,8 @@ const {
1615

1716
describe('stat', () => {
1817
let mfs
19-
let smallFile = loadFixture(path.join('test', 'fixtures', 'small-file.txt'))
20-
let largeFile = loadFixture(path.join('test', 'fixtures', 'large-file.jpg'))
18+
let smallFile = randomBytes(13)
19+
let largeFile = randomBytes(490668)
2120

2221
before(async () => {
2322
mfs = await createMfs()

test/write.spec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
const chai = require('chai')
55
chai.use(require('dirty-chai'))
66
const expect = chai.expect
7-
const path = require('path')
8-
const loadFixture = require('aegir/fixtures')
97
const isNode = require('detect-node')
108
const values = require('pull-stream/sources/values')
119
const bufferStream = require('pull-buffer-stream')
1210
const multihash = require('multihashes')
11+
const randomBytes = require('./helpers/random-bytes')
12+
const util = require('util')
1313
const {
1414
collectLeafCids,
1515
createMfs,
@@ -19,16 +19,17 @@ const {
1919
} = require('./helpers')
2020
const CID = require('cids')
2121

22-
let fs
22+
let fs, tempWrite
2323

2424
if (isNode) {
2525
fs = require('fs')
26+
tempWrite = require('temp-write')
2627
}
2728

2829
describe('write', () => {
2930
let mfs
30-
let smallFile = loadFixture(path.join('test', 'fixtures', 'small-file.txt'))
31-
let largeFile = loadFixture(path.join('test', 'fixtures', 'large-file.jpg'))
31+
let smallFile = randomBytes(13)
32+
let largeFile = randomBytes(490668)
3233

3334
const runTest = (fn) => {
3435
let i = 0
@@ -148,15 +149,16 @@ describe('write', () => {
148149
}
149150

150151
const filePath = `/small-file-${Math.random()}.txt`
151-
const pathToFile = path.resolve(path.join(__dirname, 'fixtures', 'small-file.txt'))
152+
const pathToFile = await tempWrite(smallFile)
153+
const fsStats = await util.promisify(fs.stat)(pathToFile)
152154

153155
await mfs.write(filePath, pathToFile, {
154156
create: true
155157
})
156158

157159
const stats = await mfs.stat(filePath)
158160

159-
expect(stats.size).to.equal(smallFile.length)
161+
expect(stats.size).to.equal(fsStats.size)
160162
})
161163

162164
it('writes part of a small file using a path (Node only)', async function () {
@@ -165,7 +167,7 @@ describe('write', () => {
165167
}
166168

167169
const filePath = `/small-file-${Math.random()}.txt`
168-
const pathToFile = path.resolve(path.join(__dirname, 'fixtures', 'small-file.txt'))
170+
const pathToFile = await tempWrite(smallFile)
169171

170172
await mfs.write(filePath, pathToFile, {
171173
create: true,
@@ -183,7 +185,7 @@ describe('write', () => {
183185
}
184186

185187
const filePath = `/small-file-${Math.random()}.txt`
186-
const pathToFile = path.resolve(path.join(__dirname, 'fixtures', 'small-file.txt'))
188+
const pathToFile = await tempWrite(smallFile)
187189
const stream = fs.createReadStream(pathToFile)
188190

189191
await mfs.write(filePath, stream, {

0 commit comments

Comments
 (0)