From 2cbb0a97eeb4eea8ef18d59346759b20cc8fa180 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 13 May 2019 22:31:50 +0200 Subject: Adapt CI scripts to work under swift docker image --- Scripts/install_swiftlint.sh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'Scripts/install_swiftlint.sh') diff --git a/Scripts/install_swiftlint.sh b/Scripts/install_swiftlint.sh index 6a2f250..4b8299d 100755 --- a/Scripts/install_swiftlint.sh +++ b/Scripts/install_swiftlint.sh @@ -1,25 +1,11 @@ #!/bin/bash -# Taken from: https://alexplescan.com/posts/2016/03/03/setting-up-swiftlint-on-travis-ci/ - -# Installs the SwiftLint package. -# Tries to get the precompiled .pkg file from Github, but if that -# fails just recompiles from source. +# Installs SwiftLint from source (Intended to be used with +# swift docker image) set -e -SWIFTLINT_PKG_PATH="/tmp/SwiftLint.pkg" -SWIFTLINT_PKG_URL="https://github.com/realm/SwiftLint/releases/download/0.18.1/SwiftLint.pkg" - -wget --output-document=$SWIFTLINT_PKG_PATH $SWIFTLINT_PKG_URL - -if [ -f $SWIFTLINT_PKG_PATH ]; then - echo "SwiftLint package exists! Installing it..." - sudo installer -pkg $SWIFTLINT_PKG_PATH -target / -else - echo "SwiftLint package doesn't exist. Compiling from source..." && - git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint && - cd /tmp/SwiftLint && - git submodule update --init --recursive && - sudo make install -fi +git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint && +cd /tmp/SwiftLint && +git submodule update --init --recursive && +make install -- cgit From 6a628388c496987819ef26bda1a99595bce2b1d5 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 13 May 2019 23:22:58 +0200 Subject: Makes test environment docker-based Provides Dockerfile to build test environment that should be used by CI --- .gitlab-ci.yml | 8 +------- Dockerfile | 26 ++++++++++++++++++++++++++ Makefile | 9 ++++++++- Scripts/install_sourcekitten.sh | 10 ---------- Scripts/install_swiftlint.sh | 11 ----------- 5 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 Dockerfile delete mode 100755 Scripts/install_sourcekitten.sh delete mode 100755 Scripts/install_swiftlint.sh (limited to 'Scripts/install_swiftlint.sh') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d984cb..ebe400d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: swift:5.0.1 +image: lyriclitest/swift:5.0.1 stages: - lint @@ -11,12 +11,6 @@ cache: paths: - .build/ -before_script: - - apt install -y ruby ruby-dev libsqlite3-dev wget - - gem install jazzy - - "./Scripts/install_sourcekitten.sh" - - "./Scripts/install_swiftlint.sh" - lint: stage: lint script: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..db35f5c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +ARG swift_version=latest +FROM swift:${swift_version} + +RUN apt-get update && apt-get install -y \ + libsqlite3-dev \ + ruby \ + ruby-dev \ + wget \ + && rm -rf /var/lib/apt/lists/* + +RUN gem install --no-ri --no-rdoc jazzy + +# SourceKitten + +RUN git clone https://github.com/jpsim/SourceKitten.git /tmp/SourceKitten \ + && cd /tmp/SourceKitten \ + && make install \ + && rm -rf /tmp/SourceKitten + +# Swiftlint + +RUN git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint \ + && cd /tmp/SwiftLint \ + && git submodule update --init --recursive \ + && make install \ + && rm -rf /tmp/SwiftLint diff --git a/Makefile b/Makefile index 3066e11..d993480 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ target_binary_name = lrc install_path = /usr/local/bin source_binary_path = $(build_path)/$(configuration)/$(source_binary_name) install_binary_path = $(install_path)/$(target_binary_name) +swift_version = 5.0.1 # Default to release configuration on install install: configuration = release @@ -40,4 +41,10 @@ document: build clean: swift package clean -.PHONY: build install test clean lint +docker-build: + docker build --force-rm --build-arg swift_version=$(swift_version) -t lyriclitest/swift:$(swift_version) . + +docker-push: docker-build + docker push lyriclitest/swift:$(swift_version) + +.PHONY: build install test clean lint docker-build docker-push diff --git a/Scripts/install_sourcekitten.sh b/Scripts/install_sourcekitten.sh deleted file mode 100755 index f94fb53..0000000 --- a/Scripts/install_sourcekitten.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Installs SourceKitten from source (Intended to be used with -# swift docker image) - -set -e - -git clone https://github.com/jpsim/SourceKitten.git /tmp/SourceKitten && -cd /tmp/SourceKitten && -make install diff --git a/Scripts/install_swiftlint.sh b/Scripts/install_swiftlint.sh deleted file mode 100755 index 4b8299d..0000000 --- a/Scripts/install_swiftlint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Installs SwiftLint from source (Intended to be used with -# swift docker image) - -set -e - -git clone https://github.com/realm/SwiftLint.git /tmp/SwiftLint && -cd /tmp/SwiftLint && -git submodule update --init --recursive && -make install -- cgit