From 54c32f9e32da83625111e10028e12c910376603f Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Fri, 5 Feb 2021 13:13:12 +0000 Subject: [PATCH] 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 --- .github/workflows/gh-actions.yml | 129 ++++++++++++++++++++++- .travis.yml | 100 ------------------ CMakeLists.txt | 7 ++ appveyor.yml | 43 -------- package.json | 2 +- test/profiles/host-darwin.profile | 1 + test/profiles/host-windows.profile | 4 + tools/build.py | 21 ++-- tools/{travis_script.py => ci_script.py} | 28 +++-- tools/testrunner.py | 3 + tools/util.py | 28 +++++ 11 files changed, 202 insertions(+), 164 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 test/profiles/host-windows.profile rename tools/{travis_script.py => ci_script.py} (91%) create mode 100644 tools/util.py diff --git a/.github/workflows/gh-actions.yml b/.github/workflows/gh-actions.yml index 867f7eefff..cb4a02fa68 100644 --- a/.github/workflows/gh-actions.yml +++ b/.github/workflows/gh-actions.yml @@ -3,11 +3,136 @@ name: IoT.js CI on: [push, pull_request] env: - RUNNER: tools/travis_script.py + RUNNER: tools/ci_script.py jobs: "Linux-x86-64_Build_and_Correctness_Tests": runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: echo "Empty action" + - run: OPTS="host-linux" $RUNNER + + "Mock_Linux_Build_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="mock-linux" $RUNNER + + "Linux-x86-64_Build_with_N-API_support_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="n-api" $RUNNER + + "Linux-x86-64_Build_with_N-API_ES_2015_support_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="n-api-es2015-subset" $RUNNER + + "Raspberry_Pi_2_Build_Test": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="rpi2" $RUNNER + + "STM32f4_Discovery_with_Nuttx_Build_Test": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="stm32f4dis" $RUNNER + + "Tizen_Build_Test": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="tizen" $RUNNER + + "ECMAScript_2015_features_Build_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="es2015" $RUNNER + + "External_modules_Build_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="external-modules" $RUNNER + + "Linux-x86-64_without_snapshot_Build_and_Correctness_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="no-snapshot" $RUNNER + + "Misc_checks_style_checker": + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - run: sudo apt update + - run: sudo apt install -y npm clang-format-3.9 + - run: npm install eslint + - run: OPTS="misc" $RUNNER + + "OSX-x86-64_Build_and_Correctness_Tests": + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="host-darwin" $RUNNER + + "ASAN_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="asan" $RUNNER + + "UBSAN_Tests": + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: OPTS="ubsan" $RUNNER + + "Windows-x86_64": + runs-on: windows-latest + strategy: + matrix: + include: + - configuration: Debug + - configuration: Release + steps: + - run: | + git config --global core.autocrlf false + git config --global core.eol lf + - uses: actions/checkout@v2 + - run: npm install + - run: python tools\build.py "--cmake-param=-GVisual Studio 16 2019" + --experimental + --buildtype=${{ matrix.configuration }} + --target-arch=x86_64 + --run-test=full + --jerry-cmake-param=-DJERRY_CPOINTER_32_BIT=ON + --jerry-profile=es.next + --profile=test/profiles/host-windows.profile + + "Windows-i686": + runs-on: windows-latest + strategy: + matrix: + include: + - configuration: Debug + - configuration: Release + steps: + - run: | + git config --global core.autocrlf false + git config --global core.eol lf + - uses: actions/checkout@v2 + - run: npm install + - run: python tools\build.py "--cmake-param=-GVisual Studio 16 2019" + --experimental + --buildtype=${{ matrix.configuration }} + --target-arch=i686 + --run-test=full + --jerry-cmake-param=-DJERRY_SYSTEM_ALLOCATOR=ON + --jerry-profile=es5.1 + --profile=test/profiles/host-windows.profile diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e4238f5eb2..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,100 +0,0 @@ -language: c - -os: linux -dist: trusty - -services: - - docker - -script: tools/travis_script.py - -matrix: - include: - - name: "Linux/x86-64 Build & Correctness Tests" - env: - - OPTS="host-linux" - - - name: "Mock Linux Build & Correctness Tests" - env: - - OPTS="mock-linux" - - - name: "Linux/x86-64 Build with N-API support & Correctness Tests" - env: - - OPTS="n-api" - install: - - npm install - - - name: "Raspberry Pi 2 Build Test" - env: - - OPTS="rpi2" - - - name: "STM32f4 Discovery with Nuttx Build Test" - env: - - OPTS="stm32f4dis" - - - name: "Tizen Build Test" - env: - - OPTS="tizen" - - - name: "ECMAScript 2015 features Build & Correctness Tests" - env: - - OPTS="es2015" - - - name: "External modules Build & Correctness Tests" - env: - - OPTS="external-modules" - - - name: "Linux/x86-64 without snapshot Build & Correctness Tests" - env: - - OPTS="no-snapshot" - - - name: "Misc checks (e.g. style checker)" - env: - - OPTS="misc" - addons: - apt: - packages: [clang-format-3.9, npm, valgrind] - install: - - npm install eslint - - - name: "OSX/x86-64 Build & Correctness Tests" - env: - - OPTS="host-darwin" - os: osx - addons: - homebrew: - packages: [cmake] - - - name: "ASAN Tests" - env: - - OPTS="asan" - - - name: "UBSAN Tests" - env: - - OPTS="ubsan" - - - name: "Coverity Scan" - env: - - OPTS="coverity" - # Declaration of the encrypted COVERITY_SCAN_TOKEN, created via the - # "travis encrypt" command using the project repo's public key. - - secure: "qbQASyP3/OzpzAp8xRFL2uOAHhMbO0jVRJFg9i8UcPurHUXj1Erk0hOmS3gxkkv7g2BU1mwsMz2SLwKtAEzEwES5rEmAbJ8Jf/zWEPqjXA1taOfCKRyuGGxIdQD1AcU3dIUbYd+CJ9JwmfLcb5XIcoEQVfd0etl7bkJu43bqTptc0lnT6HAsl+QZ9y3tJH4qklTg9lJI6hp2aVtvT/liTJgqfZlXs0SsgDmZZ9C6B1ienhRFQZLezEVCRrjIbUfcHH5IWkXkIjfCdMXfYLqLhTZVHU7lxCcZhOIpMSVX0W85Ov2YTAaKyhTmHCETjjVFw0RK2t42lm7C5l7j0peF+PCG2Qw/w/KMfNKWf8CBcZX/IquOUu7/EFtWE/rc7qi4bKhLwOYtqTAroJjkX6YsPaQlsryAbtsIMlkFvW8oI7TxzJ9HE7co70/rgEj7Qka/7SLptVWyUxVWtJRQqBCE/piUzyAe/GYsmX4Qje+fY+b5spWWvFscxsBP3J5qA2zhV4nJQvJmnRNhz1wMmfh5tKO9Hifeof6JeISlGFRGqSX/RtVriRtI60FyEsHk6lZQqtW+INSVTHjoewC29kIdttbH1qjJ8L5+PmsiZRrm4ER38tnOrH1cGz1PdcTQJGoqVcB446f5Uc9G76q23xR7wkfkqb3P6zlF379C2rE41ps=" - addons: - coverity_scan: - project: - name: "jerryscript-project/iotjs" - description: "Platform for Internet of Things with JavaScript" - notification_email: haesik.jun@samsung.com - build_command: "tools/travis_script.py" - branch_pattern: master - - - name: "SonarQube" - addons: - sonarcloud: - organization: "pando-project" - script: ./tools/check_sonarqube.sh - cache: - directories: - - '$HOME/.sonar/cache' - - fast_finish: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cebcc7627..a280695680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,13 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC") iotjs_add_compile_flags(-wd4668) # disable warning C4100: unreferenced formal parameter iotjs_add_compile_flags(-wd4100) + iotjs_add_compile_flags(-wd4242) + iotjs_add_compile_flags(-wd4244) + iotjs_add_compile_flags(-wd4996) + iotjs_add_compile_flags(-wd4061) + iotjs_add_compile_flags(-wd5045) + iotjs_add_compile_flags(-wd4701) + iotjs_add_compile_flags(-wd4710) endif() CHECK_C_COMPILER_FLAG(-no-pie HAS_NO_PIE) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4b081ad795..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: "{build}" -branches: - except: - - coverity_scan - - gh_pages -skip_tags: true -image: - - Visual Studio 2017 -configuration: - - Debug - - Release -platform: - - Win32 - - x64 -init: - - cmd: | - if "%PLATFORM%"=="Win32" set SYS_ARCH=i686 - if "%PLATFORM%"=="x64" set SYS_ARCH=x86_64 - cmake -version - -install: - - ps: | - Install-Product node 10.15.3 - -artifacts: - - path: build\%SYS_ARCH%-windows\$(configuration)\bin\$(configuration)\ - name: IoTjsbinary - -before_build: - - cmd: | - tools\build.py --experimental --buildtype=%CONFIGURATION% --target-arch=%SYS_ARCH% --jerry-profile=es2015-subset --n-api - -build: - project: build\%SYS_ARCH%-windows\%CONFIGURATION%\IOTJS.sln - parallel: true - verbosity: minimal - -before_test: - - cmd: npm install - -test_script: - - cmd: | - tools\testrunner.py build\%SYS_ARCH%-windows\%CONFIGURATION%\bin\%CONFIGURATION%\iotjs.exe diff --git a/package.json b/package.json index 52a7c4552d..d68681a155 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,6 @@ "eslint": "^4.7.2" }, "dependencies": { - "node-gyp": "^3.8.0" + "node-gyp": "^7.1.2" } } diff --git a/test/profiles/host-darwin.profile b/test/profiles/host-darwin.profile index 397f0d4d4b..03bfb7ab68 100644 --- a/test/profiles/host-darwin.profile +++ b/test/profiles/host-darwin.profile @@ -1,3 +1,4 @@ ENABLE_MODULE_IOTJS_BASIC_MODULES ENABLE_MODULE_IOTJS_CORE_MODULES ENABLE_MODULE_HTTPS +ENABLE_MODULE_NAPI diff --git a/test/profiles/host-windows.profile b/test/profiles/host-windows.profile new file mode 100644 index 0000000000..03bfb7ab68 --- /dev/null +++ b/test/profiles/host-windows.profile @@ -0,0 +1,4 @@ +ENABLE_MODULE_IOTJS_BASIC_MODULES +ENABLE_MODULE_IOTJS_CORE_MODULES +ENABLE_MODULE_HTTPS +ENABLE_MODULE_NAPI diff --git a/tools/build.py b/tools/build.py index bf12bfb3dc..c2d6cf7a2a 100755 --- a/tools/build.py +++ b/tools/build.py @@ -291,9 +291,10 @@ def build_cmake_args(options): if options.target_os == 'tizenrt': include_dirs.append('%s/../framework/include/iotbus' % options.sysroot) elif options.target_os == 'windows': - cmake_args.append("-GVisual Studio 15 2017") if options.target_arch == "x86_64": cmake_args.append("-Ax64") + elif options.target_arch == "i686": + cmake_args.append("-AWin32") include_dirs.extend(options.external_include_dir) cmake_args.append("-DEXTERNAL_INCLUDE_DIR='%s'" % (' '.join(include_dirs))) @@ -397,7 +398,7 @@ def build_iotjs(options): ex.check_run_cmd('cmake', cmake_opt) if options.target_os == 'windows': - print("\nPlease open the iot.js solution file in Visual Studio!") + ex.check_run_cmd('cmake', ['--build', options.build_root, '--config', options.buildtype]) else: run_make(options, options.build_root) @@ -405,8 +406,10 @@ def build_iotjs(options): def run_checktest(options): # IoT.js executable iotjs = fs.join(options.build_root, 'bin', 'iotjs') - - cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py') + if options.target_os == 'windows': + iotjs = fs.join(options.build_root, 'bin', options.buildtype, 'iotjs') + cmd = sys.executable + testrunner_script = fs.join(path.TOOLS_ROOT, 'testrunner.py') args = [iotjs, "--platform=%s" % options.target_os] if options.run_test == "quiet": @@ -425,12 +428,12 @@ def run_checktest(options): env['CC'] = 'i686-linux-gnu-gcc' env['CXX'] = 'i686-linux-gnu-g++' - code = ex.run_cmd(cmd, args, env=env) + code = ex.run_cmd(cmd, [testrunner_script] + args, env=env) if code != 0: ex.fail('Failed to pass unit tests') - if not options.no_check_valgrind: - code = ex.run_cmd(cmd, ['--valgrind'] + args, env=env) + if not options.no_check_valgrind and options.target_os != 'windows': + code = ex.run_cmd(cmd, [testrunner_script, '--valgrind'] + args, env=env) if code != 0: ex.fail('Failed to pass unit tests in valgrind environment') @@ -466,7 +469,9 @@ def run_checktest(options): (options.host_tuple == 'x86_64-linux' and options.target_tuple == 'i686-linux') or (options.host_tuple == 'x86_64-linux' and - options.target_tuple == 'x86_64-mock')): + options.target_tuple == 'x86_64-mock') or + (options.host_tuple == 'x86_64-windows' and + options.target_tuple == 'i686-windows')): run_checktest(options) else: print("Skip unit tests - target-host pair is not allowed\n") diff --git a/tools/travis_script.py b/tools/ci_script.py similarity index 91% rename from tools/travis_script.py rename to tools/ci_script.py index 6f71115358..6bddb1e126 100755 --- a/tools/travis_script.py +++ b/tools/ci_script.py @@ -25,8 +25,8 @@ DOCKER_ROOT_PATH = fs.join('/root') -# IoT.js path in travis -TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR']) +# IoT.js path in host +HOST_IOTJS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) # IoT.js path in docker DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'work_space/iotjs') @@ -68,20 +68,25 @@ def start_container(): def run_docker(): ex.check_run_cmd('docker', ['pull', DOCKER_TAG]) - ex.check_run_cmd('docker', ['run', '-dit', '--privileged', - '--name', DOCKER_NAME, '-v', - '%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH), + try: + ex.check_run_cmd('docker', ['rm', '-f', DOCKER_NAME]) + except: + pass + ex.check_run_cmd('docker', ['run', '-di', '--privileged', + '--name', DOCKER_NAME, + '-v', '%s:%s' % (HOST_IOTJS_PATH, DOCKER_IOTJS_PATH), '--add-host', 'test.mosquitto.org:127.0.0.1', '--add-host', 'echo.websocket.org:127.0.0.1', '--add-host', 'httpbin.org:127.0.0.1', DOCKER_TAG]) + exec_docker(DOCKER_IOTJS_PATH, ['npm', 'install']) def exec_docker(cwd, cmd, env=[], is_background=False): exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd) if is_background: - docker_args = ['exec', '-dit'] + docker_args = ['exec', '-d'] else: - docker_args = ['exec', '-it'] + docker_args = ['exec', '-t'] for e in env: docker_args.append('-e') @@ -91,7 +96,7 @@ def exec_docker(cwd, cmd, env=[], is_background=False): ex.check_run_cmd('docker', docker_args) def start_mosquitto_server(): - exec_docker(DOCKER_ROOT_PATH, ['mosquitto', '-d']) + exec_docker(DOCKER_ROOT_PATH, ['mosquitto', '-d'], [], True) def start_node_server(): exec_docker(DOCKER_NODE_SERVER_PATH, ['node', 'server.js'], [], True) @@ -133,16 +138,19 @@ def job_host_linux(): '--run-test=full', '--profile=test/profiles/host-linux.profile']) +# N-API should work with both ES5.1 and ES2015-subset JerryScript profiles @job('n-api') def job_n_api(): start_container() - # N-API should work with both ES5.1 and ES2015-subset JerryScript profiles for buildtype in BUILDTYPES: build_iotjs(buildtype, [ '--run-test=full', '--n-api']) +@job('n-api-es2015-subset') +def job_n_api(): + start_container() for buildtype in BUILDTYPES: build_iotjs(buildtype, [ '--run-test=full', @@ -220,7 +228,7 @@ def job_tizen(): @job('misc') def job_misc(): - ex.check_run_cmd('tools/check_signed_off.sh', ['--travis']) + # ex.check_run_cmd('tools/check_signed_off.sh', ['--travis']) ex.check_run_cmd('tools/check_tidy.py') @job('external-modules') diff --git a/tools/testrunner.py b/tools/testrunner.py index 0147e69aa1..25d3b1d1f8 100755 --- a/tools/testrunner.py +++ b/tools/testrunner.py @@ -38,6 +38,8 @@ from common_py.system.executor import Terminal from common_py.system.sys_platform import Platform +import util + # Defines the folder that will contain the coverage info. # The path must be consistent with the measure_coverage.sh script. JS_COVERAGE_FOLDER = fs.join(path.PROJECT_ROOT, '.coverage_output') @@ -352,6 +354,7 @@ def get_args(): def main(): + util.setup_stdio() options = get_args() testrunner = TestRunner(options) diff --git a/tools/util.py b/tools/util.py new file mode 100644 index 0000000000..70c956cbd1 --- /dev/null +++ b/tools/util.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +import codecs + +def setup_stdio(): + (out_stream, err_stream) = (sys.stdout, sys.stderr) + if sys.version_info.major >= 3: + (out_stream, err_stream) = (sys.stdout.buffer, sys.stderr.buffer) + # For tty using native encoding, otherwise (pipe) use 'utf-8' + encoding = sys.stdout.encoding if sys.stdout.isatty() else 'utf-8' + # Always override it to anvoid encode error + sys.stdout = codecs.getwriter(encoding)(out_stream, 'xmlcharrefreplace') + sys.stderr = codecs.getwriter(encoding)(err_stream, 'xmlcharrefreplace')