Skip to content

Commit 104b688

Browse files
authored
Prepare Dockerfiles and scripts for swift-server CI (#90)
1 parent a030b40 commit 104b688

9 files changed

+433
-0
lines changed

docker/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARG swift_version=5.7
2+
ARG ubuntu_version=jammy
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 libz-dev 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 build-essential
21+
# jazzy no longer works on xenial as ruby is too old.
22+
RUN if [ "${ubuntu_version}" = "focal" ] ; then echo "gem: --no-document" > ~/.gemrc; fi
23+
RUN if [ "${ubuntu_version}" = "focal" ] ; then gem install jazzy; fi
24+
25+
# tools
26+
RUN mkdir -p $HOME/.tools
27+
RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
28+
29+
# swiftformat (until part of the toolchain)
30+
31+
ARG swiftformat_version=0.48.8
32+
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
33+
RUN cd $HOME/.tools/swift-format && swift build -c release
34+
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat

docker/docker-compose.2204.57.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: prometheus:22.04-5.7
7+
build:
8+
args:
9+
ubuntu_version: "jammy"
10+
swift_version: "5.7"
11+
12+
documentation-check:
13+
image: prometheus:22.04-5.7
14+
15+
test:
16+
image: prometheus:22.04-5.7
17+
environment: []
18+
#- SANITIZER_ARG=--sanitize=thread
19+
20+
shell:
21+
image: prometheus:22.04-5.7

docker/docker-compose.2204.58.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: prometheus:22.04-5.8
7+
build:
8+
args:
9+
ubuntu_version: "jammy"
10+
swift_version: "5.8"
11+
12+
documentation-check:
13+
image: prometheus:22.04-5.8
14+
15+
test:
16+
image: prometheus:22.04-5.8
17+
environment:
18+
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
19+
#- SANITIZER_ARG=--sanitize=thread
20+
21+
shell:
22+
image: prometheus:22.04-5.8

docker/docker-compose.2204.59.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: prometheus:22.04-5.9
7+
build:
8+
args:
9+
base_image: "swiftlang/swift:nightly-5.9-jammy"
10+
11+
documentation-check:
12+
image: prometheus:22.04-5.9
13+
14+
test:
15+
image: prometheus:22.04-5.9
16+
environment:
17+
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
18+
#- SANITIZER_ARG=--sanitize=thread
19+
20+
shell:
21+
image: prometheus:22.04-5.9

docker/docker-compose.2204.main.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: prometheus:22.04-main
7+
build:
8+
args:
9+
base_image: "swiftlang/swift:nightly-main-jammy"
10+
11+
documentation-check:
12+
image: prometheus:22.04-main
13+
14+
test:
15+
image: prometheus:22.04-main
16+
environment:
17+
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
18+
#- SANITIZER_ARG=--sanitize=thread
19+
20+
shell:
21+
image: prometheus:22.04-main

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.1804.50.yaml run test
4+
version: "3"
5+
6+
services:
7+
8+
runtime-setup:
9+
image: prometheus:default
10+
build:
11+
context: .
12+
dockerfile: Dockerfile
13+
14+
common: &common
15+
image: prometheus: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+
soundness:
26+
<<: *common
27+
command: /bin/bash -xcl "./scripts/soundness.sh"
28+
29+
documentation-check:
30+
<<: *common
31+
command: /bin/bash -xcl "./scripts/check-docs.sh"
32+
33+
test:
34+
<<: *common
35+
depends_on: [runtime-setup]
36+
command: /bin/bash -xcl "swift test -Xswiftc -warnings-as-errors --enable-test-discovery $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}"
37+
38+
# util
39+
40+
shell:
41+
<<: *common
42+
entrypoint: /bin/bash

scripts/check_no_api_breakages.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftPrometheus open source project
5+
##
6+
## Copyright (c) 2023 SwiftPrometheus project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
##===----------------------------------------------------------------------===##
16+
##
17+
## This source file is part of the SwiftNIO open source project
18+
##
19+
## Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors
20+
## Licensed under Apache License v2.0
21+
##
22+
## See LICENSE.txt for license information
23+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
24+
##
25+
## SPDX-License-Identifier: Apache-2.0
26+
##
27+
##===----------------------------------------------------------------------===##
28+
29+
set -eu
30+
31+
function usage() {
32+
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
33+
echo >&2
34+
echo >&2 "This script requires a Swift 5.6+ toolchain."
35+
echo >&2
36+
echo >&2 "Examples:"
37+
echo >&2
38+
echo >&2 "Check between main and tag 1.0.2 of prometheus:"
39+
echo >&2 " $0 https://github.com/swift-server/swift-prometheus main 1.0.2"
40+
echo >&2
41+
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
42+
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
43+
}
44+
45+
if [[ $# -lt 3 ]]; then
46+
usage
47+
exit 1
48+
fi
49+
50+
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
51+
repo_url=$1
52+
new_tag=$2
53+
shift 2
54+
55+
repodir="$tmpdir/repo"
56+
git clone "$repo_url" "$repodir"
57+
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
58+
cd "$repodir"
59+
git checkout -q "$new_tag"
60+
61+
for old_tag in "$@"; do
62+
echo "Checking public API breakages from $old_tag to $new_tag"
63+
64+
swift package diagnose-api-breaking-changes "$old_tag"
65+
done
66+
67+
echo done

scripts/generate_contributors_list.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftPrometheus open source project
5+
##
6+
## Copyright (c) 2023 SwiftPrometheus project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftPrometheus project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
##===----------------------------------------------------------------------===##
16+
##
17+
## This source file is part of the SwiftNIO open source project
18+
##
19+
## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
20+
## Licensed under Apache License v2.0
21+
##
22+
## See LICENSE.txt for license information
23+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
24+
##
25+
## SPDX-License-Identifier: Apache-2.0
26+
##
27+
##===----------------------------------------------------------------------===##
28+
29+
set -eu
30+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
31+
contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' )
32+
33+
cat > "$here/../CONTRIBUTORS.txt" <<- EOF
34+
For the purpose of tracking copyright, this is the list of individuals and
35+
organizations who have contributed source code to RediStack.
36+
37+
For employees of an organization/company where the copyright of work done
38+
by employees of that company is held by the company itself, only the company
39+
needs to be listed here.
40+
41+
## COPYRIGHT HOLDERS
42+
43+
- Apple Inc. (all contributors with '@apple.com')
44+
- Globant Inc. (all contributors with '@globant.com')
45+
46+
### Contributors
47+
48+
$contributors
49+
50+
**Updating this list**
51+
52+
Please do not edit this file manually. It is generated using \`./scripts/generate_contributors_list.sh\`. If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\`
53+
EOF

0 commit comments

Comments
 (0)