Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 65c4683

Browse files
committed
update travis tests to test against distribution build
Fixes #987
1 parent d08992e commit 65c4683

File tree

8 files changed

+70
-37
lines changed

8 files changed

+70
-37
lines changed

.travis.yml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ addons:
1414
- dbus-x11
1515
- xvfb
1616
- make
17+
- jq # required by dist/build.sh
18+
# - wine # ibid, for windows builds
1719
- g++
1820
- libnss3
1921
- libasound2
@@ -24,36 +26,42 @@ addons:
2426

2527
env:
2628
global:
29+
- DISPLAY=:99
2730
- API_HOST=172.17.0.1
2831
- REDIS_URL=redis://172.17.0.1:6379 # we'll pick up openwhisk's redis
29-
- UV_THREADPOOL_SIZE=128
30-
- NO_NOTIFICATIONS=true
31-
- NO_DEBUGGER_BREAKPOINTS=true
32-
- WINDOW_WIDTH=1400
33-
- WINDOW_HEIGHT=1050
34-
- KEY_FROM_LAYER=true
35-
- DISPLAY=:99
32+
- UV_THREADPOOL_SIZE=128 # might be superfluous; was trying to work around ESOCKETTIMEOUT on linux
33+
- NO_NOTIFICATIONS=true # try not to use Notifications in the browser
34+
- WINDOW_WIDTH=1400 # ! important ! so that clicks don't fail due to elements being off-viewport
35+
- WINDOW_HEIGHT=1050 # ! ibid !
36+
- KEY_FROM_LAYER=true # use one api key per test layer
37+
- TEST_FROM_BUILD="${TRAVIS_BUILD_DIR}/dist/build/IBM Cloud Shell-linux-x64/IBM Cloud Shell" # test against a specific dist build
3638

3739
install:
38-
- echo "API_HOST=foo" > ~/.wskprops # dist/compile.sh needs something here
39-
- echo "AUTH=bar" >> ~/.wskprops # ibid
40+
- echo "APIHOST=foo" > ~/.wskprops # dist/compile.sh needs something here
41+
- echo "AUTH=bar" >> ~/.wskprops # ibid (see the call to initOW in openwhisk-core.js)
4042
- (cd app && npm install && cd ../tests && npm install && npm run _instrument) & # app and tests npm install
4143
- (./tools/travis/setup.sh; ./tools/travis/build.sh; ./tools/travis/init_auth.sh) & # initialize openwhisk and test docker
42-
- wait
43-
- Xvfb $DISPLAY -screen 0 ${WINDOW_WIDTH}x${WINDOW_HEIGHT}x24 -ac &
44-
- sleep 5
45-
- head -50 app/content/js/ui.js
46-
# - rm .dockerignore
47-
# - cp tools/travis/Dockerfile .
48-
# - docker build -t shell-test . # initialize test docker image
44+
- wait # wait for the above &'d background processes
45+
- Xvfb $DISPLAY -screen 0 ${WINDOW_WIDTH}x${WINDOW_HEIGHT}x24 -ac & # start virtual framebuffer process
46+
- sleep 5 # wait a bit for it to come up
47+
- echo "AUTH=bar" >> ~/.wskprops # tools/travis/build.sh overrides this
48+
- (cd dist && ./build.sh linux) # create a dist build to test against
49+
# ^^^ for the dist build, notice that we build for all platforms, even
50+
# though travis only needs linux; this is done purposefully, so as
51+
# to test the dist build mechanism for all platforms
52+
- echo "composer plugin version `cat app/plugins/modules/composer/package.json | jq --raw-output .version`" # log to travis just in case
53+
- cat app/plugins/.pre-scanned | jq .commandToPlugin # ibid
54+
- cat app/plugins/.pre-scanned | jq .overrides # ibid
55+
- echo "install steps completed with success"
4956

57+
# if for some reason we want to avoid the use of travis jobs:
5058
#script: (cd tests && npm run test)
5159
#script: (cd tests && ./bin/runLocal.sh 01 08 07 02 03 04 05)
5260

5361
jobs:
5462
include:
55-
- script: (cd tests && ./bin/runLocal.sh 01 08 02 05)
56-
env: EXECUTING=01:08:02:05
63+
- script: (cd tests && ./bin/runLocal.sh 01 08 02 05) # test a couple of layers here, as they're all small
64+
env: EXECUTING=01:08:02:05 # this env var will help us distinguish jobs in the travis console
5765
- script: (cd tests && ./bin/runLocal.sh 07)
5866
env: EXECUTING=07
5967
- script: (cd tests && ./bin/runLocal.sh 03)

app/content/js/plugins.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ const loadPlugin = (route, pluginPath) => {
213213
// the /wsk/action/invoke command)
214214
for (let k in cmdToPlugin) {
215215
if (commandToPlugin[k]) {
216+
debug('override', k, cmdToPlugin[k], commandToPlugin[k])
216217
overrides[k] = cmdToPlugin[k]
218+
} else {
219+
debug('not override', k, cmdToPlugin[k])
217220
}
218221
commandToPlugin[k] = cmdToPlugin[k]
219222
}

app/content/js/repl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ self.exec = (commandUntrimmed, execOptions) => {
10811081
throw e
10821082
}
10831083

1084-
console.error('catastrophic error in repl', e)
1084+
console.error('catastrophic error in repl')
1085+
console.error(e)
10851086

10861087
const blockForError = block || ui.getCurrentProcessingBlock()
10871088

app/plugins/modules/plugin/lib/compile.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const diff = ({commandToPlugin:before}, {commandToPlugin:after}, reverseDiff = f
109109
*
110110
*/
111111
const uglify = modules => modules.flat.map(module => new Promise((resolve, reject) => {
112-
if (!process.env.UGLIFY) resolve()
112+
if (!process.env.UGLIFY) return resolve()
113113
debug('uglify %s', module.path)
114114

115115
const src = path.join(__dirname, '..', '..', '..', module.path),
@@ -223,12 +223,17 @@ module.exports = (rootDir, externalOnly, cleanup = false, reverseDiff = false) =
223223
if (cleanup) {
224224
// copy the TMP originals back in place
225225
debug('cleanup')
226-
Promise.all(require('../../../../content/js/plugins.js').scanForPlugins(TMP)
227-
.map(pluginJsFile => {
228-
const pluginRoot = path.join(__dirname, '..', '..', '..', '..'),
229-
originalLocation = path.join(pluginRoot, pluginJsFile)
230-
return fs.copy(pluginJsFile, originalLocation)
231-
})).then(()=>resolve()).catch(err=>reject(err))
226+
return fs.exists('../../../../content/js/plugins.js')
227+
.then(exists => {
228+
if (exists) {
229+
return Promise.all(require('../../../../content/js/plugins.js').scanForPlugins(TMP)
230+
.map(pluginJsFile => {
231+
const pluginRoot = path.join(__dirname, '..', '..', '..', '..'),
232+
originalLocation = path.join(pluginRoot, pluginJsFile)
233+
return fs.copy(pluginJsFile, originalLocation)
234+
})).then(()=>resolve()).catch(err=>reject(err))
235+
}
236+
})
232237

233238
} else {
234239
const pluginRoot = path.join(rootDir, 'plugins') // pluginRoot points to the root of the modules subdir

app/plugins/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "",
1111
"license": "ISC",
1212
"dependencies": {
13-
"@shell/composer": "git://github.com/ibm-functions/shell-composer-plugin#0.5.0",
13+
"@shell/composer": "git://github.com/ibm-functions/shell-composer-plugin#0.5.2",
1414
"@shell/local": "git://github.com/ibm-functions/shell-local-plugin",
1515
"@shell/wskflow": "git://github.com/ibm-functions/shell-wskflow-plugin",
1616
"archiver": "^2.1.1",

app/plugins/ui/commands/openwhisk-core.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const initOW = () => {
110110
debug('initOW done')
111111
}
112112
if (apiHost && auth) initOW()
113+
else console.error('skipping initOW', apiHost, auth)
113114

114115
/** is a given entity type CRUDable? i.e. does it have get and update operations, and parameters and annotations properties? */
115116
const isCRUDable = {

dist/build.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ ICON_LINUX=`cat ../app/build/config.json | jq --raw-output .filesystemIcons.linu
1616
VERSION=`git rev-parse master`
1717
BUILDDIR=build
1818

19+
# if we're running a test against a dist build, then we need to tell
20+
# electron-packager to keep around devDependencies
21+
if [ -n "${TEST_FROM_BUILD}" ]; then
22+
NO_PRUNE=--no-prune
23+
NO_INSTALLER=true
24+
else
25+
# by default, we want to uglify the javascript
26+
UGLIFY=true
27+
fi
28+
1929
function init {
2030
# make the build directory
2131
if [ ! -d $BUILDDIR ]; then
@@ -30,7 +40,7 @@ function init {
3040
fi
3141

3242
# assemble plugins
33-
UGLIFY=true ./compile.js
43+
./compile.js
3444

3545
# minify the css
3646
cp ../app/content/css/ui.css /tmp
@@ -47,7 +57,7 @@ function cleanup {
4757

4858
cp /tmp/ui.css ../app/content/css/ui.css
4959

50-
UGLIFY=true ./compile.js cleanup
60+
./compile.js cleanup
5161
}
5262

5363
function win32 {
@@ -127,6 +137,7 @@ function linux {
127137
./node_modules/.bin/electron-packager \
128138
../app \
129139
"${PRODUCT_NAME}" \
140+
${NO_PRUNE} \
130141
--asar=true \
131142
--build-version=$VERSION \
132143
--out=$BUILDDIR \
@@ -146,8 +157,4 @@ function linux {
146157

147158

148159
# line up the work
149-
init
150-
win32
151-
mac
152-
linux
153-
cleanup
160+
init && win32 && mac && linux && cleanup

tests/lib/common.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@ exports.before = (ctx, {fuzz, noApp=false}={}) => {
4343

4444
if (!noApp) {
4545
const opts = {
46-
path: electron,
4746
env,
4847
chromeDriverArgs: [ '--no-sandbox' ],
4948
waitTimeout: process.env.TIMEOUT || 60000,
50-
args: [ appMain ]
5149
}
52-
if (process.env.CHROMEDRIVER_PORT) {
50+
51+
if (process.env.TEST_FROM_BUILD) {
52+
console.log(`Using build-based assets: ${process.env.TEST_FROM_BUILD}`)
53+
opts.path = process.env.TEST_FROM_BUILD
54+
} else {
55+
console.log('Using filesystem-based assets')
56+
opts.path = electron // this means spectron will use electron located in node_modules
57+
opts.args = [ appMain ] // in this mode, we need to specify the main.js to use
58+
}
59+
60+
if (process.env.CHROMEDRIVER_PORT) {
5361
opts.port = process.env.CHROMEDRIVER_PORT
5462
}
5563
if (process.env.WSKNG_NODE_DEBUG) {

0 commit comments

Comments
 (0)