Skip to content

Commit

Permalink
upgrade node to latest version v17.9.0 (DeviceFarmer#500)
Browse files Browse the repository at this point in the history
* upgrade node to latest version v17.9.0

Signed-off-by: Denis Barbaron <[email protected]>

* remove useless comments in karma configuration file

Signed-off-by: Denis Barbaron <[email protected]>
Signed-off-by: di.smirnov <[email protected]>
  • Loading branch information
denis99999 authored and di.smirnov committed May 10, 2022
1 parent 8cc8cd0 commit 72321c9
Show file tree
Hide file tree
Showing 22 changed files with 4,960 additions and 3,282 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.16.1
17.9.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 8.16.1
nodejs 17.9.0
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM ubuntu:16.04
#
# Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#

FROM ubuntu:20.04

# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
Expand All @@ -25,10 +29,10 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
stf && \
sed -i'' 's@http://archive.ubuntu.com/ubuntu/@mirror://mirrors.ubuntu.com/mirrors.txt@' /etc/apt/sources.list && \
apt-get update && \
apt-get -y install wget python build-essential && \
apt-get -y install wget python3 build-essential && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-x64.tar.xz && \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-x64.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
su stf-build -s /bin/bash -c '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js install' && \
Expand All @@ -55,7 +59,7 @@ USER stf-build
RUN set -x && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
npm install --loglevel http && \
npm install --python="/usr/bin/python3" --loglevel http && \
npm pack && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
bower cache clean && \
Expand Down
12 changes: 5 additions & 7 deletions Dockerfile-debian-armhf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2020 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2020,2022 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#

FROM arm32v7/debian:buster-slim
Expand All @@ -23,10 +23,10 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Building node' && \
apt-get -y install wget python build-essential cmake && \
apt-get -y install wget python3 build-essential cmake && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-armv7l.tar.xz && \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-armv7l.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
useradd --system \
Expand All @@ -42,9 +42,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
sed -i'' -e '/phantomjs/d' package.json && \
npm config set unsafe-perm true && \
echo 'npm cache clean --force' | su stf -s /bin/bash && \
echo 'npm install --no-optional --legacy-peer-deps --loglevel http' | su stf -s /bin/bash && \
echo 'npm install --python="/usr/bin/python3" --no-optional --loglevel http' | su stf -s /bin/bash && \
echo '--- Assembling app' && \
echo 'npm pack' | su stf -s /bin/bash && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
Expand All @@ -55,7 +53,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Cleaning up' && \
echo 'npm cache clean --force' | su stf -s /bin/bash && \
rm -rf ~/.node-gyp && \
apt-get -y purge wget python build-essential && \
apt-get -y purge wget python3 build-essential && \
apt-get -y clean && \
apt-get -y autoremove && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile-debian-x86_64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright © 2020 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2020,2022 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#

FROM debian:buster-slim
Expand All @@ -23,10 +23,10 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Building node' && \
apt-get -y install wget python build-essential && \
apt-get -y install wget python3 build-essential && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-x64.tar.xz && \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-x64.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
useradd --system \
Expand All @@ -42,7 +42,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
sed -i'' -e '/phantomjs/d' package.json && \
echo 'npm install --no-optional --loglevel http --legacy-peer-deps' | su stf -s /bin/bash && \
echo 'npm install --python="/usr/bin/python3" --no-optional --loglevel http' | su stf -s /bin/bash && \
echo '--- Assembling app' && \
echo 'npm pack' | su stf -s /bin/bash && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
Expand All @@ -53,7 +53,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Cleaning up' && \
echo 'npm cache clean --force' | su stf -s /bin/bash && \
rm -rf ~/.node-gyp && \
apt-get -y purge wget python build-essential && \
apt-get -y purge wget python3 build-essential && \
apt-get -y clean && \
apt-get -y autoremove && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
Expand Down
42 changes: 23 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

var path = require('path')

var gulp = require('gulp')
Expand All @@ -24,7 +28,7 @@ gulp.task('jsonlint', function() {
'.bowerrc'
, '.yo-rc.json'
, '*.json'
])
], {allowEmpty: true})
.pipe(jsonlint())
.pipe(jsonlint.reporter())
})
Expand Down Expand Up @@ -75,16 +79,12 @@ gulp.task('eslint-cli', function(done) {
}
})


gulp.task('lint', ['jsonlint', 'eslint-cli'])
gulp.task('test', ['lint', 'run:checkversion'])
gulp.task('build', ['clean', 'webpack:build'])

gulp.task('run:checkversion', function() {
gutil.log('Checking STF version...')
return run('./bin/stf -V').exec()
})


gulp.task('karma_ci', function(done) {
karma.start({
configFile: path.join(__dirname, karmaConfig)
Expand Down Expand Up @@ -113,7 +113,7 @@ gulp.task('protractor-explorer', function(callback) {
}, callback)
})

gulp.task('protractor', ['webdriver-update'], function(callback) {
gulp.task('protractor', gulp.series('webdriver-update', function(callback) {
gulp.src(['./res/test/e2e/**/*.js'])
.pipe(protractor.protractor({
configFile: protractorConfig
Expand All @@ -126,7 +126,7 @@ gulp.task('protractor', ['webdriver-update'], function(callback) {
/* eslint no-console: 0 */
})
.on('end', callback)
})
}))

// For piping strings
function fromString(filename, string) {
Expand All @@ -136,7 +136,7 @@ function fromString(filename, string) {
cwd: ''
, base: ''
, path: filename
, contents: new Buffer(string)
, contents: Buffer.from(string)
}))
this.push(null)
}
Expand Down Expand Up @@ -174,6 +174,7 @@ gulp.task('webpack:build', function(callback) {
})
})


gulp.task('webpack:others', function(callback) {
var myConfig = Object.create(webpackStatusConfig)
myConfig.plugins = myConfig.plugins.concat(
Expand All @@ -197,13 +198,6 @@ gulp.task('webpack:others', function(callback) {
})
})

gulp.task('translate', [
'translate:extract'
, 'translate:push'
, 'translate:pull'
, 'translate:compile'
])

gulp.task('pug', function() {
return gulp.src([
'./res/**/*.pug'
Expand All @@ -221,7 +215,7 @@ gulp.task('pug', function() {
.pipe(gulp.dest('./tmp/html/'))
})

gulp.task('translate:extract', ['pug'], function() {
gulp.task('translate:extract', gulp.series('pug', function() {
return gulp.src([
'./tmp/html/**/*.html'
, './res/**/*.js'
Expand All @@ -230,7 +224,7 @@ gulp.task('translate:extract', ['pug'], function() {
])
.pipe(gettext.extract('stf.pot'))
.pipe(gulp.dest('./res/common/lang/po/'))
})
}))

gulp.task('translate:compile', function() {
return gulp.src('./res/common/lang/po/**/*.po')
Expand All @@ -251,9 +245,19 @@ gulp.task('translate:pull', function() {
})

gulp.task('clean', function(cb) {
del([
return del([
'./tmp'
, './res/build'
, '.eslintcache'
], cb)
})

gulp.task('build', gulp.parallel('clean', 'webpack:build'))
gulp.task('lint', gulp.parallel('jsonlint', 'eslint-cli'))
gulp.task('test', gulp.parallel('lint', 'run:checkversion'))
gulp.task('translate', gulp.parallel(
'translate:extract'
, 'translate:push'
, 'translate:pull'
, 'translate:compile'
))
6 changes: 5 additions & 1 deletion lib/cli/doctor/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

module.exports.command = 'doctor'

module.exports.describe = 'Diagnose potential issues with your installation.'
Expand Down Expand Up @@ -148,7 +152,7 @@ module.exports.handler = function() {

function checkZeroMQ() {
return check('ZeroMQ', function(checker) {
var zmq = require('zmq')
var zmq = require('zeromq')
return checker.version(pkg.externalDependencies.zeromq)(zmq.version)
})
}
Expand Down
4 changes: 2 additions & 2 deletions lib/units/api/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019,2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/

var http = require('http')
var path = require('path')
var events = require('events')

var express = require('express')
var swaggerExpress = require('swagger-express-mw')
var swaggerExpress = require('swagger-express-mw-node12')
var swaggerUi = require('swagger-tools/middleware/swagger-ui')
var cookieSession = require('cookie-session')
var Promise = require('bluebird')
Expand Down
2 changes: 1 addition & 1 deletion lib/units/auth/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(options) {

var relyingParty = new openid.RelyingParty(
urljoin(options.appUrl, '/auth/openid/verify')
, null // Realm (optional, specifies realm for OpenID authentication)
, null // Realm (optional, specifies realm for OpenID authentication)
, false // Use stateless verification
, false // Strict mode
, extensions)
Expand Down
9 changes: 9 additions & 0 deletions lib/units/device/plugins/install.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

var stream = require('stream')
var url = require('url')
var util = require('util')
Expand Down Expand Up @@ -70,6 +74,11 @@ module.exports = syrup.serial()
, stats.bytesTransferred / contentLength
))
)
// temporary workaround as the 'end' event is never fired
if ((stats.bytesTransferred / contentLength) === 1 &&
process.versions.node.split('.')[0] >= 16) {
endListener()
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions lib/units/device/plugins/vnc/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

var net = require('net')
var util = require('util')
var os = require('os')
Expand Down Expand Up @@ -59,13 +63,13 @@ module.exports = syrup.serial()
}

function joinListener(newGroup, identifier) {
if (!data.response.equals(new Buffer(identifier || '', 'hex'))) {
if (!data.response.equals(Buffer.from(identifier || '', 'hex'))) {
resolver.reject(new Error('Someone else took the device'))
}
}

function autojoinListener(identifier, joined) {
if (data.response.equals(new Buffer(identifier, 'hex'))) {
if (data.response.equals(Buffer.from(identifier, 'hex'))) {
if (joined) {
resolver.resolve()
}
Expand Down Expand Up @@ -99,7 +103,7 @@ module.exports = syrup.serial()
, height: options.vncInitialSize[1]
, security: [{
type: VncConnection.SECURITY_VNC
, challenge: new Buffer(16).fill(0)
, challenge: Buffer.alloc(16).fill(0)
, auth: vncAuthHandler
}]
}
Expand Down
6 changes: 5 additions & 1 deletion lib/util/streamutil.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

var util = require('util')

var Promise = require('bluebird')
Expand All @@ -15,7 +19,7 @@ module.exports.NoSuchLineError = NoSuchLineError

module.exports.readAll = function(stream) {
var resolver = Promise.defer()
var collected = new Buffer(0)
var collected = Buffer.alloc(0)

function errorListener(err) {
resolver.reject(err)
Expand Down
6 changes: 5 additions & 1 deletion lib/util/zmqutil.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

// ISSUE-100 (https://github.com/openstf/stf/issues/100)

// In some networks TCP Connection dies if kept idle for long.
// Setting TCP_KEEPALIVE option true, to all the zmq sockets
// won't let it die

var zmq = require('zmq')
var zmq = require('zeromq')

var log = require('./logger').createLogger('util:zmqutil')

Expand Down
9 changes: 7 additions & 2 deletions lib/wire/messagestream.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//

var util = require('util')
var stream = require('stream')

Expand All @@ -6,7 +10,7 @@ function DelimitedStream() {
this._length = 0
this._lengthIndex = 0
this._readingLength = true
this._buffer = new Buffer(0)
this._buffer = Buffer.alloc(0)
}

util.inherits(DelimitedStream, stream.Transform)
Expand Down Expand Up @@ -64,7 +68,8 @@ DelimitingStream.prototype._transform = function(chunk, encoding, done) {

lengthBytes.push(length)

this.push(new Buffer(lengthBytes))
// this.push(new Buffer(lengthBytes))
this.push(Buffer.from(lengthBytes))
this.push(chunk)

done()
Expand Down
Loading

0 comments on commit 72321c9

Please sign in to comment.