Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dc23a76

Browse files
committedFeb 7, 2021
Add github actions.
Disable check sign off first. Rename to ci_script.py IoT.js-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
1 parent eb3497a commit dc23a76

File tree

11 files changed

+201
-164
lines changed

11 files changed

+201
-164
lines changed
 

‎.github/workflows/gh-actions.yml

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,135 @@ name: IoT.js CI
33
on: [push, pull_request]
44

55
env:
6-
RUNNER: tools/travis_script.py
6+
RUNNER: tools/ci_script.py
77

88
jobs:
99
"Linux-x86-64_Build_and_Correctness_Tests":
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- run: echo "Empty action"
13+
- run: OPTS="host-linux" $RUNNER
14+
15+
"Mock_Linux_Build_and_Correctness_Tests":
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- run: OPTS="mock-linux" $RUNNER
20+
21+
"Linux-x86-64_Build_with_N-API_support_and_Correctness_Tests":
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v2
25+
- run: OPTS="n-api" $RUNNER
26+
27+
"Linux-x86-64_Build_with_N-API_ES_2015_support_and_Correctness_Tests":
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- run: OPTS="n-api-es2015-subset" $RUNNER
32+
33+
"Raspberry_Pi_2_Build_Test":
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v2
37+
- run: OPTS="rpi2" $RUNNER
38+
39+
"STM32f4_Discovery_with_Nuttx_Build_Test":
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v2
43+
- run: OPTS="stm32f4dis" $RUNNER
44+
45+
"Tizen_Build_Test":
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
- run: OPTS="tizen" $RUNNER
50+
51+
"ECMAScript_2015_features_Build_and_Correctness_Tests":
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v2
55+
- run: OPTS="es2015" $RUNNER
56+
57+
"External_modules_Build_and_Correctness_Tests":
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v2
61+
- run: OPTS="external-modules" $RUNNER
62+
63+
"Linux-x86-64_without_snapshot_Build_and_Correctness_Tests":
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v2
67+
- run: OPTS="no-snapshot" $RUNNER
68+
69+
"Misc_checks_style_checker":
70+
runs-on: ubuntu-18.04
71+
steps:
72+
- uses: actions/checkout@v2
73+
- run: sudo apt update
74+
- run: sudo apt install -y npm clang-format-3.9
75+
- run: npm install eslint
76+
- run: OPTS="misc" $RUNNER
77+
78+
"OSX-x86-64_Build_and_Correctness_Tests":
79+
runs-on: macos-latest
80+
steps:
81+
- uses: actions/checkout@v2
82+
- run: OPTS="host-darwin" $RUNNER
83+
84+
"ASAN_Tests":
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v2
88+
- run: OPTS="asan" $RUNNER
89+
90+
"UBSAN_Tests":
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v2
94+
- run: OPTS="ubsan" $RUNNER
95+
96+
"Windows-x86_64":
97+
runs-on: windows-latest
98+
strategy:
99+
matrix:
100+
include:
101+
- configuration: Debug
102+
- configuration: Release
103+
steps:
104+
- run: |
105+
git config --global core.autocrlf false
106+
git config --global core.eol lf
107+
- uses: actions/checkout@v2
108+
- run: npm install
109+
- run: python tools\build.py "--cmake-param=-GVisual Studio 16 2019"
110+
--experimental
111+
--buildtype=${{ matrix.configuration }}
112+
--target-arch=x86_64
113+
--run-test=full
114+
--jerry-profile=es.next
115+
--profile=test/profiles/host-windows.profile
116+
117+
"Windows-i686":
118+
runs-on: windows-latest
119+
strategy:
120+
matrix:
121+
include:
122+
- configuration: Debug
123+
- configuration: Release
124+
steps:
125+
- run: |
126+
git config --global core.autocrlf false
127+
git config --global core.eol lf
128+
- uses: actions/checkout@v2
129+
- run: npm install
130+
- run: python tools\build.py "--cmake-param=-GVisual Studio 16 2019"
131+
--experimental
132+
--buildtype=${{ matrix.configuration }}
133+
--target-arch=i686
134+
--run-test=full
135+
--jerry-cmake-param=-DJERRY_SYSTEM_ALLOCATOR=ON
136+
--jerry-profile=es5.1
137+
--profile=test/profiles/host-windows.profile

‎.travis.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

‎CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
9494
iotjs_add_compile_flags(-wd4668)
9595
# disable warning C4100: unreferenced formal parameter
9696
iotjs_add_compile_flags(-wd4100)
97+
iotjs_add_compile_flags(-wd4242)
98+
iotjs_add_compile_flags(-wd4244)
99+
iotjs_add_compile_flags(-wd4996)
100+
iotjs_add_compile_flags(-wd4061)
101+
iotjs_add_compile_flags(-wd5045)
102+
iotjs_add_compile_flags(-wd4701)
103+
iotjs_add_compile_flags(-wd4710)
97104
endif()
98105

99106
CHECK_C_COMPILER_FLAG(-no-pie HAS_NO_PIE)

‎appveyor.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"eslint": "^4.7.2"
1212
},
1313
"dependencies": {
14-
"node-gyp": "^3.8.0"
14+
"node-gyp": "^7.1.2"
1515
}
1616
}

‎test/profiles/host-darwin.profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ENABLE_MODULE_IOTJS_BASIC_MODULES
22
ENABLE_MODULE_IOTJS_CORE_MODULES
33
ENABLE_MODULE_HTTPS
4+
ENABLE_MODULE_NAPI

‎test/profiles/host-windows.profile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ENABLE_MODULE_IOTJS_BASIC_MODULES
2+
ENABLE_MODULE_IOTJS_CORE_MODULES
3+
ENABLE_MODULE_HTTPS
4+
ENABLE_MODULE_NAPI

‎tools/build.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,10 @@ def build_cmake_args(options):
291291
if options.target_os == 'tizenrt':
292292
include_dirs.append('%s/../framework/include/iotbus' % options.sysroot)
293293
elif options.target_os == 'windows':
294-
cmake_args.append("-GVisual Studio 15 2017")
295294
if options.target_arch == "x86_64":
296295
cmake_args.append("-Ax64")
296+
elif options.target_arch == "i686":
297+
cmake_args.append("-AWin32")
297298

298299
include_dirs.extend(options.external_include_dir)
299300
cmake_args.append("-DEXTERNAL_INCLUDE_DIR='%s'" % (' '.join(include_dirs)))
@@ -397,16 +398,18 @@ def build_iotjs(options):
397398
ex.check_run_cmd('cmake', cmake_opt)
398399

399400
if options.target_os == 'windows':
400-
print("\nPlease open the iot.js solution file in Visual Studio!")
401+
ex.check_run_cmd('cmake', ['--build', options.build_root, '--config', options.buildtype])
401402
else:
402403
run_make(options, options.build_root)
403404

404405

405406
def run_checktest(options):
406407
# IoT.js executable
407408
iotjs = fs.join(options.build_root, 'bin', 'iotjs')
408-
409-
cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py')
409+
if options.target_os == 'windows':
410+
iotjs = fs.join(options.build_root, 'bin', options.buildtype, 'iotjs')
411+
cmd = sys.executable
412+
testrunner_script = fs.join(path.TOOLS_ROOT, 'testrunner.py')
410413
args = [iotjs, "--platform=%s" % options.target_os]
411414

412415
if options.run_test == "quiet":
@@ -425,12 +428,12 @@ def run_checktest(options):
425428
env['CC'] = 'i686-linux-gnu-gcc'
426429
env['CXX'] = 'i686-linux-gnu-g++'
427430

428-
code = ex.run_cmd(cmd, args, env=env)
431+
code = ex.run_cmd(cmd, [testrunner_script] + args, env=env)
429432
if code != 0:
430433
ex.fail('Failed to pass unit tests')
431434

432-
if not options.no_check_valgrind:
433-
code = ex.run_cmd(cmd, ['--valgrind'] + args, env=env)
435+
if not options.no_check_valgrind and options.target_os != 'windows':
436+
code = ex.run_cmd(cmd, [testrunner_script, '--valgrind'] + args, env=env)
434437
if code != 0:
435438
ex.fail('Failed to pass unit tests in valgrind environment')
436439

@@ -466,7 +469,9 @@ def run_checktest(options):
466469
(options.host_tuple == 'x86_64-linux' and
467470
options.target_tuple == 'i686-linux') or
468471
(options.host_tuple == 'x86_64-linux' and
469-
options.target_tuple == 'x86_64-mock')):
472+
options.target_tuple == 'x86_64-mock') or
473+
(options.host_tuple == 'x86_64-windows' and
474+
options.target_tuple == 'i686-windows')):
470475
run_checktest(options)
471476
else:
472477
print("Skip unit tests - target-host pair is not allowed\n")

‎tools/travis_script.py renamed to ‎tools/ci_script.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
DOCKER_ROOT_PATH = fs.join('/root')
2727

28-
# IoT.js path in travis
29-
TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR'])
28+
# IoT.js path in host
29+
HOST_IOTJS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
3030

3131
# IoT.js path in docker
3232
DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'work_space/iotjs')
@@ -68,20 +68,25 @@ def start_container():
6868

6969
def run_docker():
7070
ex.check_run_cmd('docker', ['pull', DOCKER_TAG])
71-
ex.check_run_cmd('docker', ['run', '-dit', '--privileged',
72-
'--name', DOCKER_NAME, '-v',
73-
'%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH),
71+
try:
72+
ex.check_run_cmd('docker', ['rm', '-f', DOCKER_NAME])
73+
except:
74+
pass
75+
ex.check_run_cmd('docker', ['run', '-di', '--privileged',
76+
'--name', DOCKER_NAME,
77+
'-v', '%s:%s' % (HOST_IOTJS_PATH, DOCKER_IOTJS_PATH),
7478
'--add-host', 'test.mosquitto.org:127.0.0.1',
7579
'--add-host', 'echo.websocket.org:127.0.0.1',
7680
'--add-host', 'httpbin.org:127.0.0.1',
7781
DOCKER_TAG])
82+
exec_docker(DOCKER_IOTJS_PATH, ['npm', 'install'])
7883

7984
def exec_docker(cwd, cmd, env=[], is_background=False):
8085
exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd)
8186
if is_background:
82-
docker_args = ['exec', '-dit']
87+
docker_args = ['exec', '-d']
8388
else:
84-
docker_args = ['exec', '-it']
89+
docker_args = ['exec', '-t']
8590

8691
for e in env:
8792
docker_args.append('-e')
@@ -91,7 +96,7 @@ def exec_docker(cwd, cmd, env=[], is_background=False):
9196
ex.check_run_cmd('docker', docker_args)
9297

9398
def start_mosquitto_server():
94-
exec_docker(DOCKER_ROOT_PATH, ['mosquitto', '-d'])
99+
exec_docker(DOCKER_ROOT_PATH, ['mosquitto', '-d'], [], True)
95100

96101
def start_node_server():
97102
exec_docker(DOCKER_NODE_SERVER_PATH, ['node', 'server.js'], [], True)
@@ -133,16 +138,19 @@ def job_host_linux():
133138
'--run-test=full',
134139
'--profile=test/profiles/host-linux.profile'])
135140

141+
# N-API should work with both ES5.1 and ES2015-subset JerryScript profiles
136142
@job('n-api')
137143
def job_n_api():
138144
start_container()
139145

140-
# N-API should work with both ES5.1 and ES2015-subset JerryScript profiles
141146
for buildtype in BUILDTYPES:
142147
build_iotjs(buildtype, [
143148
'--run-test=full',
144149
'--n-api'])
145150

151+
@job('n-api-es2015-subset')
152+
def job_n_api():
153+
start_container()
146154
for buildtype in BUILDTYPES:
147155
build_iotjs(buildtype, [
148156
'--run-test=full',
@@ -220,7 +228,7 @@ def job_tizen():
220228

221229
@job('misc')
222230
def job_misc():
223-
ex.check_run_cmd('tools/check_signed_off.sh', ['--travis'])
231+
# ex.check_run_cmd('tools/check_signed_off.sh', ['--travis'])
224232
ex.check_run_cmd('tools/check_tidy.py')
225233

226234
@job('external-modules')

‎tools/testrunner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
from common_py.system.executor import Terminal
3939
from common_py.system.sys_platform import Platform
4040

41+
import util
42+
4143
# Defines the folder that will contain the coverage info.
4244
# The path must be consistent with the measure_coverage.sh script.
4345
JS_COVERAGE_FOLDER = fs.join(path.PROJECT_ROOT, '.coverage_output')
@@ -352,6 +354,7 @@ def get_args():
352354

353355

354356
def main():
357+
util.setup_stdio()
355358
options = get_args()
356359

357360
testrunner = TestRunner(options)

‎tools/util.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import sys
18+
import codecs
19+
20+
def setup_stdio():
21+
(out_stream, err_stream) = (sys.stdout, sys.stderr)
22+
if sys.version_info.major >= 3:
23+
(out_stream, err_stream) = (sys.stdout.buffer, sys.stderr.buffer)
24+
# For tty using native encoding, otherwise (pipe) use 'utf-8'
25+
encoding = sys.stdout.encoding if sys.stdout.isatty() else 'utf-8'
26+
# Always override it to anvoid encode error
27+
sys.stdout = codecs.getwriter(encoding)(out_stream, 'xmlcharrefreplace')
28+
sys.stderr = codecs.getwriter(encoding)(err_stream, 'xmlcharrefreplace')

0 commit comments

Comments
 (0)
Please sign in to comment.