Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI and Tests stabilization #372

Merged
merged 13 commits into from
Feb 12, 2018
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ As a courtesy, please add a comment informing about your intent. That way we wi

## Submitting Pull Requests

Just make sure your PR comes with its own tests and does pass [automated TravisCI tests](https://travis-ci.org/ipfs/ipfs-companion/branches).
Just make sure your PR comes with its own tests and does pass [automated CI build](https://ci.ipfs.team/blue/organizations/jenkins/IPFS%20Shipyard%2Fipfs-companion/pr).
See the [GitHub Flow Guide](https://guides.github.com/introduction/flow/) for details.

Read section below to get familiar with tools and commands that will make your work easier.
Expand Down Expand Up @@ -92,8 +92,8 @@ Each `npm` task can be run separately. The most useful ones are:

- `npm install` -- install all NPM dependencies
- `npm run build` -- build the add-on (copy external libraries, create `.zip` bundle)
- `npm run yarn-build` -- fast install+build with yarn
- `npm run docker-build` -- reproducible build using yarn.lock and specific version of yarn and node
- `npm run yarn-build` -- fast dependency install + build with yarn (installs and updates yarn.lock if needed)
- `npm run ci` -- reproducible test and build (with frozen yarn.lock)
- `npm test` -- run entire test suite
- `npm run lint` -- check for potential syntax problems (run all linters)
- `npm run lint:standard` -- run [standard](http://standardjs.com) linter ([IPFS JavaScript projects default to standard code style](https://github.com/ipfs/community/blob/master/js-project-guidelines.md#linting--code-style))
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:9.4.0-alpine
RUN apk add --update make gcc g++ python
FROM node:9.5.0
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/package.json
COPY yarn.lock /usr/src/app/yarn.lock
RUN yarn
RUN npm run ci:install
ENV PATH="/usr/src/app/node_modules/.bin:${PATH}"
COPY . /usr/src/app
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
![demo of v2.0.13](https://ipfs.io/ipfs/QmUxZrrjUGZVMjqc2noCRkQZr8B9JyGNj7sPpRoJ6uPQq1)

[![](https://img.shields.io/github/release/ipfs/ipfs-companion.svg)](https://github.com/ipfs/ipfs-companion/releases/latest)
[![](https://img.shields.io/badge/mozilla-full%20review-blue.svg)](https://addons.mozilla.org/en-US/firefox/addon/ipfs-companion/)
[![](https://img.shields.io/badge/mozilla-reviewed-blue.svg)](https://addons.mozilla.org/en-US/firefox/addon/ipfs-companion/)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-blue.svg)](http://standardjs.com/)
[![localization status](https://d322cqt584bo4o.cloudfront.net/ipfs-companion/localized.svg)](https://crowdin.com/project/ipfs-companion)
[![Coverage Status](https://coveralls.io/repos/github/lidel/ipfs-firefox-addon/badge.svg?branch=master)](https://coveralls.io/github/lidel/ipfs-firefox-addon?branch=master)
[![build-status](https://travis-ci.org/ipfs/ipfs-companion.svg?branch=master)](https://travis-ci.org/ipfs/ipfs-companion)
[![build-status](https://img.shields.io/jenkins/s/http/ci.ipfs.team/job/IPFS%20Shipyard/job/ipfs-companion/job/master.svg)](https://ci.ipfs.team/blue/organizations/jenkins/IPFS%20Shipyard%2Fipfs-companion/activity?branch=master)<br>
[![#ipfs-in-web-browsers](https://img.shields.io/badge/irc-%23ipfs--in--web--browsers-brightgreen.svg)](https://webchat.freenode.net/?channels=ipfs-in-web-browsers)

> Browser extension that simplifies access to IPFS resources
Expand Down
33 changes: 28 additions & 5 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
node(label: 'linux') {
checkout scm
sh 'docker build -t ipfs-companion .'
sh 'docker run -i ipfs-companion yarn test'
sh 'docker run -i -v $(pwd)/build:/usr/src/app/build ipfs-companion yarn build'
archiveArtifacts artifacts: 'build/*.zip'
stage('git:checkout') {
checkout scm
sh 'printenv'
}
stage('ci:install') {
sh 'docker build -t ipfs-companion:${JOB_BASE_NAME}-${BUILD_NUMBER} .'
}
catchError {
stage('ci:test') {
sh 'docker run -i --name ipfs-companion-test-${JOB_BASE_NAME}-${BUILD_NUMBER} -e JUNIT_REPORT_PATH=test/report.xml ipfs-companion:${JOB_BASE_NAME}-${BUILD_NUMBER} npm run ci:test'
sh 'docker cp ipfs-companion-test-${JOB_BASE_NAME}-${BUILD_NUMBER}:/usr/src/app/test/report.xml test/report.xml || true' // copy test report
}
}
sh 'docker rm ipfs-companion-test-${JOB_BASE_NAME}-${BUILD_NUMBER}'
junit allowEmptyResults: true, testResults: 'test/report.xml'
catchError {
stage('ci:build') {
sh 'docker run -i --name ipfs-companion-build-${JOB_BASE_NAME}-${BUILD_NUMBER} ipfs-companion:${JOB_BASE_NAME}-${BUILD_NUMBER} npm run ci:build'
sh 'docker cp ipfs-companion-build-${JOB_BASE_NAME}-${BUILD_NUMBER}:/usr/src/app/build/ . || true' // copy package
sh 'docker cp ipfs-companion-build-${JOB_BASE_NAME}-${BUILD_NUMBER}:/usr/src/app/add-on/ . || true' // needed for lint:web-ext
archiveArtifacts artifacts: 'build/*.zip', fingerprint: true
}
stage('lint:web-ext') {
sh 'docker run -i --rm -v $(pwd)/add-on:/usr/src/app/add-on ipfs-companion:${JOB_BASE_NAME}-${BUILD_NUMBER} npm run lint:web-ext'
}
}
sh 'docker rm ipfs-companion-build-${JOB_BASE_NAME}-${BUILD_NUMBER}'
sh 'docker rmi -f ipfs-companion:${JOB_BASE_NAME}-${BUILD_NUMBER}'
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
"watch:content-scripts:ipfs-proxy:content": "watchify -s IpfsProxyContent add-on/src/contentScripts/ipfs-proxy/content.js -o add-on/dist/contentScripts/ipfs-proxy/content.js",
"watch:content-scripts:ipfs-proxy:page": "watchify -s IpfsProxyPage add-on/src/contentScripts/ipfs-proxy/page.js -o add-on/dist/contentScripts/ipfs-proxy/page.js",
"test": "run-s test:*",
"test:functional": " nyc --reporter=lcov --reporter=text mocha --require ignore-styles 'test/functional/**/*.test.js'",
"test:functional": " nyc --reporter=lcov --reporter=text mocha --color --timeout 15000 --require ignore-styles --reporter mocha-jenkins-reporter 'test/functional/**/*.test.js'",
"lint": "run-s lint:*",
"lint:standard": "standard --fix -v \"add-on/src/**/*.js\" \"test/**/*.js\"",
"lint:web-ext": "web-ext lint -s add-on/",
"precommit": "run-s -s clean build lint",
"prepush": "run-s -s precommit test build",
"firefox": "web-ext run -s add-on/ --browser-console",
"ci": "run-s ci:*",
"ci:install": "npx yarn@1.3.2 install --frozen-lockfile",
"ci:test": "npx yarn@1.3.2 test",
"ci:build": "npx yarn@1.3.2 build",
"yarn-build": "npx yarn@1.3.2 && npx yarn@1.3.2 build"
},
"private": true,
Expand All @@ -56,6 +60,7 @@
"ignore-styles": "5.0.1",
"mem-storage-area": "1.0.3",
"mocha": "4.0.1",
"mocha-jenkins-reporter": "0.3.10",
"npm-run-all": "4.1.2",
"nyc": "^11.4.1",
"shx": "0.2.2",
Expand Down
16 changes: 7 additions & 9 deletions test/functional/lib/ipfs-companion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,29 @@ const browser = require('sinon-chrome')
const { URL } = require('url')
const { optionDefaults } = require('../../../add-on/src/lib/options')

describe('init', () => {
describe('init', function () {
let init

before(function () {
this.timeout = 1000 * 10
global.window = {}
global.browser = browser
global.URL = URL
init = require('../../../add-on/src/lib/ipfs-companion')
})

beforeEach(function () {
this.timeout = 1000 * 10
browser.flush()
})

it('should query local storage for options with hardcoded defaults for fallback', async () => {
it('should query local storage for options with hardcoded defaults for fallback', async function () {
browser.storage.local.get.returns(Promise.resolve(optionDefaults))
browser.storage.local.set.returns(Promise.resolve())
const ipfsCompanion = await init()
browser.storage.local.get.calledWith(optionDefaults)
ipfsCompanion.destroy()
})

after(() => {
after(function () {
delete global.window
delete global.browser
delete global.URL
Expand All @@ -39,18 +37,18 @@ describe('init', () => {
describe.skip('onStorageChange()', function () {
let init

before(() => {
before(function () {
global.window = {}
global.browser = browser
global.URL = URL
init = require('../../../add-on/src/lib/ipfs-companion')
})

beforeEach(() => {
beforeEach(function () {
browser.flush()
})

it('should update ipfs API instance on IPFS API URL change', async () => {
it('should update ipfs API instance on IPFS API URL change', async function () {
browser.storage.local.get.returns(Promise.resolve(optionDefaults))
browser.storage.local.set.returns(Promise.resolve())
browser.browserAction.setBadgeBackgroundColor.returns(Promise.resolve())
Expand All @@ -72,7 +70,7 @@ describe.skip('onStorageChange()', function () {
ipfsCompanion.destroy()
})

after(() => {
after(function () {
delete global.window
delete global.browser
delete global.URL
Expand Down
116 changes: 116 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,12 @@ debug@2, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.6.1, d
dependencies:
ms "2.0.0"

debug@2.6.8:
version "2.6.8"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
dependencies:
ms "2.0.0"

debug@3.1.0, debug@^3.0.1, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
Expand Down Expand Up @@ -2229,6 +2235,14 @@ dicer@^0.2.5:
readable-stream "1.1.x"
streamsearch "0.1.2"

diff@1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/diff/-/diff-1.0.7.tgz#24bbb001c4a7d5522169e7cabdb2c2814ed91cf4"

diff@3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"

diff@3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75"
Expand Down Expand Up @@ -3423,6 +3437,17 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"

glob@7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.2"
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.0, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
Expand Down Expand Up @@ -3534,6 +3559,10 @@ growl@1.10.3:
version "1.10.3"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f"

growl@1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f"

growly@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
Expand Down Expand Up @@ -4824,6 +4853,10 @@ json-text-sequence@^0.1:
dependencies:
delimit-stream "0.1.0"

json3@3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"

json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
Expand Down Expand Up @@ -5412,10 +5445,41 @@ lock-me@^1.0.3:
optionalDependencies:
fs-ext "github:baudehlo/node-fs-ext#master"

lodash._baseassign@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
dependencies:
lodash._basecopy "^3.0.0"
lodash.keys "^3.0.0"

lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"

lodash._basecreate@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821"

lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"

lodash._isiterateecall@^3.0.0:
version "3.0.9"
resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c"

lodash.cond@^4.3.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"

lodash.create@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7"
dependencies:
lodash._baseassign "^3.0.0"
lodash._basecreate "^3.0.0"
lodash._isiterateecall "^3.0.0"

lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
Expand Down Expand Up @@ -5456,6 +5520,14 @@ lodash.includes@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f"

lodash.isarguments@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"

lodash.isarray@^3.0.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"

lodash.isequalwith@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.isequalwith/-/lodash.isequalwith-4.4.0.tgz#266726ddd528f854f21f4ea98a065606e0fbc6b0"
Expand All @@ -5472,6 +5544,14 @@ lodash.isundefined@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash.isundefined/-/lodash.isundefined-3.0.1.tgz#23ef3d9535565203a66cefd5b830f848911afb48"

lodash.keys@^3.0.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
dependencies:
lodash._getnative "^3.0.0"
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"

lodash.map@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
Expand Down Expand Up @@ -5797,6 +5877,15 @@ mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:
dependencies:
minimist "0.0.8"

mocha-jenkins-reporter@0.3.10:
version "0.3.10"
resolved "https://registry.yarnpkg.com/mocha-jenkins-reporter/-/mocha-jenkins-reporter-0.3.10.tgz#11b04b84f7bef0ffa2baae6cf6ae9c1c2a0c121b"
dependencies:
diff "1.0.7"
mkdirp "0.5.1"
mocha "^3.0.0"
xml "^1.0.1"

mocha@4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-4.0.1.tgz#0aee5a95cf69a4618820f5e51fa31717117daf1b"
Expand All @@ -5812,6 +5901,23 @@ mocha@4.0.1:
mkdirp "0.5.1"
supports-color "4.4.0"

mocha@^3.0.0:
version "3.5.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d"
dependencies:
browser-stdout "1.3.0"
commander "2.9.0"
debug "2.6.8"
diff "3.2.0"
escape-string-regexp "1.0.5"
glob "7.1.1"
growl "1.9.2"
he "1.1.1"
json3 "3.3.2"
lodash.create "3.1.1"
mkdirp "0.5.1"
supports-color "3.1.2"

module-deps@^4.0.8:
version "4.1.1"
resolved "https://registry.yarnpkg.com/module-deps/-/module-deps-4.1.1.tgz#23215833f1da13fd606ccb8087b44852dcb821fd"
Expand Down Expand Up @@ -8246,6 +8352,12 @@ subtext@^5.0.0:
pez "2.x.x"
wreck "12.x.x"

supports-color@3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5"
dependencies:
has-flag "^1.0.0"

supports-color@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e"
Expand Down Expand Up @@ -8996,6 +9108,10 @@ xml2js@~0.4.4:
sax ">=0.6.0"
xmlbuilder "~9.0.1"

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"

xmlbuilder@~9.0.1:
version "9.0.4"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.4.tgz#519cb4ca686d005a8420d3496f3f0caeecca580f"
Expand Down