From daca3d72eb200f7e5d716a3e8e7f7c6ad0560dd6 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 28 Aug 2019 16:08:48 +0100 Subject: [PATCH] # This is a combination of 18 commits. # This is the 1st commit message: try gh actions License: MIT Signed-off-by: Henrique Dias # This is the commit message #2: add build License: MIT Signed-off-by: Henrique Dias # This is the commit message #3: License: MIT Signed-off-by: Henrique Dias # This is the commit message #4: License: MIT Signed-off-by: Henrique Dias # This is the commit message #5: add gh token License: MIT Signed-off-by: Henrique Dias # This is the commit message #6: fix names License: MIT Signed-off-by: Henrique Dias # This is the commit message #7: add chrome-log driver License: MIT Signed-off-by: Henrique Dias # This is the commit message #8: License: MIT Signed-off-by: Henrique Dias # This is the commit message #9: xvfb? License: MIT Signed-off-by: Henrique Dias # This is the commit message #10: install xvfb License: MIT Signed-off-by: Henrique Dias # This is the commit message #11: License: MIT Signed-off-by: Henrique Dias # This is the commit message #12: License: MIT Signed-off-by: Henrique Dias # This is the commit message #13: License: MIT Signed-off-by: Henrique Dias # This is the commit message #14: add screensize License: MIT Signed-off-by: Henrique Dias # This is the commit message #15: License: MIT Signed-off-by: Henrique Dias # This is the commit message #16: License: MIT Signed-off-by: Henrique Dias # This is the commit message #17: xvfb-maybe License: MIT Signed-off-by: Henrique Dias # This is the commit message #18: chore! License: MIT Signed-off-by: Henrique Dias --- .github/workflows/build.yaml | 37 ++++++++++++++++++++++ .travis.yml | 29 ----------------- appveyor.yml | 24 -------------- package-lock.json | 27 ++++++++++++++++ package.json | 10 +++--- test/{launch.spec.js => e2e/launch.e2e.js} | 5 +-- test/{ => e2e}/utils/include.js | 0 test/{ => e2e}/utils/ipfsd.js | 0 test/{ => unit}/create-toggler.spec.js | 2 +- test/{ => unit}/dock.spec.js | 20 ++++++------ test/{ => unit}/mocks/electron.js | 0 test/{ => unit}/mocks/store.js | 0 test/{ => unit}/mocks/webui.js | 0 13 files changed, 84 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml rename test/{launch.spec.js => e2e/launch.e2e.js} (98%) rename test/{ => e2e}/utils/include.js (100%) rename test/{ => e2e}/utils/ipfsd.js (100%) rename test/{ => unit}/create-toggler.spec.js (98%) rename test/{ => unit}/dock.spec.js (82%) rename test/{ => unit}/mocks/electron.js (100%) rename test/{ => unit}/mocks/store.js (100%) rename test/{ => unit}/mocks/webui.js (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..128439791 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,37 @@ +name: CI + +on: [push] + +jobs: + lint-unit: + name: lint and unit testing + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + version: 12.x + - run: npm install + - run: npm run lint + - run: npm run test + e2e-build: + name: e2e tests and building + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + needs: + - lint-unit + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + version: 12.x + - run: npm install + - run: npm run test:e2e + env: + CI: true + - run: npm run build + env: + CI: true + GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f611951d8..000000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: node_js - -services: - - xvfb - -node_js: - - 12.1.0 - -os: - - linux - - osx - -osx_image: xcode11 - -before_script: - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - sudo apt update - sudo apt install -y rpm - sudo snap install snapcraft --classic - fi - -script: - - npm run test - - npm run lint - - npm run build - -notifications: - email: false diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index b1b33732f..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,24 +0,0 @@ -image: Visual Studio 2017 - -os: unstable - -platform: - - x64 - -cache: - - node_modules - - '%USERPROFILE%\.electron' - -init: - - git config --global core.autocrlf input - -install: - - ps: Install-Product node 10 x64 - - npm install - -build_script: - - npm run test - - npm run lint - - npm run build - -test: off diff --git a/package-lock.json b/package-lock.json index 73ee79253..3c442da44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11280,6 +11280,33 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, + "xvfb-maybe": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/xvfb-maybe/-/xvfb-maybe-0.2.1.tgz", + "integrity": "sha1-7YyxMpV7eEi0OZhMZvAQ6n8kNhs=", + "dev": true, + "requires": { + "debug": "^2.2.0", + "which": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/package.json b/package.json index d4635af5f..6481eb165 100644 --- a/package.json +++ b/package.json @@ -8,16 +8,17 @@ "scripts": { "start": "cross-env NODE_ENV=development electron -r @babel/register src/index.js", "lint": "standard", - "test": "cross-env NODE_ENV=test mocha -r @babel/register", + "test": "cross-env NODE_ENV=test mocha test/unit/**/*.spec.js -r @babel/register", + "test:e2e": "xvfb-maybe cross-env NODE_ENV=test mocha test/e2e/**/*.e2e.js -r @babel/register", "postinstall": "run-s install-app-deps build:webui", "install-app-deps": "electron-builder install-app-deps", "clean:webui": "shx rm -rf assets/webui/", "build": "run-s build:*", "build:webui": "run-s build:webui:*", - "build:webui:download": "npx ipfs-or-gateway -c QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz -p assets/webui/ -t 360000 --verbose", + "build:webui:download": "npx ipfs-or-gateway -c QmQn7B9nLDXgDWjVjgjHActHDQ3AK1NRv7f733P8ki7dik -p assets/webui/ -t 360000 --verbose", "build:webui:minimize": "shx rm -rf assets/webui/static/js/*.map && shx rm -rf assets/webui/static/css/*.map", "build:babel": "babel src --out-dir out --copy-files", - "build:binaries": "electron-builder --publish onTag" + "build:binaries": "electron-builder" }, "pre-commit": [ "lint" @@ -70,7 +71,8 @@ "spectron": "^8.0.0", "standard": "^14.1.0", "tar": "^4.4.10", - "tmp": "0.1.0" + "tmp": "0.1.0", + "xvfb-maybe": "^0.2.1" }, "dependencies": { "@babel/runtime": "^7.5.5", diff --git a/test/launch.spec.js b/test/e2e/launch.e2e.js similarity index 98% rename from test/launch.spec.js rename to test/e2e/launch.e2e.js index ae4fa28e6..fdfe2d43b 100644 --- a/test/launch.spec.js +++ b/test/e2e/launch.e2e.js @@ -39,12 +39,13 @@ describe('Application launch', function () { }) { app = new Application({ path: electronPath, - args: ['-r', path.join(__dirname, 'utils/include.js'), path.join(__dirname, '../src/index.js')], + args: ['-r', path.join(__dirname, 'utils/include.js'), path.join(__dirname, '../../src/index.js')], env: { NODE_ENV: 'test', HOME: home, IPFS_PATH: ipfsPath - } + }, + chromeDriverArgs: ['--no-sandbox'] }) await app.start() return { app, ipfsPath, home } diff --git a/test/utils/include.js b/test/e2e/utils/include.js similarity index 100% rename from test/utils/include.js rename to test/e2e/utils/include.js diff --git a/test/utils/ipfsd.js b/test/e2e/utils/ipfsd.js similarity index 100% rename from test/utils/ipfsd.js rename to test/e2e/utils/ipfsd.js diff --git a/test/create-toggler.spec.js b/test/unit/create-toggler.spec.js similarity index 98% rename from test/create-toggler.spec.js rename to test/unit/create-toggler.spec.js index 5d2b92eeb..c9d76eb87 100644 --- a/test/create-toggler.spec.js +++ b/test/unit/create-toggler.spec.js @@ -18,7 +18,7 @@ describe('Create toggler', () => { electron = mockElectron() store = mockStore() webui = mockWebUI() - createToggler = proxyquire('../src/create-toggler', { + createToggler = proxyquire('../../src/create-toggler', { electron: electron, './common/store': store }).default diff --git a/test/dock.spec.js b/test/unit/dock.spec.js similarity index 82% rename from test/dock.spec.js rename to test/unit/dock.spec.js index 48adb6141..0efeec223 100644 --- a/test/dock.spec.js +++ b/test/unit/dock.spec.js @@ -14,21 +14,21 @@ chai.use(dirtyChai) describe('Dock', () => { it('show dock succeeds with dock (macOS)', () => { const electron = mockElectron({ withDock: true }) - const { show } = proxyquire('../src/dock', { electron }).default + const { show } = proxyquire('../../src/dock', { electron }).default show() expect(electron.app.dock.show.callCount).to.equal(1) }) it('show dock succeeds without dock (other OSes)', () => { const electron = mockElectron() - const { show } = proxyquire('../src/dock', { electron }).default + const { show } = proxyquire('../../src/dock', { electron }).default show() }) it('hide dock succeeds with dock and no windows (macOS)', () => { const electron = mockElectron({ withDock: true }) electron.BrowserWindow.getAllWindows.returns([]) - const { hide } = proxyquire('../src/dock', { electron }).default + const { hide } = proxyquire('../../src/dock', { electron }).default hide() expect(electron.app.dock.hide.callCount).to.equal(1) }) @@ -40,7 +40,7 @@ describe('Dock', () => { { isVisible: sinon.stub().returns(false) } ] electron.BrowserWindow.getAllWindows.returns(windows) - const { hide } = proxyquire('../src/dock', { electron }).default + const { hide } = proxyquire('../../src/dock', { electron }).default hide() expect(windows[0].isVisible.callCount).to.equal(1) expect(windows[1].isVisible.callCount).to.equal(1) @@ -54,7 +54,7 @@ describe('Dock', () => { { isVisible: sinon.stub().returns(false) } ] electron.BrowserWindow.getAllWindows.returns(windows) - const { hide } = proxyquire('../src/dock', { electron }).default + const { hide } = proxyquire('../../src/dock', { electron }).default hide() expect(windows[0].isVisible.callCount).to.equal(1) expect(windows[1].isVisible.callCount).to.equal(1) @@ -63,14 +63,14 @@ describe('Dock', () => { it('hide dock succeeds without dock (other OSes)', () => { const electron = mockElectron() - const { hide } = proxyquire('../src/dock', { electron }).default + const { hide } = proxyquire('../../src/dock', { electron }).default hide() }) it('runs async function with dock (macOS)', async () => { const electron = mockElectron({ withDock: true }) electron.BrowserWindow.getAllWindows.returns([]) - const { run } = proxyquire('../src/dock', { electron }).default + const { run } = proxyquire('../../src/dock', { electron }).default const fn = sinon.stub().resolves(5) const res = await run(fn) expect(res).to.equal(5) @@ -82,7 +82,7 @@ describe('Dock', () => { it('runs async function without dock (other OSes)', async () => { const electron = mockElectron() electron.BrowserWindow.getAllWindows.returns([]) - const { run } = proxyquire('../src/dock', { electron }).default + const { run } = proxyquire('../../src/dock', { electron }).default const fn = sinon.stub().resolves(5) const res = await run(fn) expect(res).to.equal(5) @@ -91,7 +91,7 @@ describe('Dock', () => { it('runs sync function with dock (macOS)', () => { const electron = mockElectron({ withDock: true }) electron.BrowserWindow.getAllWindows.returns([]) - const { runSync } = proxyquire('../src/dock', { electron }).default + const { runSync } = proxyquire('../../src/dock', { electron }).default const fn = sinon.stub().returns(5) const res = runSync(fn) expect(res).to.equal(5) @@ -103,7 +103,7 @@ describe('Dock', () => { it('runs sync function without dock (other OSes)', () => { const electron = mockElectron() electron.BrowserWindow.getAllWindows.returns([]) - const { runSync } = proxyquire('../src/dock', { electron }).default + const { runSync } = proxyquire('../../src/dock', { electron }).default const fn = sinon.stub().returns(5) const res = runSync(fn) expect(res).to.equal(5) diff --git a/test/mocks/electron.js b/test/unit/mocks/electron.js similarity index 100% rename from test/mocks/electron.js rename to test/unit/mocks/electron.js diff --git a/test/mocks/store.js b/test/unit/mocks/store.js similarity index 100% rename from test/mocks/store.js rename to test/unit/mocks/store.js diff --git a/test/mocks/webui.js b/test/unit/mocks/webui.js similarity index 100% rename from test/mocks/webui.js rename to test/unit/mocks/webui.js