From d039e3328793bbd089c4ee18931cd71259b40578 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sun, 31 Jan 2021 01:53:53 +0800 Subject: [PATCH] Add github actions. Disable check sign off first. IoT.js-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com --- .github/workflows/gh-actions.yml | 109 ++++++++++++++++++++++++++++++- .travis.yml | 100 ---------------------------- appveyor.yml | 43 ------------ package.json | 2 +- tools/build.py | 5 +- tools/check_tidy.py | 2 +- tools/testrunner.py | 3 + tools/travis_script.py | 22 +++++-- tools/util.py | 28 ++++++++ 9 files changed, 159 insertions(+), 155 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 tools/util.py diff --git a/.github/workflows/gh-actions.yml b/.github/workflows/gh-actions.yml index 867f7eefff..a922732c68 100644 --- a/.github/workflows/gh-actions.yml +++ b/.github/workflows/gh-actions.yml @@ -10,4 +10,111 @@ jobs: 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 valgrind 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 + + "Win": + runs-on: windows-latest + strategy: + matrix: + include: + - configuration: Debug + sys_arch: x86_64 + - configuration: Release + sys_arch: x86_64 + - configuration: Debug + sys_arch: i686 + - configuration: Release + sys_arch: i686 + env: + CONFIGURATION: ${{ matrix.configuration }} + SYS_ARCH: ${{ matrix.sys_arch }} + JERRY_PROFILE: es.next + 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=${{ matrix.sys_arch }} --jerry-profile=$env:JERRY_PROFILE --n-api + - run: python tools\testrunner.py build\$env:SYS_ARCH-windows\$env:CONFIGURATION\bin\$env:CONFIGURATION\iotjs.exe 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/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/tools/build.py b/tools/build.py index ff1d6166d3..e068204263 100755 --- a/tools/build.py +++ b/tools/build.py @@ -292,9 +292,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))) @@ -398,7 +399,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) diff --git a/tools/check_tidy.py b/tools/check_tidy.py index 79fb5b52d1..4c0bed3383 100755 --- a/tools/check_tidy.py +++ b/tools/check_tidy.py @@ -44,7 +44,7 @@ def parse_option(): class StyleChecker(object): - column_limit = 80 + column_limit = 100 def __init__(self): self.count_lines = 0 diff --git a/tools/testrunner.py b/tools/testrunner.py index 6e9750c1ae..143dd7b829 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') @@ -345,6 +347,7 @@ def get_args(): def main(): + util.setup_stdio() options = get_args() testrunner = TestRunner(options) diff --git a/tools/travis_script.py b/tools/travis_script.py index 6f71115358..3f8fe3e63e 100755 --- a/tools/travis_script.py +++ b/tools/travis_script.py @@ -26,7 +26,7 @@ DOCKER_ROOT_PATH = fs.join('/root') # IoT.js path in travis -TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR']) +TRAVIS_BUILD_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', + 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' % (TRAVIS_BUILD_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/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')