diff options
-rw-r--r-- | .appveyor.yml | 62 | ||||
-rw-r--r-- | .github/workflows/build_release.yml | 75 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 238 | ||||
-rw-r--r-- | .travis.yml | 184 | ||||
-rwxr-xr-x | check.py | 2 | ||||
-rwxr-xr-x | scripts/clang-tidy-diff.sh | 2 | ||||
-rwxr-xr-x | scripts/emcc-tests.sh (renamed from scripts/travis-emcc-tests.sh) | 12 |
7 files changed, 321 insertions, 254 deletions
diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 8664baafb..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- - -skip_branch_with_pr: true -image: Visual Studio 2017 - -init: - - set PATH=C:\Python27\Scripts;%PATH% # while python's bin is already in PATH, but pip.exe in Scripts\ dir isn't - - set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH% - -environment: - DEGREE_OF_PARALLELISM: 3 - matrix: - - GENERATOR: MSYS Makefiles - CONFIG: Release - PARALLEL_FLAG: -j - - GENERATOR: Visual Studio 15 2017 - CONFIG: Release - PARALLEL_FLAG: "/m:" - DEPLOY: 1 - ARCH: x86 - - GENERATOR: Visual Studio 15 2017 Win64 - CONFIG: Debug - PARALLEL_FLAG: "/m:" - - GENERATOR: Visual Studio 15 2017 Win64 - CONFIG: Release - PARALLEL_FLAG: "/m:" - DEPLOY: 1 - ARCH: x86_64 - -install: - - pip install flake8==3.4.1 - -before_build: - # Check the style of a subset of Python code until the other code is updated. - - flake8 ./scripts/ - -build_script: - # Request `libcmt.lib` is used so our released artifacts don't dynamically - # link to `msvcrt.dll` - - cmake . -DCMAKE_BUILD_TYPE=%CONFIG% -G "%GENERATOR%" -DMSVC_USE_LIBCMT=YES - - cmake --build . --config %CONFIG% -- %PARALLEL_FLAG%%DEGREE_OF_PARALLELISM% - -test_script: - - ctest --output-on-failure --timeout 10 -j 5 -C Release - -before_deploy: - - ps: | - $NAME = "binaryen-${env:APPVEYOR_REPO_TAG_NAME}-${env:ARCH}-windows" - Move-Item -Path bin -Destination $NAME - 7z a -ttar "${NAME}.tar" "${NAME}" - 7z a "${NAME}.tar.gz" "${NAME}.tar" - Push-AppveyorArtifact "${NAME}.tar.gz" - -deploy: - artifact: /.*\.tar.gz/ - auth_token: - secure: zM0Bcjy1JXOBuu2C32lY0vCxREu7ah+bYFUpwmuryw82+HgCjvq7ZMutAk34Lv9d - description: '' - on: - appveyor_repo_tag: true - DEPLOY: 1 - provider: GitHub diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 000000000..cd71a90e4 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,75 @@ +name: Build Release + +# Trigger whenever a release is created +on: + release: + types: + - created + +jobs: + build: + name: build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + + - name: install ninja (linux) + run: sudo apt-get install ninja-build + if: matrix.os == 'ubuntu-latest' + + - name: install ninja (osx) + run: brew install ninja + if: matrix.os == 'macos-latest' + + - name: install ninja (win) + run: choco install ninja + if: matrix.os == 'windows-latest' + + - name: mkdir + run: mkdir -p out + + - name: cmake (linux) + run: cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + if: matrix.os == 'ubuntu-latest' + + - name: cmake (osx) + run: cmake -S . -B out -G Ninja + if: matrix.os == 'macos-latest' + + - name: cmake (win) + # -G "Visual Studio 15 2017" + run: cmake -S . -B out + if: matrix.os == 'windows-latest' + + - name: build + run: cmake --build out + + - name: archive + id: archive + run: | + export VERSION=${{ github.event.release.tag_name }} + export PKGNAME="binaryen-$VERSION-x86_64-${{ matrix.os }}" + export TARBALL=$PKGNAME.tar.gz + mv out/bin binaryen-$VERSION + tar -czf $TARBALL binaryen-$VERSION + shasum -a 256 $TARBALL > $PKGNAME.tar.gz.sha256 + echo "::set-output name=asset_name::$TARBALL" + + - name: upload release asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./${{ steps.archive.outputs.asset_name }} + asset_name: ${{ steps.archive.outputs.asset_name }} + asset_content_type: application/gzip diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..706ada62e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,238 @@ +name: CI + +# Trigger on pull_request or on push to master +on: + push: + branches: + - master + pull_request: + +jobs: + + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install tools + run: | + sudo pip3 install flake8==3.7.8 + sudo apt-get install clang-format clang-tidy + echo "::add-path::/usr/lib/llvm-8/bin" + - name: flake8 + run: flake8 + - run: ./scripts/clang-format-diff.sh + - run: ./scripts/clang-tidy-diff.sh + + build: + name: build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + + - name: install ninja (linux) + run: sudo apt-get install ninja-build + if: matrix.os == 'ubuntu-latest' + + - name: install ninja (osx) + run: brew install ninja + if: matrix.os == 'macos-latest' + + - name: install ninja (win) + run: choco install ninja + if: matrix.os == 'windows-latest' + + - name: mkdir + run: mkdir -p out + + - name: cmake (linux) + run: cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + if: matrix.os == 'ubuntu-latest' + + - name: cmake (osx) + run: cmake -S . -B out -G Ninja + if: matrix.os == 'macos-latest' + + - name: cmake (win) + # -G "Visual Studio 15 2017" + run: cmake -S . -B out + if: matrix.os == 'windows-latest' + + - name: build + run: cmake --build out + + - name: test + run: python check.py --binaryen-bin=out/bin + # Currently disabled on windows due to a single test failure. + # https://github.com/WebAssembly/binaryen/issues/2781 + if: matrix.os != 'windows-latest' + + # Build with gcc 6.3 and run tests on Alpine Linux (inside chroot). + # Note: Alpine uses musl libc. + build-alpine: + name: alpine + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: start docker + run: | + docker run -w /src -dit --name alpine -v $PWD:/src node:lts-alpine + echo 'docker exec alpine "$@";' > ./alpine.sh + chmod +x ./alpine.sh + - name: install packages + run: | + ./alpine.sh apk update + ./alpine.sh apk add build-base cmake git python3 clang ninja + - name: build + run: | + ./alpine.sh cmake . -G Ninja + ./alpine.sh ninja + - name: test + run: ./alpine.sh python3 ./check.py + + build-gcc: + name: gcc + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install ninja + run: sudo apt-get install ninja-build + - name: cmake + run: | + mkdir -p out + cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 + - name: build + run: cmake --build out + - name: test + run: python check.py --binaryen-bin=out/bin + + # TODO(sbc): Find a way to reduce the duplicate between these sanitizer jobs + build-asan: + name: asan + runs-on: ubuntu-latest + env: + # FIXME we currently must disable LSAN entirely, see #1351 + ASAN_OPTIONS: "detect_leaks=0 symbolize=1" + COMPILER_FLAGS: "-fsanitize=address" + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install ninja + run: sudo apt-get install ninja-build + - name: cmake + run: | + mkdir -p out + cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" + - name: build + run: cmake --build out + - name: test + run: python check.py --binaryen-bin=out/bin + + # Duplicates build-asan. Please keep in sync + build-ubsan: + name: ubsan + runs-on: ubuntu-latest + env: + COMPILER_FLAGS: "-fsanitize=undefined -fno-sanitize-recover=all" + CC: "clang" + CXX: "clang++" + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install ninja + run: sudo apt-get install ninja-build + - name: cmake + run: | + mkdir -p out + cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS -fsanitize-blacklist=$PWD/ubsan.blacklist" + - name: build + run: cmake --build out + - name: test + run: python check.py --binaryen-bin=out/bin + + # Duplicates build-asan. Please keep in sync + build-tsan: + name: tsan + runs-on: ubuntu-latest + env: + COMPILER_FLAGS: "-fsanitize=thread" + LINKER_FLAGS: "-fsanitize=thread" + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install ninja + run: sudo apt-get install ninja-build + - name: cmake + run: | + mkdir -p out + cmake -S . -B out -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" + - name: build + run: cmake --build out + - name: test + run: python check.py --binaryen-bin=out/bin + + # Build the .js outputs using emcc + build-emscripten: + name: emscipten + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v1 + with: + python-version: '3.x' + - uses: actions/checkout@v1 + with: + submodules: true + - name: install ninja + run: sudo apt-get install ninja-build + - name: download cmake + run: | + mkdir $HOME/cmake + wget -qO- https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz | tar -xzC $HOME/cmake --strip-components 1 + echo "::add-path::$HOME/cmake/bin" + - name: emsdk install + run: | + mkdir $HOME/emsdk + git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk + $HOME/emsdk/emsdk update-tags + $HOME/emsdk/emsdk install tot + $HOME/emsdk/emsdk activate tot + echo "::add-path::$HOME/emsdk" + - name: emcc-tests + run: | + source $HOME/emsdk/emsdk_env.sh + ./scripts/emcc-tests.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7b6f8969f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,184 +0,0 @@ -sudo: false -dist: bionic -language: cpp -python: - - 3.6 - -stages: - - name: test - - name: archive - # Don't run archive stage for pull requests and other branches than master - # to save time and resources. - if: type != pull_request AND (branch = master OR tag IS present) - -DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB - before_deploy: - - PKGNAME="binaryen-$TRAVIS_TAG-$ARCH" - - mv bin binaryen-$TRAVIS_TAG - - tar -czf $PKGNAME.tar.gz binaryen-$TRAVIS_TAG - - shasum -a 256 $PKGNAME.tar.gz > $PKGNAME.tar.gz.sha256 - deploy: - provider: releases - api_key: - secure: "cu6CD5BaycXdCylvcs+Fho5+OVTkh9mZwH8RTnNpXo9hAQzLJDFgcNBHeXHEHtcp4IWf/YZSMu48UKnpU9sP5iF0AS4rtuEBJk5gOKkgB8GWnuIOePFkfANAZMN+EncuUwhAdN56iOAESXqnlHYgmJjyRVCHOxiezuWTOYui4lxoIAdxvOMJc3E9yfzUq4Epm2GDszSDN7ObmRIJpVgDXD9Sze1Xv4IkbIwc0biCmduGGLp3ow2KM+RZ4tOF0c8P0ki49vOFHr6n2Vmqg0QCiVNd4JJBRBCGn6Tzip2jsTQewnUUvpYCZafLeRV//v//voNA6ZUz91yXR23GIhkfdlyuqnz3/7l335Sa749M1lpYfSRWvwg9mJEqP66mxqTrWzj1xSItr9T+p0WhSmRN/4UEJPuItYPSma6kfv+H7qhLa3ZYKECH8hHW79grYmUWtiX0vQVIgnctJGgboPNLfG/1mNtmCI241wK0S3zvL2okdZH8/PqxfllYHMBTUp9lUrop8eoLKPgHZPm6+V20dgTUgOuGTZzTWwQ7Uk/Pg8JMUgkre5y0eo6pP3z0vDW1NNFNhouJ5oGkAeK/HAznr8Q0zWWF1vGFhoyC8ok/IJ7yKxK9scJVPBDe4oox6tr1zlsxzNEYE0/mY3JjuWV0z8RgjrIAbRe8IpGTkYz5VOM=" - file: binaryen-$TRAVIS_TAG-*.tar.gz* - file_glob: true - skip_cleanup: true - on: - tags: true - -jobs: - include: - - name: lint-checks - stage: test - addons: - apt: - packages: ['cmake', 'python3-pip'] - install: pip3 install --user flake8==3.7.8 - script: - - flake8 - - ./scripts/clang-format-diff.sh - # ensure generated parser is up to date - - ./scripts/gen-s-parser.py | diff src/gen-s-parser.inc - - # clang-tidy requires compile_commands.json generated by cmake - - cmake ${TRAVIS_BUILD_DIR} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - - ./scripts/clang-tidy-diff.sh - - # Build with clang and run tests on the host system (Ubuntu). - - &test-ubuntu - name: clang - stage: test - compiler: clang - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['cmake', 'g++-5', 'ninja-build'] - before_install: - - export ASAN_OPTIONS="$ASAN_OPTIONS symbolize=1" - install: - - nvm install 12 - - nvm use 12 - # get jsvu in order to get more js engines - - npm install jsvu -g - - export PATH="${HOME}/.jsvu:${PATH}" - - jsvu --os=linux64 --engines=spidermonkey,v8 - script: - - set -o errexit - - BUILD_DIR=${BUILD_DIR:-.} - - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} - - cmake ${TRAVIS_BUILD_DIR} -G Ninja - -DCMAKE_C_FLAGS="$COMPILER_FLAGS" - -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" - -DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" - -DCMAKE_INSTALL_PREFIX=install - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - - ninja install - # Run tests from source directory - - cd ${TRAVIS_BUILD_DIR} - - python3 ./check.py --binaryen-bin=${BUILD_DIR}/install/bin - - - <<: *test-ubuntu - name: ubsan - env: | - COMPILER_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-blacklist=$(pwd)/ubsan.blacklist" - - # FIXME we currently must disable LSAN entirely, see #1351 - - <<: *test-ubuntu - name: asan - env: | - COMPILER_FLAGS="-fsanitize=address" - ASAN_OPTIONS="detect_leaks=0" - - - <<: *test-ubuntu - name: tsan - env: | - COMPILER_FLAGS="-fsanitize=thread" - LINKER_FLAGS="-fsanitize=thread" - - # Build with gcc 7 and run tests on the host system (Ubuntu). - # Also tests that out-of-tree builds work - - <<: *test-ubuntu - name: gcc-7 / out-of-tree - compiler: gcc - env: | - CC="gcc-7" - CXX="g++-7" - BUILD_DIR=out - - # Build the .js outputs using emcc - - name: emscripten - stage: test - compiler: clang - python: 2.7 - language: node_js - install: - - mkdir $HOME/cmake && - wget -qO- https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz | tar -xzC $HOME/cmake --strip-components 1 && - export PATH=$HOME/cmake/bin:$PATH - - mkdir $HOME/emsdk && - git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk && - $HOME/emsdk/emsdk update-tags && - $HOME/emsdk/emsdk install tot && - $HOME/emsdk/emsdk activate tot && - export PATH=$HOME/emsdk:$PATH - script: - # run binaryen.js tests before and after building, so we see if the bundled - # version is good too. - - source $HOME/emsdk/emsdk_env.sh && - ./scripts/travis-emcc-tests.sh - - # Build with gcc 6.3 and run tests on Alpine Linux (inside chroot). - # Note: Alpine uses musl libc. - - &test-alpine - name: alpine - stage: test - sudo: true - language: minimal - compiler: gcc - env: ARCH=x86_64 - before_install: - - docker run -w /src -dit --name alpine -v $(pwd):/src node:lts-alpine - - alpine() { docker exec -it alpine "$@"; } - install: - - alpine apk update - - alpine apk add build-base cmake git python3 clang ninja - script: - - alpine cmake . -G Ninja - - alpine ninja - - alpine python3 ./check.py - - - name: osx - env: JOB=dist-osx ARCH=x86_64-apple-darwin - os: osx - stage: archive - script: - - cmake . && make - <<: *DEPLOY_TO_GITHUB - - # Build statically linked release binaries with gcc 6.3 on Alpine Linux - # (inside chroot). If building a tagged commit, then deploy release tarball - # to GitHub Releases. - - &archive-alpine - <<: *test-alpine - name: x86_64-linux - stage: archive - env: ARCH=x86_64-linux - script: - - alpine cmake . -G Ninja - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_VERBOSE_MAKEFILE=ON - -DCMAKE_CXX_FLAGS="-static" - -DCMAKE_C_FLAGS="-static" - -DCMAKE_C_COMPILER=clang - -DCMAKE_CXX_COMPILER=clang++ - - alpine ninja - - alpine find bin/ -type f -perm -u=x -exec strip {} + - - alpine ls -lh bin/ - # Check if the built executables are really statically linked. - - if [ -n "$(find bin/ -type f -perm -u=x -exec file {} + | grep -Fvw 'statically linked')" ]; then - file bin/*; false; - fi - <<: *DEPLOY_TO_GITHUB - -notifications: - email: false @@ -329,7 +329,7 @@ def run_gcc_tests(): print('run...', output_file) actual = subprocess.check_output([os.path.abspath(output_file)]).decode('utf-8') os.remove(output_file) - if sys.platform == 'darwin': + if sys.platform == 'darwin' and os.path.exists(output_file + '.dSYM'): # Also removes debug directory produced on Mac OS shutil.rmtree(output_file + '.dSYM') diff --git a/scripts/clang-tidy-diff.sh b/scripts/clang-tidy-diff.sh index c3f3cc4a2..c8d6b11a5 100755 --- a/scripts/clang-tidy-diff.sh +++ b/scripts/clang-tidy-diff.sh @@ -21,7 +21,7 @@ if [ ! -e "$CLANG_TIDY" ]; then exit 1 fi -CLANG_DIR=$(dirname $(dirname $CLANG_TIDY)) +CLANG_DIR=$(dirname $(dirname $(readlink -f $CLANG_TIDY))) CLANG_TIDY_DIFF=$CLANG_DIR/share/clang/clang-tidy-diff.py if [ ! -e "$CLANG_TIDY_DIFF" ]; then echo "Failed to find clang-tidy-diff.py ($CLANG_TIDY_DIFF)" diff --git a/scripts/travis-emcc-tests.sh b/scripts/emcc-tests.sh index ac10118f8..bea5760e6 100755 --- a/scripts/travis-emcc-tests.sh +++ b/scripts/emcc-tests.sh @@ -2,15 +2,15 @@ set -e -echo "travis-test build:wasm" +echo "emcc-tests: build:wasm" emcmake cmake -DCMAKE_BUILD_TYPE=Release emmake make -j4 binaryen_wasm -echo "travis-test test:wasm" +echo "emcc-tests: test:wasm" python3 -m scripts.test.binaryenjs wasm -echo "travis-test done:wasm" +echo "emcc-tests: done:wasm" -echo "travis-test build:js" +echo "emcc-tests: build:js" emmake make -j4 binaryen_js -echo "travis-test test:js" +echo "emcc-tests: test:js" python3 -m scripts.test.binaryenjs js -echo "travis-test done:js" +echo "emcc-tests: done:js" |