Skip to content

Commit 71aa686

Browse files
tomerdweissi
authored andcommitted
swift 5.1 docker setup (#133)
* swift 5.1 docker setup motivation: support swift 5.1 changes: * use formal swift docker images * refactor docker-compose to seperate unit tests, integration tests and full test suites * add docker compose file for swift 5.1, will add CI job once merged * update swiftformat version to 0.40.12
1 parent 31c599f commit 71aa686

File tree

4 files changed

+61
-52
lines changed

4 files changed

+61
-52
lines changed

docker/Dockerfile

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,36 @@
1-
ARG ubuntu_version=16.04
2-
FROM ubuntu:$ubuntu_version
1+
ARG swift_version=5.0
2+
ARG ubuntu_version=bionic
3+
FROM swift:$swift_version-$ubuntu_version
34
# needed to do again after FROM due to docker limitation
5+
ARG swift_version
46
ARG ubuntu_version
57

6-
ARG DEBIAN_FRONTEND=noninteractive
7-
# do not start services during installation as this will fail and log a warning / error.
8-
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
8+
# set as UTF-8
9+
RUN apt-get update && apt-get install -y locales locales-all
10+
ENV LC_ALL en_US.UTF-8
11+
ENV LANG en_US.UTF-8
12+
ENV LANGUAGE en_US.UTF-8
913

10-
# basic dependencies
11-
RUN apt-get update && apt-get install -y wget git build-essential software-properties-common pkg-config locales expect
12-
RUN apt-get update && apt-get install -y libicu-dev libblocksruntime0 libssl-dev
13-
14-
# local
15-
RUN locale-gen en_US.UTF-8
16-
RUN locale-gen en_US en_US.UTF-8
17-
RUN dpkg-reconfigure locales
18-
RUN echo 'export LANG=en_US.UTF-8' >> $HOME/.profile
19-
RUN echo 'export LANGUAGE=en_US:en' >> $HOME/.profile
20-
RUN echo 'export LC_ALL=en_US.UTF-8' >> $HOME/.profile
21-
22-
# known_hosts
23-
RUN mkdir -p $HOME/.ssh
24-
RUN touch $HOME/.ssh/known_hosts
25-
RUN ssh-keyscan github.com 2> /dev/null >> $HOME/.ssh/known_hosts
26-
27-
# clang
28-
RUN apt-get update && apt-get install -y clang-3.9
29-
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.9 100
30-
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.9 100
31-
32-
# modern curl, if needed
33-
ARG install_curl_from_source
34-
RUN apt-get update && apt-get install -y curl libcurl4-openssl-dev libz-dev
14+
# dependencies
15+
RUN apt-get update && apt-get install -y wget
16+
RUN apt-get update && apt-get install -y lsof dnsutils netcat-openbsd net-tools expect # used by integration tests
17+
RUN apt-get update && apt-get install -y libssl-dev
3518

3619
# ruby and jazzy for docs generation
37-
ARG skip_ruby_from_ppa
38-
RUN [ -n "$skip_ruby_from_ppa" ] || apt-add-repository -y ppa:brightbox/ruby-ng
39-
RUN [ -n "$skip_ruby_from_ppa" ] || { apt-get update && apt-get install -y ruby2.4 ruby2.4-dev; }
40-
RUN [ -z "$skip_ruby_from_ppa" ] || { apt-get update && apt-get install -y ruby ruby-dev; }
41-
RUN apt-get update && apt-get install -y libsqlite3-dev
20+
RUN apt-get update && apt-get install -y ruby ruby-dev libsqlite3-dev
4221
RUN gem install jazzy --no-ri --no-rdoc
4322

44-
# swift
45-
ARG swift_version=4.0.3
46-
ARG swift_flavour=RELEASE
47-
ARG swift_builds_suffix=release
23+
# tools
24+
RUN mkdir -p $HOME/.tools
25+
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
26+
27+
# script to allow mapping framepointers on linux (until part of the toolchain)
28+
RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.tools/symbolicate-linux-fatal
29+
RUN chmod 755 $HOME/.tools/symbolicate-linux-fatal
4830

49-
RUN mkdir $HOME/.swift
50-
RUN wget -q "https://swift.org/builds/swift-${swift_version}-${swift_builds_suffix}/ubuntu$(echo $ubuntu_version | sed 's/\.//g')/swift-${swift_version}-${swift_flavour}/swift-${swift_version}-${swift_flavour}-ubuntu${ubuntu_version}.tar.gz" -O $HOME/swift.tar.gz
51-
RUN tar xzf $HOME/swift.tar.gz --directory $HOME/.swift --strip-components=1
52-
RUN echo 'export PATH="$HOME/.swift/usr/bin:$PATH"' >> $HOME/.profile
53-
RUN echo 'export LINUX_SOURCEKIT_LIB_PATH="$HOME/.swift/usr/lib"' >> $HOME/.profile
31+
# swiftformat (until part of the toolchain)
5432

55-
# script to allow mapping framepointers on linux
56-
RUN mkdir -p $HOME/.scripts
57-
RUN wget -q https://raw.githubusercontent.com/apple/swift/master/utils/symbolicate-linux-fatal -O $HOME/.scripts/symbolicate-linux-fatal
58-
RUN chmod 755 $HOME/.scripts/symbolicate-linux-fatal
59-
RUN echo 'export PATH="$HOME/.scripts:$PATH"' >> $HOME/.profile
33+
ARG swiftformat_version=0.40.12
34+
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
35+
RUN cd $HOME/.tools/swift-format && swift build -c release
36+
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat

docker/docker-compose.1604.51.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: swift-nio-ssl:16.04-5.1
7+
build:
8+
args:
9+
ubuntu_version: "xenial"
10+
swift_version: "5.1"
11+
12+
unit-tests:
13+
image: swift-nio-ssl:16.04-5.1
14+
15+
integration-tests:
16+
image: swift-nio-ssl:16.04-5.1
17+
18+
test:
19+
image: swift-nio-ssl:16.04-5.1

docker/docker-compose.1804.50.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ services:
66
image: swift-nio-ssl:18.04-5.0
77
build:
88
args:
9-
ubuntu_version: "18.04"
9+
ubuntu_version: "bionic"
1010
swift_version: "5.0"
11-
skip_ruby_from_ppa: "true"
11+
12+
unit-tests:
13+
image: swift-nio-ssl:18.04-5.0
14+
15+
integration-tests:
16+
image: swift-nio-ssl:18.04-5.0
1217

1318
test:
1419
image: swift-nio-ssl:18.04-5.0

docker/docker-compose.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# this file is not designed to be run directly
22
# instead, use the docker-compose.<os>.<swift> files
3-
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.1604.41.yaml run test
3+
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.1804.50.yaml run test
44
version: "3"
55

66
services:
@@ -23,6 +23,14 @@ services:
2323
<<: *common
2424
command: /bin/bash -cl "./scripts/sanity.sh"
2525

26+
unit-tests:
27+
<<: *common
28+
command: /bin/bash -cl "swift test -Xswiftc -warnings-as-errors"
29+
30+
integration-tests:
31+
<<: *common
32+
command: /bin/bash -cl "./scripts/integration_tests.sh"
33+
2634
test:
2735
<<: *common
2836
command: /bin/bash -cl "swift test -Xswiftc -warnings-as-errors && ./scripts/integration_tests.sh"

0 commit comments

Comments
 (0)