<commit_before>#!/bin/bash
#
# Copyright 2018, alex at staticlibs.net
#
# 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.

set -e
set -x

# detect container
export VERSION_XENIAL=`cat /etc/os-release | grep xenial | wc -l`
export VERSION_STRETCH=`cat /etc/os-release | grep stretch | wc -l`
export VERSION_BIONIC=`cat /etc/os-release | grep bionic | wc -l`

if [ "x2" = "x${VERSION_XENIAL}" ] ; then
    # there are no separate flavour for xenial
    export WILTON_BUILD_FLAVOUR=stretch
    export WILTON_ARCH=armhf
    export WILTON_QEMU_ARCH=arm
    export WILTON_IMAGE_POSTFIX=xenial
    export LANG=C
fi
if [ "x2" = "x${VERSION_STRETCH}" ] ; then
    export WILTON_BUILD_FLAVOUR=stretch
    export WILTON_ARCH=aarch64
    export WILTON_QEMU_ARCH=aarch64
    export WILTON_IMAGE_POSTFIX=stretch
fi
if [ "x2" = "x${VERSION_BIONIC}" ] ; then
    export WILTON_BUILD_FLAVOUR=bionic
    export WILTON_ARCH=amd64
    export WILTON_IMAGE_POSTFIX=bionic
    # additional engines
    git submodule update --quiet --init deps/external_chakracore
    git submodule update --quiet --init deps/external_icu
    git submodule update --quiet --init deps/external_mozjs
    git submodule update --quiet --init deps/external_v8
    git submodule update --quiet --init engines/wilton_chakracore
    git submodule update --quiet --init engines/wilton_mozjs
    git submodule update --quiet --init engines/wilton_v8
fi

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

# build
mkdir build
pushd build
if [ "x" = "x${CIRRUS_TAG}" ] ;  then
    cmake .. -DSTATICLIB_TOOLCHAIN=linux_${WILTON_ARCH}_gcc -DWILTON_BUILD_FLAVOUR=${WILTON_BUILD_FLAVOUR}
else
    cmake .. -DSTATICLIB_TOOLCHAIN=linux_${WILTON_ARCH}_gcc -DWILTON_BUILD_FLAVOUR=${WILTON_BUILD_FLAVOUR} -DWILTON_RELEASE=${CIRRUS_TAG}
fi
make -j 2
make dist_debug > dist_debug.log

# test
make dist_unversioned > dist_unversioned.log

if [ "xbionic" = "x${WILTON_BUILD_FLAVOUR}" ] ; then

echo jsc
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j jsc
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j jsc
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j jsc > jsc_stdlib.log

echo duktape
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j duktape
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j duktape

echo chakracore
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j chakracore
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j chakracore
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j chakracore > chakracore_stdlib.log

echo mozjs
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j mozjs
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j mozjs
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j mozjs > mozjs_stdlib.log

echo v8
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j v8
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j v8
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j v8 > v8_stdlib.log

echo jvm
pushd ../jni
../tools/maven/bin/mvn --batch-mode clean test
popd

echo jre
ln -s ${JAVA_HOME}/jre ./wilton_dist/jre

export JAVA_TOOL_OPTIONS="-XX:MaxRAM=512M -XX:+UseSerialGC -XX:+TieredCompilation -XX:TieredStopAtLevel=1"

echo rhino
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j rhino
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j rhino

echo nashorn
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j nashorn
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j nashorn

else # QEMU

    echo duktape
    qemu-${WILTON_QEMU_ARCH}-static ./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j duktape
    qemu-${WILTON_QEMU_ARCH}-static ./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j duktape

fi

if [ "x" != "x${CIRRUS_TAG}" ] ;  then
    export IMAGE=wilton_${CIRRUS_TAG}_${WILTON_ARCH}_${WILTON_IMAGE_POSTFIX}
    mv ./wilton_${CIRRUS_TAG} ${IMAGE}
    zip -qyr9 ${IMAGE}.zip ${IMAGE}
    ../../ghr/ghr -t ${GITHUB_TOKEN} -u wilton-iot -r test-ci -c ${CIRRUS_CHANGE_IN_REPO} ${CIRRUS_TAG} ${IMAGE}.zip
fi

echo WILTON_FINISH_SUCCESS<commit_msg>cirrus ghr fix<commit_after>#!/bin/bash
#
# Copyright 2018, alex at staticlibs.net
#
# 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.

set -e
set -x

# detect container
export VERSION_XENIAL=`cat /etc/os-release | grep xenial | wc -l`
export VERSION_STRETCH=`cat /etc/os-release | grep stretch | wc -l`
export VERSION_BIONIC=`cat /etc/os-release | grep bionic | wc -l`

if [ "x2" = "x${VERSION_XENIAL}" ] ; then
    # there are no separate flavour for xenial
    export WILTON_BUILD_FLAVOUR=stretch
    export WILTON_ARCH=armhf
    export WILTON_QEMU_ARCH=arm
    export WILTON_IMAGE_POSTFIX=xenial
    export LANG=C
fi
if [ "x2" = "x${VERSION_STRETCH}" ] ; then
    export WILTON_BUILD_FLAVOUR=stretch
    export WILTON_ARCH=aarch64
    export WILTON_QEMU_ARCH=aarch64
    export WILTON_IMAGE_POSTFIX=stretch
fi
if [ "x2" = "x${VERSION_BIONIC}" ] ; then
    export WILTON_BUILD_FLAVOUR=bionic
    export WILTON_ARCH=amd64
    export WILTON_IMAGE_POSTFIX=bionic
    # additional engines
    git submodule update --quiet --init deps/external_chakracore
    git submodule update --quiet --init deps/external_icu
    git submodule update --quiet --init deps/external_mozjs
    git submodule update --quiet --init deps/external_v8
    git submodule update --quiet --init engines/wilton_chakracore
    git submodule update --quiet --init engines/wilton_mozjs
    git submodule update --quiet --init engines/wilton_v8
fi

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

# build
mkdir build
pushd build
if [ "x" = "x${CIRRUS_TAG}" ] ;  then
    cmake .. -DSTATICLIB_TOOLCHAIN=linux_${WILTON_ARCH}_gcc -DWILTON_BUILD_FLAVOUR=${WILTON_BUILD_FLAVOUR}
else
    cmake .. -DSTATICLIB_TOOLCHAIN=linux_${WILTON_ARCH}_gcc -DWILTON_BUILD_FLAVOUR=${WILTON_BUILD_FLAVOUR} -DWILTON_RELEASE=${CIRRUS_TAG}
fi
make -j 2
make dist_debug > dist_debug.log

# test
make dist_unversioned > dist_unversioned.log

if [ "xbionic" = "x${WILTON_BUILD_FLAVOUR}" ] ; then

echo jsc
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j jsc
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j jsc
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j jsc > jsc_stdlib.log

echo duktape
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j duktape
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j duktape

echo chakracore
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j chakracore
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j chakracore
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j chakracore > chakracore_stdlib.log

echo mozjs
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j mozjs
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j mozjs
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j mozjs > mozjs_stdlib.log

echo v8
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j v8
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j v8
./wilton_dist/bin/wilton ../js/test-runners/runStdLibTests.js -m ../js -j v8 > v8_stdlib.log

echo jvm
pushd ../jni
../tools/maven/bin/mvn --batch-mode clean test
popd

echo jre
ln -s ${JAVA_HOME}/jre ./wilton_dist/jre

export JAVA_TOOL_OPTIONS="-XX:MaxRAM=512M -XX:+UseSerialGC -XX:+TieredCompilation -XX:TieredStopAtLevel=1"

echo rhino
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j rhino
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j rhino

echo nashorn
./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j nashorn
./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j nashorn

else # QEMU

    echo duktape
    qemu-${WILTON_QEMU_ARCH}-static ./wilton_dist/bin/wilton ../js/wilton/test/index.js -m ../js -j duktape
    qemu-${WILTON_QEMU_ARCH}-static ./wilton_dist/bin/wilton ../js/test-runners/runSanityTests.js -m ./wilton_dist/std.min.wlib -j duktape

fi

if [ "x" != "x${CIRRUS_TAG}" ] ;  then
    export IMAGE=wilton_${CIRRUS_TAG}_${WILTON_ARCH}_${WILTON_IMAGE_POSTFIX}
    mv ./wilton_${CIRRUS_TAG} ${IMAGE}
    zip -qyr9 ${IMAGE}.zip ${IMAGE}
    ../../ghr/ghr -t ${GITHUB_TOKEN} -u wilton-iot -r wilton -c ${CIRRUS_CHANGE_IN_REPO} ${CIRRUS_TAG} ${IMAGE}.zip
fi

echo WILTON_FINISH_SUCCESS
{'fraction_non_alphanumeric': 0.1366740309299056, 'fraction_numerical': 0.007029524000803374, 'mean_word_length': 3.539197812215132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3477599', 'n_tokens_mistral': 4102, 'n_tokens_neox': 3923, 'n_words': 855}