mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-27 05:04:23 +00:00
add docker setup (#3)
motivation: add required files for ci setup changes: * add sanity script to test for oss headers and linux tests * add docker and docker-compose files for docker based tests
This commit is contained in:
1 parent
a318892778
commit
720bd5f2e5
8 files changed
+279
-1
No files matched your search
+1
-1
@@ -23,7 +23,7 @@ let package = Package(
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-nio.git", from: "1.5.0"),
|
||||
.package(url: "git@github.com:apple/swift-nio-nghttp2-support.git", from: "1.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-nio-nghttp2-support.git", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "CNIONghttp2"),
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
ARG ubuntu_version=16.04
|
||||
FROM ubuntu:$ubuntu_version
|
||||
# needed to do again after FROM due to docker limitation
|
||||
ARG ubuntu_version
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# do not start services during installation as this will fail and log a warning / error.
|
||||
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
|
||||
|
||||
# basic dependencies
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y wget git build-essential software-properties-common pkg-config locales
|
||||
RUN apt-get install -y libicu-dev libblocksruntime0
|
||||
RUN apt-get install -y lsof dnsutils netcat-openbsd # used by integration tests
|
||||
|
||||
# local
|
||||
RUN locale-gen en_US.UTF-8
|
||||
RUN locale-gen en_US en_US.UTF-8
|
||||
RUN dpkg-reconfigure locales
|
||||
RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.profile
|
||||
RUN echo 'export LANGUAGE=en_US:en' >> $HOME/.profile
|
||||
RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.profile
|
||||
|
||||
# known_hosts
|
||||
RUN mkdir -p $HOME/.ssh
|
||||
RUN touch $HOME/.ssh/known_hosts
|
||||
RUN ssh-keyscan github.com 2> /dev/null >> $HOME/.ssh/known_hosts
|
||||
|
||||
# clang
|
||||
RUN apt-get install -y clang-3.9
|
||||
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.9 100
|
||||
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.9 100
|
||||
|
||||
# modern curl, if needed
|
||||
ARG install_curl_from_source
|
||||
RUN [ ! -z $install_curl_from_source ] || apt-get install -y curl libcurl3 libz-dev
|
||||
RUN [ -z $install_curl_from_source ] || apt-get install -y libssl-dev
|
||||
RUN [ -z $install_curl_from_source ] || mkdir $HOME/.curl
|
||||
RUN [ -z $install_curl_from_source ] || wget -q https://curl.haxx.se/download/curl-7.50.3.tar.gz -O $HOME/curl.tar.gz
|
||||
RUN [ -z $install_curl_from_source ] || tar xzf $HOME/curl.tar.gz --directory $HOME/.curl --strip-components=1
|
||||
RUN [ -z $install_curl_from_source ] || ( cd $HOME/.curl && ./configure --with-ssl && make && make install && cd - )
|
||||
RUN [ -z $install_curl_from_source ] || ldconfig
|
||||
|
||||
# nghttp2
|
||||
ARG install_nghttp2_from_source
|
||||
RUN [ ! -z $install_nghttp2_from_source ] || apt-get install -y nghttp2 libnghttp2-dev
|
||||
RUN [ -z $install_nghttp2_from_source ] || mkdir $HOME/.nghttp2
|
||||
RUN [ -z $install_nghttp2_from_source ] || wget -q https://github.com/nghttp2/nghttp2/releases/download/v1.32.0/nghttp2-1.32.0.tar.gz -O $HOME/nghttp2.tar.gz
|
||||
RUN [ -z $install_nghttp2_from_source ] || tar xzf $HOME/nghttp2.tar.gz --directory $HOME/.nghttp2 --strip-components=1
|
||||
RUN [ -z $install_nghttp2_from_source ] || ( cd $HOME/.nghttp2 && ./configure && make && make install && cd - )
|
||||
RUN [ -z $install_nghttp2_from_source ] || ldconfig
|
||||
|
||||
# ruby and jazzy for docs generation
|
||||
RUN apt-add-repository -y ppa:brightbox/ruby-ng
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ruby2.4 ruby2.4-dev libsqlite3-dev
|
||||
RUN gem install jazzy --no-ri --no-rdoc
|
||||
|
||||
# swift
|
||||
ARG swift_version=4.0.3
|
||||
RUN mkdir $HOME/.swift
|
||||
RUN wget -q https://swift.org/builds/swift-${swift_version}-release/ubuntu$(echo $ubuntu_version | sed 's/\.//g')/swift-${swift_version}-RELEASE/swift-${swift_version}-RELEASE-ubuntu${ubuntu_version}.tar.gz -O $HOME/swift.tar.gz
|
||||
RUN tar xzf $HOME/swift.tar.gz --directory $HOME/.swift --strip-components=1
|
||||
RUN echo 'export PATH="$HOME/.swift/usr/bin:$PATH"' >> $HOME/.profile
|
||||
RUN echo 'export LINUX_SOURCEKIT_LIB_PATH="$HOME/.swift/usr/lib"' >> $HOME/.profile
|
||||
|
||||
# script to allow mapping framepointers on linux
|
||||
RUN mkdir -p $HOME/.scripts
|
||||
RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.scripts/symbolicate-linux-fatal
|
||||
RUN chmod 755 $HOME/.scripts/symbolicate-linux-fatal
|
||||
RUN echo 'export PATH="$HOME/.scripts:$PATH"' >> $HOME/.profile
|
||||
@@ -0,0 +1,15 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-nio-http2:ubuntu-14.04-4.0.3
|
||||
build:
|
||||
args:
|
||||
ubuntu_version : "14.04"
|
||||
swift_version : "4.0.3"
|
||||
install_curl_from_source: "true"
|
||||
install_nghttp2_from_source: "true"
|
||||
|
||||
test:
|
||||
image: swift-nio-http2:ubuntu-14.04-4.0.3
|
||||
@@ -0,0 +1,15 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-nio-http2:ubuntu-14.04-4.1
|
||||
build:
|
||||
args:
|
||||
ubuntu_version : "14.04"
|
||||
swift_version : "4.1"
|
||||
install_curl_from_source: "true"
|
||||
install_nghttp2_from_source: "true"
|
||||
|
||||
test:
|
||||
image: swift-nio-http2:ubuntu-14.04-4.1
|
||||
@@ -0,0 +1,14 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-nio-http2:ubuntu-16.04-4.0.3
|
||||
build:
|
||||
args:
|
||||
ubuntu_version : "16.04"
|
||||
swift_version : "4.0.3"
|
||||
install_nghttp2_from_source: "true"
|
||||
|
||||
test:
|
||||
image: swift-nio-http2:ubuntu-16.04-4.0.3
|
||||
@@ -0,0 +1,14 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-nio-http2:ubuntu-16.04-4.1
|
||||
build:
|
||||
args:
|
||||
ubuntu_version : "16.04"
|
||||
swift_version : "4.1"
|
||||
install_nghttp2_from_source: "true"
|
||||
|
||||
test:
|
||||
image: swift-nio-http2:ubuntu-16.04-4.1
|
||||
@@ -0,0 +1,28 @@
|
||||
# this file is not designed to be run directly
|
||||
# instead, use the docker-compose.<os>.<swift> files
|
||||
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.ubuntu-1604.41.yaml run test
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-nio-http2:default
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.ubuntu
|
||||
|
||||
common: &common
|
||||
image: swift-nio-http2:default
|
||||
depends_on: [runtime-setup]
|
||||
volumes:
|
||||
- ~/.ssh:/root/.ssh
|
||||
- ..:/code
|
||||
working_dir: /code
|
||||
|
||||
sanity:
|
||||
<<: *common
|
||||
command: /bin/bash -cl "./scripts/sanity.sh"
|
||||
|
||||
test:
|
||||
<<: *common
|
||||
command: /bin/bash -cl "swift test"
|
||||
Executable
+121
@@ -0,0 +1,121 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftNIO open source project
|
||||
##
|
||||
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
printf "=> Checking linux tests... "
|
||||
FIRST_OUT="$(git status --porcelain)"
|
||||
ruby "$here/../scripts/generate_linux_tests.rb" > /dev/null
|
||||
SECOND_OUT="$(git status --porcelain)"
|
||||
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
|
||||
printf "\033[0;31mmissing changes!\033[0m\n"
|
||||
git --no-pager diff
|
||||
exit 1
|
||||
else
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
fi
|
||||
|
||||
printf "=> Checking license headers... "
|
||||
tmp=$(mktemp /tmp/.swift-nio-sanity_XXXXXX)
|
||||
|
||||
for language in swift-or-c bash dtrace; do
|
||||
declare -a matching_files
|
||||
declare -a exceptions
|
||||
expections=( )
|
||||
matching_files=( -name '*' )
|
||||
case "$language" in
|
||||
swift-or-c)
|
||||
exceptions=( -name c_nio_http_parser.c -o -name c_nio_http_parser.h -o -name cpp_magic.h -o -name Package.swift -o -name c_nio_sha1.h -o -name c_nio_sha1.c)
|
||||
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
EOF
|
||||
;;
|
||||
bash)
|
||||
matching_files=( -name '*.sh' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftNIO open source project
|
||||
##
|
||||
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
EOF
|
||||
;;
|
||||
dtrace)
|
||||
matching_files=( -name '*.d' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
#!/usr/sbin/dtrace -q -s
|
||||
/*===----------------------------------------------------------------------===*
|
||||
*
|
||||
* This source file is part of the SwiftNIO open source project
|
||||
*
|
||||
* Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
* Licensed under Apache License v2.0
|
||||
*
|
||||
* See LICENSE.txt for license information
|
||||
* See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*===----------------------------------------------------------------------===*/
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo >&2 "ERROR: unknown language '$language'"
|
||||
;;
|
||||
esac
|
||||
|
||||
expected_lines=$(cat "$tmp" | wc -l)
|
||||
expected_sha=$(cat "$tmp" | shasum)
|
||||
|
||||
(
|
||||
cd "$here/.."
|
||||
find . \
|
||||
\( \! -path './.build/*' -a \
|
||||
\( "${matching_files[@]}" \) -a \
|
||||
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
|
||||
if [[ "$(cat "$line" | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
|
||||
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
|
||||
diff -u <(cat "$line" | head -n $expected_lines) "$tmp"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
)
|
||||
done
|
||||
|
||||
rm "$tmp"
|
||||
Reference in new issue
Block a user