From 0ff8638926cfa1aa6a9c09cc6f9fc6ef2e8f84a5 Mon Sep 17 00:00:00 2001 From: Mike Cousins Date: Wed, 21 Aug 2019 13:34:16 -0400 Subject: [PATCH] fix(app): Fix paths to BR premigration wheels on Windows --- app-shell/electron-builder.json | 7 --- app-shell/package.json | 1 - app-shell/src/buildroot/index.js | 16 +++---- app-shell/src/buildroot/update.js | 43 +++++-------------- .../shell/buildroot/__tests__/reducer.test.js | 24 +++++++++++ app/src/shell/buildroot/reducer.js | 1 + app/src/shell/buildroot/types.js | 2 +- 7 files changed, 42 insertions(+), 52 deletions(-) diff --git a/app-shell/electron-builder.json b/app-shell/electron-builder.json index b0232200f69..2647e1a3afb 100644 --- a/app-shell/electron-builder.json +++ b/app-shell/electron-builder.json @@ -12,13 +12,6 @@ "build/br-premigration-wheels", "!Makefile" ], - "extraResources": [ - { - "from": "../api/dist", - "to": "./api/dist", - "filter": ["**/*"] - } - ], "artifactName": "${productName}-v${version}-${os}-${env.BUILD_ID}.${ext}", "asar": true, "mac": { diff --git a/app-shell/package.json b/app-shell/package.json index a682748a219..6f9c19634c3 100644 --- a/app-shell/package.json +++ b/app-shell/package.json @@ -34,7 +34,6 @@ "form-data": "^2.5.0", "fs-extra": "^6.0.1", "get-stream": "^5.1.0", - "globby": "^10.0.1", "merge-options": "^1.0.1", "node-fetch": "^2.6.0", "node-stream-zip": "^1.8.2", diff --git a/app-shell/src/buildroot/index.js b/app-shell/src/buildroot/index.js index 1b6b79d5451..5043f4085d0 100644 --- a/app-shell/src/buildroot/index.js +++ b/app-shell/src/buildroot/index.js @@ -9,11 +9,7 @@ import { getConfig } from '../config' import { CURRENT_VERSION } from '../update' import { downloadManifest, getReleaseSet } from './release-manifest' import { getReleaseFiles, readUserFileInfo } from './release-files' -import { - getPremigrationWheels, - startPremigration, - uploadSystemFile, -} from './update' +import { startPremigration, uploadSystemFile } from './update' import type { Action, Dispatch } from '../types' import type { ReleaseSetUrls, ReleaseSetFilepaths } from './types' @@ -44,11 +40,9 @@ export function registerBuildrootUpdate(dispatch: Dispatch) { case 'buildroot:START_PREMIGRATION': { const robot = action.payload - getPremigrationWheels() - .then(wheels => { - log.info('Starting robot premigration', { robot, wheels }) - return startPremigration(robot, wheels.api, wheels.updateServer) - }) + log.info('Starting robot premigration', { robot }) + + startPremigration(robot) .then( (): BuildrootAction => ({ type: 'buildroot:PREMIGRATION_DONE', @@ -58,7 +52,7 @@ export function registerBuildrootUpdate(dispatch: Dispatch) { .catch( (error: Error): BuildrootAction => ({ type: 'buildroot:PREMIGRATION_ERROR', - payload: error.message, + payload: { message: error.message }, }) ) .then(dispatch) diff --git a/app-shell/src/buildroot/update.js b/app-shell/src/buildroot/update.js index a120e18e5c0..fee6d62f9dc 100644 --- a/app-shell/src/buildroot/update.js +++ b/app-shell/src/buildroot/update.js @@ -2,9 +2,7 @@ // start a buildroot migration by POSTing the necessary wheel files to a robot // and restarting -import assert from 'assert' import path from 'path' -import globby from 'globby' import { fetch, postFile } from '../http' import type { RobotHost } from '@opentrons/app/src/robot-api' @@ -14,42 +12,23 @@ const PREMIGRATION_WHL_DIR = path.join( '../../build/br-premigration-wheels' ) -const API_WHL_PATTERN = path.join(PREMIGRATION_WHL_DIR, 'opentrons-*.whl') -const SERVER_WHL_PATTERN = path.join(PREMIGRATION_WHL_DIR, 'otupdate-*.whl') +const PREMIGRATION_API_WHL = path.join( + PREMIGRATION_WHL_DIR, + 'opentrons-3.10.3-py2.py3-none-any.whl' +) +const PREMIGRATION_SERVER_WHL = path.join( + PREMIGRATION_WHL_DIR, + 'otupdate-3.10.3-py2.py3-none-any.whl' +) const SYSTEM_FILENAME = 'ot2-system.zip' -const getWheel = (pattern: string): Promise => - globby(pattern).then(matches => { - assert( - matches.length === 1, - `Expected 1 file to match ${pattern}, found [${matches.join(', ')}]` - ) - return matches[0] - }) - -export function getPremigrationWheels(): Promise<{ - api: string, - updateServer: string, -}> { - const getApiWheel = getWheel(API_WHL_PATTERN) - const getServerWheel = getWheel(SERVER_WHL_PATTERN) - - return Promise.all([getApiWheel, getServerWheel]).then( - ([api, updateServer]) => ({ api, updateServer }) - ) -} - -export function startPremigration( - robot: RobotHost, - apiWheelPath: string, - serverWheelPath: string -): Promise { +export function startPremigration(robot: RobotHost): Promise { const apiUrl = `http://${robot.ip}:${robot.port}/server/update` const serverUrl = `http://${robot.ip}:${robot.port}/server/update/bootstrap` const restartUrl = `http://${robot.ip}:${robot.port}/server/restart` - return postFile(apiUrl, 'whl', apiWheelPath) - .then(() => postFile(serverUrl, 'whl', serverWheelPath)) + return postFile(apiUrl, 'whl', PREMIGRATION_API_WHL) + .then(() => postFile(serverUrl, 'whl', PREMIGRATION_SERVER_WHL)) .then(() => fetch(restartUrl, { method: 'POST' })) } diff --git a/app/src/shell/buildroot/__tests__/reducer.test.js b/app/src/shell/buildroot/__tests__/reducer.test.js index 03d23b3a305..ec1d97fd7e5 100644 --- a/app/src/shell/buildroot/__tests__/reducer.test.js +++ b/app/src/shell/buildroot/__tests__/reducer.test.js @@ -252,6 +252,30 @@ describe('app/shell/buildroot reducer', () => { initialState: { ...INITIAL_STATE, session: BASE_SESSION }, expected: { ...INITIAL_STATE, session: null }, }, + { + name: 'handles buildroot:UNEXPECTED_ERROR', + action: { + type: 'buildroot:UNEXPECTED_ERROR', + payload: { message: 'AH!' }, + }, + initialState: { ...INITIAL_STATE, info: null }, + expected: { + ...INITIAL_STATE, + session: { ...INITIAL_STATE.session, error: 'AH!' }, + }, + }, + { + name: 'handles buildroot:PREMIGRATION_ERROR', + action: { + type: 'buildroot:PREMIGRATION_ERROR', + payload: { message: 'AH!' }, + }, + initialState: { ...INITIAL_STATE, info: null }, + expected: { + ...INITIAL_STATE, + session: { ...INITIAL_STATE.session, error: 'AH!' }, + }, + }, ] SPECS.forEach(spec => { diff --git a/app/src/shell/buildroot/reducer.js b/app/src/shell/buildroot/reducer.js index 8ebe644ae13..1da04a23490 100644 --- a/app/src/shell/buildroot/reducer.js +++ b/app/src/shell/buildroot/reducer.js @@ -88,6 +88,7 @@ export function buildrootReducer( case actions.BR_CLEAR_SESSION: return { ...state, session: null } + case actions.BR_PREMIGRATION_ERROR: case actions.BR_UNEXPECTED_ERROR: return { ...state, diff --git a/app/src/shell/buildroot/types.js b/app/src/shell/buildroot/types.js index e707011b1c2..3895518e76e 100644 --- a/app/src/shell/buildroot/types.js +++ b/app/src/shell/buildroot/types.js @@ -85,7 +85,7 @@ export type BuildrootAction = meta: {| shell: true |}, |} | {| type: 'buildroot:PREMIGRATION_DONE', payload: string |} - | {| type: 'buildroot:PREMIGRATION_ERROR', payload: string |} + | {| type: 'buildroot:PREMIGRATION_ERROR', payload: {| message: string |} |} | {| type: 'buildroot:READ_USER_FILE', payload: {| systemFile: string |},