diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 000000000000..2d36da97594c --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,101 @@ +name: Linux CI + +on: [push, pull_request] + +env: + TRAVIS_OS_NAME: linux + SPEC_SPLIT_DOTS: 160 + +jobs: + test_linux: + env: + ARCH: x86_64 + ARCH_CMD: linux64 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Test + run: bin/ci build + + test_linux_32: + env: + ARCH: i386 + ARCH_CMD: linux32 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Test + run: bin/ci with_build_env 'make std_spec threads=1' + + test_alpine: + env: + ARCH: x86_64-musl + ARCH_CMD: linux64 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Test + run: bin/ci build + + test_preview_mt: + env: + ARCH: x86_64 + ARCH_CMD: linux64 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Make Crystal + run: bin/ci with_build_env 'make crystal' + + - name: Test + run: bin/ci with_build_env 'CRYSTAL_WORKERS=4 make std_spec threads=1 FLAGS="-D preview_mt"' + + check_format: + env: + ARCH: x86_64 + ARCH_CMD: linux64 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Check Format + run: bin/ci format diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 000000000000..9d29a7d243a3 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,25 @@ +name: macOS CI + +on: [push, pull_request] + +env: + TRAVIS_OS_NAME: osx + LLVM_CONFIG: /usr/local/opt/llvm/bin/llvm-config + PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig + SPEC_SPLIT_DOTS: 160 + +jobs: + test_macos: + runs-on: macos-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v2 + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Test + run: bin/ci build diff --git a/bin/ci b/bin/ci index f6870d7b5bc7..85028df1d3cd 100755 --- a/bin/ci +++ b/bin/ci @@ -65,6 +65,15 @@ on_osx() { fail_on_error on_os "osx" "${@}" } +on_github() { + if [ "$GITHUB_ACTIONS" = "true" ]; then + eval "${@}" + return $? + else + return 0 + fi +} + prepare_system() { on_linux 'echo '"'"'{"ipv6":true, "fixed-cidr-v6":"2001:db8:1::/64"}'"'"' | sudo tee /etc/docker/daemon.json' on_linux sudo service docker restart @@ -112,7 +121,8 @@ prepare_build() { on_osx 'pushd ~;gunzip -c ~/crystal.tar.gz | tar xopf -;mv crystal-0.34.0-1 crystal;popd' on_osx 'brew unlink python@2 || true' - on_osx brew install z3 llvm@10 gmp libevent pcre openssl pkg-config + on_osx brew install z3 llvm@10 gmp libevent pcre pkg-config + on_osx brew reinstall openssl on_osx brew link --force llvm@10 # Note: brew link --force might show: # Warning: Refusing to link macOS-provided software: llvm @@ -137,6 +147,7 @@ verify_version() { with_build_env() { command="$1" + on_github "echo '::group::$1'" # Ensure non GMT timezone export TZ="America/New_York" @@ -165,6 +176,7 @@ with_build_env() { -v /etc/group:/etc/group \ -w /mnt \ -e CRYSTAL_CACHE_DIR="/tmp/crystal" \ + -e SPEC_SPLIT_DOTS \ "$DOCKER_TEST_IMAGE" \ "$ARCH_CMD" /bin/sh -c "'$command'" @@ -174,6 +186,7 @@ with_build_env() { CRYSTAL_CACHE_DIR="/tmp/crystal" \ /bin/sh -c "'$command'" + on_github echo "::endgroup::" } usage() { diff --git a/src/spec/formatter.cr b/src/spec/formatter.cr index e031204e109e..51b355ec075f 100644 --- a/src/spec/formatter.cr +++ b/src/spec/formatter.cr @@ -25,11 +25,31 @@ module Spec # :nodoc: class DotFormatter < Formatter + @count = 0 + @split = 0 + + def initialize(*args) + super + + if split = ENV["SPEC_SPLIT_DOTS"]? + @split = split.to_i + end + end + def report(result) @io << Spec.color(LETTERS[result.kind], result.kind) + split_lines @io.flush end + private def split_lines + return unless @split > 0 + if (@count += 1) >= @split + @io.puts + @count = 0 + end + end + def finish(elapsed_time, aborted) @io.puts end