Skip to content

Commit 0fa022e

Browse files
authored
Add docker-based test harness. (#3)
For testing we like to use docker to manage our Linux configurations. This patch adds that support for helpful CI management.
1 parent 03ade06 commit 0fa022e

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

docker/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
ARG swift_version=5.2
2+
ARG ubuntu_version=bionic
3+
ARG base_image=swift:$swift_version-$ubuntu_version
4+
FROM $base_image
5+
# needed to do again after FROM due to docker limitation
6+
ARG swift_version
7+
ARG ubuntu_version
8+
9+
# set as UTF-8
10+
RUN apt-get update && apt-get install -y locales locales-all
11+
ENV LC_ALL en_US.UTF-8
12+
ENV LANG en_US.UTF-8
13+
ENV LANGUAGE en_US.UTF-8
14+
15+
# dependencies
16+
RUN apt-get update && apt-get install -y wget
17+
RUN apt-get update && apt-get install -y lsof dnsutils netcat-openbsd net-tools curl jq # used by integration tests
18+
19+
# ruby and jazzy for docs generation
20+
RUN apt-get update && apt-get install -y ruby ruby-dev libsqlite3-dev
21+
# jazzy no longer works on xenial as ruby is too old.
22+
RUN if [ "${ubuntu_version}" != "xenial" ] ; then gem install jazzy --no-ri --no-rdoc ; fi
23+
24+
# tools
25+
RUN mkdir -p $HOME/.tools
26+
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
27+
28+
# swiftformat (until part of the toolchain)
29+
30+
ARG swiftformat_version=0.40.12
31+
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
32+
RUN cd $HOME/.tools/swift-format && swift build -c release
33+
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat

docker/docker-compose.1604.52.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: swift-http-structured-headers:16.04-5.2
7+
build:
8+
args:
9+
ubuntu_version: "xenial"
10+
swift_version: "5.2"
11+
12+
unit-tests:
13+
image: swift-http-structured-headers:16.04-5.2
14+
15+
test:
16+
image: swift-http-structured-headers:16.04-5.2
17+
environment:
18+
- SANITIZER_ARG=--sanitize=thread
19+
20+
shell:
21+
image: swift-http-structured-headers:16.04-5.2

docker/docker-compose.1804.53.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: "3"
2+
3+
services:
4+
5+
runtime-setup:
6+
image: swift-http-structured-headers:18.04-5.3
7+
build:
8+
args:
9+
ubuntu_version: "bionic"
10+
swift_version: "5.3"
11+
12+
unit-tests:
13+
image: swift-http-structured-headers:18.04-5.3
14+
15+
test:
16+
image: swift-http-structured-headers:18.04-5.3
17+
environment:
18+
- SANITIZER_ARG=--sanitize=thread
19+
20+
shell:
21+
image: swift-http-structured-headers:18.04-5.3
22+

docker/docker-compose.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# this file is not designed to be run directly
2+
# 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
4+
version: "3"
5+
6+
services:
7+
8+
runtime-setup:
9+
image: swift-http-structured-headers:default
10+
build:
11+
context: .
12+
dockerfile: Dockerfile
13+
14+
common: &common
15+
image: swift-http-structured-headers:default
16+
depends_on: [runtime-setup]
17+
volumes:
18+
- ~/.ssh:/root/.ssh
19+
- ..:/code:z
20+
working_dir: /code
21+
cap_drop:
22+
- CAP_NET_RAW
23+
- CAP_NET_BIND_SERVICE
24+
25+
sanity:
26+
<<: *common
27+
command: /bin/bash -xcl "./scripts/sanity.sh"
28+
29+
unit-tests:
30+
<<: *common
31+
command: /bin/bash -xcl "swift test --enable-test-discovery -Xswiftc -warnings-as-errors"
32+
33+
test:
34+
<<: *common
35+
command: /bin/bash -xcl "swift test --enable-test-discovery -Xswiftc -warnings-as-errors $${SANITIZER_ARG-}"
36+
37+
38+
# util
39+
40+
shell:
41+
<<: *common
42+
entrypoint: /bin/bash

0 commit comments

Comments
 (0)