From cfb1c80dcf649ea3e8da67bc14ba0c5924a2b174 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 10:25:31 +0000 Subject: [PATCH 01/26] Add Swift Dependencies --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 88ff09f6..dfec151f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ update-locale en_US.UTF-8 && \ apt-key adv --fetch-keys https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc && \ apt-key adv --fetch-keys https://packagecloud.io/github/git-lfs/gpgkey && \ + apt-key adv --fetch-keys https://swift.org/keys/all-keys.asc && \ apt-add-repository -y -s 'deb https://packagecloud.io/github/git-lfs/ubuntu/ xenial main' && \ add-apt-repository -y ppa:ondrej/php && \ add-apt-repository -y ppa:openjdk-r/ppa && \ @@ -41,6 +42,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ bison \ build-essential \ bzr \ + clang \ cmake \ curl \ doxygen \ From ba0c3520a7feb2afa97e55c38d31ccffed15f491 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 10:30:44 +0000 Subject: [PATCH 02/26] Add Swift Version parameter to start image --- test-tools/start-image.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test-tools/start-image.sh b/test-tools/start-image.sh index 63b7857e..7b155881 100755 --- a/test-tools/start-image.sh +++ b/test-tools/start-image.sh @@ -11,6 +11,7 @@ docker run --rm -t -i \ -e HUGO_VERSION \ -e PHP_VERSION \ -e GO_VERSION \ + -e SWIFT_VERSION \ -v ${REPO_PATH}:/opt/repo \ -v ${BASE_PATH}/run-build.sh:/usr/local/bin/build \ -v ${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh \ From 42ffdb0a3fea997f2ce329ef0927c1caab0746a3 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 10:31:43 +0000 Subject: [PATCH 03/26] Add Swift Version to test-build --- test-tools/test-build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-tools/test-build.sh b/test-tools/test-build.sh index 4c6e53bc..61a40b24 100755 --- a/test-tools/test-build.sh +++ b/test-tools/test-build.sh @@ -23,6 +23,7 @@ fi : ${HUGO_VERSION="0.54.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} +: ${SWIFT_VERSION="5.1.3"} BASE_PATH=$(pwd) REPO_PATH="$(cd $1 && pwd)" @@ -51,6 +52,7 @@ docker run --rm \ -e NETLIFY_VERBOSE \ -e GO_VERSION \ -e GO_IMPORT_PATH \ + -e SWIFT_VERSION \ -v "${REPO_PATH}:/opt/repo" \ -v "${BASE_PATH}/run-build.sh:/usr/local/bin/build" \ -v "${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh" \ From b455980763a6a17ad5208b3f2c2c862622f0cc78 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 11:50:50 +0000 Subject: [PATCH 04/26] Swift install --- Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Dockerfile b/Dockerfile index dfec151f..ad625416 100644 --- a/Dockerfile +++ b/Dockerfile @@ -469,6 +469,25 @@ ENV PATH "$PATH:/opt/buildhome/.dotnet" ENV DOTNET_ROOT "/opt/buildhome/.dotnet" #populate local package cache RUN dotnet new + + +################################################################################ +# +# Swift +# +################################################################################ +WORKDIR /tmp +RUN mkdir -p /opt/buildhome/.swift +RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig \ + && gpg --batch --quiet --keyserver ha.pool.sks-keyservers.net --recv-keys "$SWIFT_SIGNING_KEY" \ + && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ + && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ + && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ + && rm swift.tar.gz.sig swift.tar.gz +ENV PATH "$PATH:/opt/buildhome/.swift/usr/bin" +ENV SWIFT_ROOT "/opt/buildhome/.swift" +#populate local package cache +RUN swift --version WORKDIR / # Cleanup From 3512229863c60f3912c0b5bca34af982a1dbf545 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 11:56:47 +0000 Subject: [PATCH 05/26] Swift Env Vars Correction --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ad625416..dbc0aec7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -478,8 +478,8 @@ RUN dotnet new ################################################################################ WORKDIR /tmp RUN mkdir -p /opt/buildhome/.swift -RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_SIG_URL" -o swift.tar.gz.sig \ - && gpg --batch --quiet --keyserver ha.pool.sks-keyservers.net --recv-keys "$SWIFT_SIGNING_KEY" \ +ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" +RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig"" -o swift.tar.gz.sig \ && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ From 1b5ca2ef6a4fcf9f274092adbe8c984967abfb8c Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 11:59:20 +0000 Subject: [PATCH 06/26] Remove extra quote mark --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dbc0aec7..70a719d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -479,7 +479,7 @@ RUN dotnet new WORKDIR /tmp RUN mkdir -p /opt/buildhome/.swift ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" -RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig"" -o swift.tar.gz.sig \ +RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ From 91288385224680c8fad4a711dd86fb2b5f184df5 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 12:15:31 +0000 Subject: [PATCH 07/26] Temporarily skip verification of Swift --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 70a719d5..d240b6a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -480,7 +480,6 @@ WORKDIR /tmp RUN mkdir -p /opt/buildhome/.swift ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ - && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ && rm swift.tar.gz.sig swift.tar.gz From 5df930dd63e371551e3612091f437a5e59c0ea54 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 12:22:02 +0000 Subject: [PATCH 08/26] Reinstated GPG Swift checks --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d240b6a6..85143fe6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -479,14 +479,17 @@ RUN dotnet new WORKDIR /tmp RUN mkdir -p /opt/buildhome/.swift ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" +RUN wget -q -O - https://swift.org/keys/all-keys.asc | \ + gpg --import - RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ + && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ && rm swift.tar.gz.sig swift.tar.gz ENV PATH "$PATH:/opt/buildhome/.swift/usr/bin" ENV SWIFT_ROOT "/opt/buildhome/.swift" -#populate local package cache RUN swift --version + WORKDIR / # Cleanup From 9b922adc2a51dd8067d21383afd77ec354c3a3ba Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 12:22:41 +0000 Subject: [PATCH 09/26] Removed Swift keys from apt-key stages --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 85143fe6..b78a47e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ update-locale en_US.UTF-8 && \ apt-key adv --fetch-keys https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc && \ apt-key adv --fetch-keys https://packagecloud.io/github/git-lfs/gpgkey && \ - apt-key adv --fetch-keys https://swift.org/keys/all-keys.asc && \ apt-add-repository -y -s 'deb https://packagecloud.io/github/git-lfs/ubuntu/ xenial main' && \ add-apt-repository -y ppa:ondrej/php && \ add-apt-repository -y ppa:openjdk-r/ppa && \ From a22251ea7b306ad2f1031607113f756c252a54a8 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 12:30:08 +0000 Subject: [PATCH 10/26] Unsilencing cURL --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b78a47e4..1e5c8026 100644 --- a/Dockerfile +++ b/Dockerfile @@ -480,7 +480,7 @@ RUN mkdir -p /opt/buildhome/.swift ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" RUN wget -q -O - https://swift.org/keys/all-keys.asc | \ gpg --import - -RUN curl -fsSL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ +RUN curl -fsL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ From f0c33e390dd2ec0406312ef322f620870351d2bb Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 14:19:21 +0000 Subject: [PATCH 11/26] SPM/Swift Caching --- run-build-functions.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/run-build-functions.sh b/run-build-functions.sh index 04f7987e..22070296 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -39,6 +39,7 @@ mkdir -p $NETLIFY_CACHE_DIR/.bundle mkdir -p $NETLIFY_CACHE_DIR/bower_components mkdir -p $NETLIFY_CACHE_DIR/.venv mkdir -p $NETLIFY_CACHE_DIR/wapm_packages +mkdir -p $NETLIFY_CACHE_DIR/.build # HOME caches mkdir -p $NETLIFY_CACHE_DIR/.yarn_cache @@ -401,6 +402,20 @@ install_dependencies() { fi fi + # SPM dependencies + if [ -f Package.swift ] + then + echo "Building Swift Package" + restore_cwd_cache ".build" "spm cache" + if swift build + then + echo "Swift package Built" + else + echo "Error building Swift package" + exit 1 + fi + fi + # NPM Dependencies : ${YARN_VERSION="$defaultYarnVersion"} @@ -628,6 +643,7 @@ cache_artifacts() { cache_cwd_directory "node_modules" "node modules" cache_cwd_directory ".venv" "python virtualenv" cache_cwd_directory "wapm_packages", "wapm packages" + cache_cwd_directory ".build", "spm cache" cache_home_directory ".yarn_cache" "yarn cache" cache_home_directory ".cache" "pip cache" From 7b5ccb63ee4b6515f5d432887a957bbd417a1980 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 19:23:18 +0000 Subject: [PATCH 12/26] Minor Swift changes --- run-build-functions.sh | 4 ++-- test-tools/start-image.sh | 1 - test-tools/test-build.sh | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index 22070296..f35b05b5 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -406,7 +406,7 @@ install_dependencies() { if [ -f Package.swift ] then echo "Building Swift Package" - restore_cwd_cache ".build" "spm cache" + restore_cwd_cache ".build" "swift build" if swift build then echo "Swift package Built" @@ -643,7 +643,7 @@ cache_artifacts() { cache_cwd_directory "node_modules" "node modules" cache_cwd_directory ".venv" "python virtualenv" cache_cwd_directory "wapm_packages", "wapm packages" - cache_cwd_directory ".build", "spm cache" + cache_cwd_directory ".build", "swift build" cache_home_directory ".yarn_cache" "yarn cache" cache_home_directory ".cache" "pip cache" diff --git a/test-tools/start-image.sh b/test-tools/start-image.sh index 7b155881..63b7857e 100755 --- a/test-tools/start-image.sh +++ b/test-tools/start-image.sh @@ -11,7 +11,6 @@ docker run --rm -t -i \ -e HUGO_VERSION \ -e PHP_VERSION \ -e GO_VERSION \ - -e SWIFT_VERSION \ -v ${REPO_PATH}:/opt/repo \ -v ${BASE_PATH}/run-build.sh:/usr/local/bin/build \ -v ${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh \ diff --git a/test-tools/test-build.sh b/test-tools/test-build.sh index 61a40b24..f4928395 100755 --- a/test-tools/test-build.sh +++ b/test-tools/test-build.sh @@ -23,7 +23,6 @@ fi : ${HUGO_VERSION="0.54.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} -: ${SWIFT_VERSION="5.1.3"} BASE_PATH=$(pwd) REPO_PATH="$(cd $1 && pwd)" From af2d276f3f7a2aa84cab0ff092472b325ae90995 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 29 Dec 2019 19:50:40 +0000 Subject: [PATCH 13/26] Swift cachability --- run-build-functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index f35b05b5..0873a236 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -642,8 +642,8 @@ cache_artifacts() { cache_cwd_directory "bower_components" "bower components" cache_cwd_directory "node_modules" "node modules" cache_cwd_directory ".venv" "python virtualenv" - cache_cwd_directory "wapm_packages", "wapm packages" - cache_cwd_directory ".build", "swift build" + cache_cwd_directory "wapm_packages" "wapm packages" + cache_cwd_directory ".build" "swift build" cache_home_directory ".yarn_cache" "yarn cache" cache_home_directory ".cache" "pip cache" From e80ce69d13e4a9c83e1f336e12f14db7772610d9 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Tue, 31 Dec 2019 11:50:36 +0000 Subject: [PATCH 14/26] Remove SWIFT_VERSION parameter --- test-tools/test-build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test-tools/test-build.sh b/test-tools/test-build.sh index f4928395..4c6e53bc 100755 --- a/test-tools/test-build.sh +++ b/test-tools/test-build.sh @@ -51,7 +51,6 @@ docker run --rm \ -e NETLIFY_VERBOSE \ -e GO_VERSION \ -e GO_IMPORT_PATH \ - -e SWIFT_VERSION \ -v "${REPO_PATH}:/opt/repo" \ -v "${BASE_PATH}/run-build.sh:/usr/local/bin/build" \ -v "${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh" \ From af61e16ada8c13eb60caf1210dc103a528b41a15 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Fri, 3 Jan 2020 05:59:14 +0900 Subject: [PATCH 15/26] Added Swiftenv --- Dockerfile | 17 +++++------------ run-build-functions.sh | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1e5c8026..00b08c5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -475,18 +475,11 @@ RUN dotnet new # Swift # ################################################################################ -WORKDIR /tmp -RUN mkdir -p /opt/buildhome/.swift -ENV SWIFT_BIN_URL="https://swift.org/builds/swift-5.1.3-release/ubuntu1604/swift-5.1.3-RELEASE/swift-5.1.3-RELEASE-ubuntu16.04.tar.gz" -RUN wget -q -O - https://swift.org/keys/all-keys.asc | \ - gpg --import - -RUN curl -fsL "$SWIFT_BIN_URL" -o swift.tar.gz "$SWIFT_BIN_URL.sig" -o swift.tar.gz.sig \ - && gpg --batch --verify swift.tar.gz.sig swift.tar.gz \ - && tar -xzf swift.tar.gz --directory /opt/buildhome/.swift --strip-components=1 \ - && chmod -R o+r /opt/buildhome/.swift/usr/lib/swift \ - && rm swift.tar.gz.sig swift.tar.gz -ENV PATH "$PATH:/opt/buildhome/.swift/usr/bin" -ENV SWIFT_ROOT "/opt/buildhome/.swift" +USER buildbot +ENV SWIFTENV_ROOT="/opt/buildhome/.swiftenv" +RUN git clone --depth 1 https://github.com/kylef/swiftenv.git "$SWIFTENV_ROOT" +ENV PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" +RUN swiftenv install 5.1.3 RUN swift --version WORKDIR / diff --git a/run-build-functions.sh b/run-build-functions.sh index 0873a236..ca2e0778 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -17,6 +17,7 @@ export GIMME_CGO_ENABLED=true export NVM_DIR="$HOME/.nvm" export RVM_DIR="$HOME/.rvm" +export SWIFTENV_ROOT="${SWIFTENV_ROOT:-${HOME}/.swiftenv}" # Pipenv configuration export PIPENV_RUNTIME=2.7 @@ -402,6 +403,21 @@ install_dependencies() { fi fi + if [ -f .swift-version ] + then + SWIFT_VERSION=$(cat .swift-version) + echo "Attempting Swift version '$SWIFT_VERSION' from .swift-version" + fi + + if swiftenv install $SWIFT_VERSION + then + SWIFT_VERSION=$(swiftenv version) + export SWIFT_VERSION=$SWIFT_VERSION + else + echo "Failed to install Swift version '$SWIFT_VERSION'" + exit 1 + fi + # SPM dependencies if [ -f Package.swift ] then From aae1d180cab21798001bc7e66ca2e7cb5d9b213e Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sat, 4 Jan 2020 06:11:47 +0900 Subject: [PATCH 16/26] Use Swiftenv as part of build --- run-build-functions.sh | 6 +++++- run-build.sh | 3 ++- test-tools/start-image.sh | 1 + test-tools/test-build.sh | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index ca2e0778..3470f34e 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -164,6 +164,7 @@ install_dependencies() { local defaultYarnVersion=$3 local defaultPHPVersion=$4 local installGoVersion=$5 + local defaultSwiftVersion=$6 # Python Version if [ -f runtime.txt ] @@ -403,13 +404,16 @@ install_dependencies() { fi fi + # Swift Version + : ${SWIFT_VERSION="$defaultSwiftVersion"} if [ -f .swift-version ] then SWIFT_VERSION=$(cat .swift-version) echo "Attempting Swift version '$SWIFT_VERSION' from .swift-version" fi - if swiftenv install $SWIFT_VERSION + + if [ -f $SWIFTENV_ROOT/versions/$SWIFT_VERSION/usr/bin/swift ] || swiftenv install $SWIFT_VERSION then SWIFT_VERSION=$(swiftenv version) export SWIFT_VERSION=$SWIFT_VERSION diff --git a/run-build.sh b/run-build.sh index f3f9558d..01526125 100755 --- a/run-build.sh +++ b/run-build.sh @@ -23,9 +23,10 @@ cd $NETLIFY_REPO_DIR : ${YARN_VERSION="1.13.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} +: ${SWIFT_VERSION="5.1.3"} echo "Installing dependencies" -install_dependencies $NODE_VERSION $RUBY_VERSION $YARN_VERSION $PHP_VERSION $GO_VERSION +install_dependencies $NODE_VERSION $RUBY_VERSION $YARN_VERSION $PHP_VERSION $GO_VERSION $SWIFT_VERSION echo "Installing missing commands" install_missing_commands diff --git a/test-tools/start-image.sh b/test-tools/start-image.sh index 63b7857e..7b155881 100755 --- a/test-tools/start-image.sh +++ b/test-tools/start-image.sh @@ -11,6 +11,7 @@ docker run --rm -t -i \ -e HUGO_VERSION \ -e PHP_VERSION \ -e GO_VERSION \ + -e SWIFT_VERSION \ -v ${REPO_PATH}:/opt/repo \ -v ${BASE_PATH}/run-build.sh:/usr/local/bin/build \ -v ${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh \ diff --git a/test-tools/test-build.sh b/test-tools/test-build.sh index 4c6e53bc..61a40b24 100755 --- a/test-tools/test-build.sh +++ b/test-tools/test-build.sh @@ -23,6 +23,7 @@ fi : ${HUGO_VERSION="0.54.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} +: ${SWIFT_VERSION="5.1.3"} BASE_PATH=$(pwd) REPO_PATH="$(cd $1 && pwd)" @@ -51,6 +52,7 @@ docker run --rm \ -e NETLIFY_VERBOSE \ -e GO_VERSION \ -e GO_IMPORT_PATH \ + -e SWIFT_VERSION \ -v "${REPO_PATH}:/opt/repo" \ -v "${BASE_PATH}/run-build.sh:/usr/local/bin/build" \ -v "${BASE_PATH}/run-build-functions.sh:/usr/local/bin/run-build-functions.sh" \ From bf2d026acd070105100926663237d1c395f2a5ed Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sat, 4 Jan 2020 07:10:47 +0900 Subject: [PATCH 17/26] Swiftenv fixes --- Dockerfile | 2 +- run-build-functions.sh | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00b08c5f..f988ce4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -478,7 +478,7 @@ RUN dotnet new USER buildbot ENV SWIFTENV_ROOT="/opt/buildhome/.swiftenv" RUN git clone --depth 1 https://github.com/kylef/swiftenv.git "$SWIFTENV_ROOT" -ENV PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" +ENV PATH "$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" RUN swiftenv install 5.1.3 RUN swift --version diff --git a/run-build-functions.sh b/run-build-functions.sh index 3470f34e..929c4b1b 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -411,12 +411,10 @@ install_dependencies() { SWIFT_VERSION=$(cat .swift-version) echo "Attempting Swift version '$SWIFT_VERSION' from .swift-version" fi - if [ -f $SWIFTENV_ROOT/versions/$SWIFT_VERSION/usr/bin/swift ] || swiftenv install $SWIFT_VERSION then - SWIFT_VERSION=$(swiftenv version) - export SWIFT_VERSION=$SWIFT_VERSION + echo "Using Swift version $SWIFT_VERSION" else echo "Failed to install Swift version '$SWIFT_VERSION'" exit 1 From 84429f2183a621feb7a8c1e21eaa9fb790eb6ca6 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sat, 4 Jan 2020 07:15:47 +0900 Subject: [PATCH 18/26] Added Swift to included software docs --- included_software.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/included_software.md b/included_software.md index 7666f271..eaa77bb5 100644 --- a/included_software.md +++ b/included_software.md @@ -24,6 +24,9 @@ The specific patch versions included will depend on when the image was last buil * 7.4 * Go - `GO_VERSION` * 1.12 (default) +* Swift - `SWIFT_VERSION`, `.swift-version` + * 5.1.3 (default) + * Any version that `swiftenv` can install. * Java * 8 (default) * Emacs From 4fb88985178eb1cd308728038d277e7d5e63d043 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 5 Jan 2020 05:37:33 +0900 Subject: [PATCH 19/26] Used skip if installed swiftenv parameter --- run-build-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index 929c4b1b..001b9558 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -412,7 +412,7 @@ install_dependencies() { echo "Attempting Swift version '$SWIFT_VERSION' from .swift-version" fi - if [ -f $SWIFTENV_ROOT/versions/$SWIFT_VERSION/usr/bin/swift ] || swiftenv install $SWIFT_VERSION + if swiftenv install -s $SWIFT_VERSION then echo "Using Swift version $SWIFT_VERSION" else From 025453236513e54a90c2c9b6ab2cd8f2f0319a50 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Tue, 7 Jan 2020 05:41:01 +0900 Subject: [PATCH 20/26] Extracted out Docker Swift version to its own env variable --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f988ce4d..30aa2bd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -476,10 +476,11 @@ RUN dotnet new # ################################################################################ USER buildbot -ENV SWIFTENV_ROOT="/opt/buildhome/.swiftenv" +ENV SWIFTENV_SWIFT_VERSION 5.1.3 +ENV SWIFTENV_ROOT "/opt/buildhome/.swiftenv" RUN git clone --depth 1 https://github.com/kylef/swiftenv.git "$SWIFTENV_ROOT" ENV PATH "$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" -RUN swiftenv install 5.1.3 +RUN swiftenv install ${SWIFTENV_SWIFT_VERSION} RUN swift --version WORKDIR / From 3f270f07ed94a0fe78ef72d9bab64e0e03787f3a Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Tue, 7 Jan 2020 05:51:42 +0900 Subject: [PATCH 21/26] Removed extra space from run build script --- run-build-functions.sh | 26 ++++++++++++++++++++++++++ run-build.sh | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index 001b9558..7eade35c 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -33,6 +33,7 @@ NC="\033[0m" # No Color # language versions mkdir -p $NETLIFY_CACHE_DIR/node_version mkdir -p $NETLIFY_CACHE_DIR/ruby_version +mkdir -p $NETLIFY_CACHE_DIR/swift_version # pwd caches mkdir -p $NETLIFY_CACHE_DIR/node_modules @@ -411,6 +412,17 @@ install_dependencies() { SWIFT_VERSION=$(cat .swift-version) echo "Attempting Swift version '$SWIFT_VERSION' from .swift-version" fi + + swiftenv global ${SWIFT_VERSION} > /dev/null 2>&1 + export CUSTOM_SWIFT=$? + + if [ -d $NETLIFY_CACHE_DIR/swift_version/${SWIFT_VERSION} ] + then + echo "Started restoring cached Swift version" + rm -rf $SWIFTENV_ROOT/versions/$SWIFT_VERSION + cp -p -r $NETLIFY_CACHE_DIR/swift_version/${SWIFT_VERSION} $SWIFTENV_ROOT/versions/ + echo "Finished restoring cached Swift version" + fi if swiftenv install -s $SWIFT_VERSION then @@ -703,6 +715,20 @@ cache_artifacts() { else rm -rf $NETLIFY_CACHE_DIR/ruby_version fi + + # cache the version of Swift installed + if [[ "$CUSTOM_SWIFT" -ne "0" ]] + then + if ! [ -d $NETLIFY_CACHE_DIR/swift_version/$SWIFT_VERSION ] + then + rm -rf $NETLIFY_CACHE_DIR/swift_version + mkdir $NETLIFY_CACHE_DIR/swift_version + mv $SWIFTENV_ROOT/versions/$SWIFT_VERSION $NETLIFY_CACHE_DIR/swift_version/ + echo "Cached Swift version $SWIFT_VERSION" + fi + else + rm -rf $NETLIFY_CACHE_DIR/swift_version + fi } move_cache() { diff --git a/run-build.sh b/run-build.sh index 01526125..dda9d8ff 100755 --- a/run-build.sh +++ b/run-build.sh @@ -26,7 +26,7 @@ cd $NETLIFY_REPO_DIR : ${SWIFT_VERSION="5.1.3"} echo "Installing dependencies" -install_dependencies $NODE_VERSION $RUBY_VERSION $YARN_VERSION $PHP_VERSION $GO_VERSION $SWIFT_VERSION +install_dependencies $NODE_VERSION $RUBY_VERSION $YARN_VERSION $PHP_VERSION $GO_VERSION $SWIFT_VERSION echo "Installing missing commands" install_missing_commands From a300cdf72fa0f7db063d8d7db6bb7e8b16d52ea2 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Tue, 7 Jan 2020 06:38:32 +0900 Subject: [PATCH 22/26] Rehash cached Swift build --- run-build-functions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run-build-functions.sh b/run-build-functions.sh index 7eade35c..68d855a8 100755 --- a/run-build-functions.sh +++ b/run-build-functions.sh @@ -416,11 +416,12 @@ install_dependencies() { swiftenv global ${SWIFT_VERSION} > /dev/null 2>&1 export CUSTOM_SWIFT=$? - if [ -d $NETLIFY_CACHE_DIR/swift_version/${SWIFT_VERSION} ] + if [ -d $NETLIFY_CACHE_DIR/swift_version/$SWIFT_VERSION ] then echo "Started restoring cached Swift version" rm -rf $SWIFTENV_ROOT/versions/$SWIFT_VERSION cp -p -r $NETLIFY_CACHE_DIR/swift_version/${SWIFT_VERSION} $SWIFTENV_ROOT/versions/ + swiftenv rehash echo "Finished restoring cached Swift version" fi From d71ef1ec6ad6990e0d44117f1859ee16dc6fc3b9 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 1 Mar 2020 17:00:08 +0000 Subject: [PATCH 23/26] Removed unnecessary clang dependency --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 30aa2bd9..b464f0df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ bison \ build-essential \ bzr \ - clang \ cmake \ curl \ doxygen \ From c82fb196c2d993668df2d6d61dd1972cc09a390c Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Sun, 1 Mar 2020 17:10:33 +0000 Subject: [PATCH 24/26] Renamed env variable to NETLIFY_BUILD_SWIFT_VERSION, to be consistent with Node --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b464f0df..9f4f40e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -475,11 +475,11 @@ RUN dotnet new # ################################################################################ USER buildbot -ENV SWIFTENV_SWIFT_VERSION 5.1.3 +ENV NETLIFY_BUILD_SWIFT_VERSION 5.1.3 ENV SWIFTENV_ROOT "/opt/buildhome/.swiftenv" RUN git clone --depth 1 https://github.com/kylef/swiftenv.git "$SWIFTENV_ROOT" ENV PATH "$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" -RUN swiftenv install ${SWIFTENV_SWIFT_VERSION} +RUN swiftenv install ${NETLIFY_BUILD_SWIFT_VERSION} RUN swift --version WORKDIR / From 8893e9a03c938314391a8c22080ab5cd52f32fd9 Mon Sep 17 00:00:00 2001 From: Simon Rice Date: Thu, 26 Mar 2020 16:07:29 +0000 Subject: [PATCH 25/26] Swift 5.2 update --- Dockerfile | 2 +- included_software.md | 2 +- run-build.sh | 2 +- test-tools/test-build.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f4f40e2..f817d593 100644 --- a/Dockerfile +++ b/Dockerfile @@ -475,7 +475,7 @@ RUN dotnet new # ################################################################################ USER buildbot -ENV NETLIFY_BUILD_SWIFT_VERSION 5.1.3 +ENV NETLIFY_BUILD_SWIFT_VERSION 5.2 ENV SWIFTENV_ROOT "/opt/buildhome/.swiftenv" RUN git clone --depth 1 https://github.com/kylef/swiftenv.git "$SWIFTENV_ROOT" ENV PATH "$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH" diff --git a/included_software.md b/included_software.md index eaa77bb5..d176f284 100644 --- a/included_software.md +++ b/included_software.md @@ -25,7 +25,7 @@ The specific patch versions included will depend on when the image was last buil * Go - `GO_VERSION` * 1.12 (default) * Swift - `SWIFT_VERSION`, `.swift-version` - * 5.1.3 (default) + * 5.2 (default) * Any version that `swiftenv` can install. * Java * 8 (default) diff --git a/run-build.sh b/run-build.sh index dda9d8ff..996d06b2 100755 --- a/run-build.sh +++ b/run-build.sh @@ -23,7 +23,7 @@ cd $NETLIFY_REPO_DIR : ${YARN_VERSION="1.13.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} -: ${SWIFT_VERSION="5.1.3"} +: ${SWIFT_VERSION="5.2"} echo "Installing dependencies" install_dependencies $NODE_VERSION $RUBY_VERSION $YARN_VERSION $PHP_VERSION $GO_VERSION $SWIFT_VERSION diff --git a/test-tools/test-build.sh b/test-tools/test-build.sh index 61a40b24..e69dede6 100755 --- a/test-tools/test-build.sh +++ b/test-tools/test-build.sh @@ -23,7 +23,7 @@ fi : ${HUGO_VERSION="0.54.0"} : ${PHP_VERSION="5.6"} : ${GO_VERSION="1.12"} -: ${SWIFT_VERSION="5.1.3"} +: ${SWIFT_VERSION="5.2"} BASE_PATH=$(pwd) REPO_PATH="$(cd $1 && pwd)" From c31a76cf7f2dfbf8169504315f1f187d1334fc57 Mon Sep 17 00:00:00 2001 From: Benaiah Mischenko Date: Fri, 24 Apr 2020 14:52:43 -0700 Subject: [PATCH 26/26] Document that versions of Swift 4.x and older will not run --- included_software.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/included_software.md b/included_software.md index d176f284..565a1370 100644 --- a/included_software.md +++ b/included_software.md @@ -26,7 +26,7 @@ The specific patch versions included will depend on when the image was last buil * 1.12 (default) * Swift - `SWIFT_VERSION`, `.swift-version` * 5.2 (default) - * Any version that `swiftenv` can install. + * Any version that `swiftenv` can install newer than `4.x`. Versions `4.x` and below will not work due to incompatible shared libraries. * Java * 8 (default) * Emacs