├── tests
├── library
│ ├── .swift-version
│ ├── .gitignore
│ ├── Sources
│ │ └── library
│ │ │ └── library.swift
│ ├── Tests
│ │ ├── LinuxMain.swift
│ │ └── libraryTests
│ │ │ └── libraryTests.swift
│ ├── .swiftlint.yml
│ ├── .jazzy.yaml
│ ├── Package.swift
│ └── Package@swift-4.swift
└── executable
│ ├── .swift-version
│ ├── .gitignore
│ ├── Sources
│ └── executable
│ │ └── main.swift
│ ├── Package.swift
│ ├── Package@swift-4.swift
│ └── .jazzy.yaml
├── img
├── file_screenshot.jpg
└── codecov-swift-cfenv-1024x768.png
├── lib
├── README.md
├── travis_fold.bash
├── travis_time_start.bash
├── travis_nanoseconds.bash
└── travis_time_finish.bash
├── .swiftlint.yml.disable
├── backup
├── .travis.yml.trigger
├── get_latest_xcodeproj.sh
├── travis_script.sh
├── script_travis.sh
├── package-build-trigger.sh
├── run-kitura-ubuntu-container.sh
├── generate_linux_main.sh
├── install_swift_binaries.sh
├── Makefile
├── build-package.sh
└── build-package-old.sh
├── scripts
├── README.md
├── Kitura-Repos.txt
└── setTravisVars.sh
├── xccov-to-sonarcloud-report.sh
├── .github
├── PULL_REQUEST_TEMPLATE.md
└── CONTRIBUTING.md
├── generate-xcodeproj.sh
├── linux
├── install_swift_from_url.sh
└── install_swift_binaries.sh
├── osx
└── install_swift_binaries.sh
├── codecov.sh
├── run_tests.sh
├── .travis.yml
├── jazzy.sh
├── sonarcloud.sh
├── install-swift.sh
├── LICENSE.txt
└── README.md
/tests/library/.swift-version:
--------------------------------------------------------------------------------
1 | 4.0.3
2 |
--------------------------------------------------------------------------------
/tests/executable/.swift-version:
--------------------------------------------------------------------------------
1 | 4.0.3
2 |
--------------------------------------------------------------------------------
/tests/library/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 |
--------------------------------------------------------------------------------
/tests/executable/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 |
--------------------------------------------------------------------------------
/img/file_screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kitura/Package-Builder/HEAD/img/file_screenshot.jpg
--------------------------------------------------------------------------------
/tests/executable/Sources/executable/main.swift:
--------------------------------------------------------------------------------
1 | /**
2 | Test jazzy
3 | */
4 | print("Hello, world!")
5 |
--------------------------------------------------------------------------------
/tests/library/Sources/library/library.swift:
--------------------------------------------------------------------------------
1 | struct Library {
2 |
3 | var text = "Hello, World!"
4 | }
5 |
--------------------------------------------------------------------------------
/img/codecov-swift-cfenv-1024x768.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kitura/Package-Builder/HEAD/img/codecov-swift-cfenv-1024x768.png
--------------------------------------------------------------------------------
/lib/README.md:
--------------------------------------------------------------------------------
1 | This directory includes Travis functions sourced from: https://github.com/travis-ci/travis-build/tree/master/lib/travis/build/bash
2 |
--------------------------------------------------------------------------------
/tests/library/Tests/LinuxMain.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | @testable import libraryTests
3 |
4 | XCTMain([
5 | testCase(LibraryTests.allTests)
6 | ])
7 |
--------------------------------------------------------------------------------
/lib/travis_fold.bash:
--------------------------------------------------------------------------------
1 | travis_fold() {
2 | local action="${1}"
3 | local name="${2}"
4 | echo -en "travis_fold:${action}:${name}\\r${ANSI_CLEAR}"
5 | }
6 |
--------------------------------------------------------------------------------
/tests/executable/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.0
2 | import PackageDescription
3 |
4 | let package = Package(
5 | name: "executable",
6 | targets: [
7 | .target(name: "executable", dependencies: []),
8 | ]
9 | )
10 |
--------------------------------------------------------------------------------
/tests/executable/Package@swift-4.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.0
2 | import PackageDescription
3 |
4 | let package = Package(
5 | name: "executable",
6 | targets: [
7 | .target(name: "executable", dependencies: []),
8 | ]
9 | )
10 |
--------------------------------------------------------------------------------
/lib/travis_time_start.bash:
--------------------------------------------------------------------------------
1 | travis_time_start() {
2 | TRAVIS_TIMER_ID="$(printf %08x $((RANDOM * RANDOM)))"
3 | TRAVIS_TIMER_START_TIME="$(travis_nanoseconds)"
4 | export TRAVIS_TIMER_ID TRAVIS_TIMER_START_TIME
5 | echo -en "travis_time:start:$TRAVIS_TIMER_ID\\r${ANSI_CLEAR}"
6 | }
7 |
--------------------------------------------------------------------------------
/tests/library/.swiftlint.yml:
--------------------------------------------------------------------------------
1 | disabled_rules: # rule identifiers to exclude from running
2 | - line_length
3 | - file_length
4 | - identifier_name
5 | - type_name
6 | - cyclomatic_complexity
7 |
8 | type_name:
9 | max_length: # warning and error
10 | warning: 60
11 | error: 80
12 |
--------------------------------------------------------------------------------
/lib/travis_nanoseconds.bash:
--------------------------------------------------------------------------------
1 | travis_nanoseconds() {
2 | local cmd='date'
3 | local format='+%s%N'
4 |
5 | if hash gdate >/dev/null 2>&1; then
6 | cmd='gdate'
7 | elif [[ "${TRAVIS_OS_NAME}" == osx ]]; then
8 | format='+%s000000000'
9 | fi
10 |
11 | "${cmd}" -u "${format}"
12 | }
13 |
--------------------------------------------------------------------------------
/tests/executable/.jazzy.yaml:
--------------------------------------------------------------------------------
1 | module: Package-Builder
2 | author: IBM
3 | github_url: https://github.com/Kitura/Package-Builder
4 |
5 | theme: fullwidth
6 | clean: true
7 |
8 | skip_undocumented: false
9 | hide_documentation_coverage: false
10 |
11 | xcodebuild_arguments: [-project, -target, Package-Builder]
12 |
--------------------------------------------------------------------------------
/tests/library/.jazzy.yaml:
--------------------------------------------------------------------------------
1 | module: Package-Builder
2 | author: IBM
3 | github_url: https://github.com/Kitura/Package-Builder
4 |
5 | theme: fullwidth
6 | clean: true
7 |
8 | skip_undocumented: false
9 | hide_documentation_coverage: false
10 |
11 | xcodebuild_arguments: [-project, Package-Builder.xcodeproj, -target, Package-Builder, LIBRARY_SEARCH_PATHS=.build/debug]
12 |
--------------------------------------------------------------------------------
/tests/library/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.0
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "library",
7 | products: [
8 | .library(name: "library", targets: ["library"]),
9 | ],
10 | targets: [
11 | .target(name: "library", dependencies: []),
12 | .testTarget(name: "libraryTests", dependencies: ["library"]),
13 | ]
14 | )
15 |
--------------------------------------------------------------------------------
/tests/library/Package@swift-4.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:4.0
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "library",
7 | products: [
8 | .library(name: "library", targets: ["library"]),
9 | ],
10 | targets: [
11 | .target(name: "library", dependencies: []),
12 | .testTarget(name: "libraryTests", dependencies: ["library"]),
13 | ]
14 | )
15 |
--------------------------------------------------------------------------------
/lib/travis_time_finish.bash:
--------------------------------------------------------------------------------
1 | travis_time_finish() {
2 | local result="${?}"
3 | local travis_timer_end_time
4 | travis_timer_end_time="$(travis_nanoseconds)"
5 | local duration
6 | duration="$((travis_timer_end_time - TRAVIS_TIMER_START_TIME))"
7 | echo -en "travis_time:end:${TRAVIS_TIMER_ID}:start=${TRAVIS_TIMER_START_TIME},finish=${travis_timer_end_time},duration=${duration}\\r${ANSI_CLEAR}"
8 | return "${result}"
9 | }
10 |
--------------------------------------------------------------------------------
/.swiftlint.yml.disable:
--------------------------------------------------------------------------------
1 | included:
2 | - Sources
3 |
4 | custom_rules:
5 | double_space:
6 | include: "*.swift"
7 | name: "Double space"
8 | regex: "([a-z,A-Z] \s+)"
9 | message: "Double space between keywords"
10 | match_kinds: keyword
11 | severity: warning
12 |
13 | line_length:
14 | warning: 250
15 | error: 500
16 |
17 | excluded: # paths to ignore during linting. Takes precedence over `included`.
18 | - Package-Builder
19 |
--------------------------------------------------------------------------------
/backup/.travis.yml.trigger:
--------------------------------------------------------------------------------
1 | # .travis.yml for Kitura Swift Packages
2 |
3 | sudo: true
4 |
5 | # whitelist
6 | branches:
7 | only:
8 | - master
9 | - develop
10 |
11 | before_install:
12 | - git submodule update --init --remote --merge --recursive
13 |
14 | script:
15 | - echo "About to trigger build for the Kitura repository..."
16 | - cd Kitura-Build && ./kitura-build-trigger.sh $TRAVIS_BRANCH $TRAVIS_TOKEN
17 | - echo "Request to build Kitura sent!"
18 |
--------------------------------------------------------------------------------
/scripts/README.md:
--------------------------------------------------------------------------------
1 | # Scripts
2 |
3 | Maintenance scripts for use when administering Kitura repositories.
4 |
5 | ### Kitura-Repos.txt
6 |
7 | A (manually maintained) list of repositories processed by scripts.
8 |
9 | ### setTravisVars.sh
10 |
11 | Automates the process of updating a Travis environment variable across repositories listed in `Kitura-Repos.txt`. The script **must** be customized prior to use. Requires the [Travis CLI](https://github.com/travis-ci/travis.rb#installation) to be installed.
12 |
--------------------------------------------------------------------------------
/tests/library/Tests/libraryTests/libraryTests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | @testable import library
3 |
4 | class LibraryTests: XCTestCase {
5 | func testExample() {
6 | // This is an example of a functional test case.
7 | // Use XCTAssert and related functions to verify your tests produce the correct results.
8 | XCTAssertEqual(Library().text, "Hello, World!")
9 | }
10 |
11 | static var allTests: [(String, (LibraryTests) -> () throws -> Void)] {
12 | return [
13 | ("testExample", testExample)
14 | ]
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/backup/get_latest_xcodeproj.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #/**
4 | #* Copyright IBM Corporation 2016
5 | #*
6 | #* Licensed under the Apache License, Version 2.0 (the "License");
7 | #* you may not use this file except in compliance with the License.
8 | #* You may obtain a copy of the License at
9 | #*
10 | #* http://www.apache.org/licenses/LICENSE-2.0
11 | #*
12 | #* Unless required by applicable law or agreed to in writing, software
13 | #* distributed under the License is distributed on an "AS IS" BASIS,
14 | #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | #* See the License for the specific language governing permissions and
16 | #* limitations under the License.
17 | #**/
18 | LIST=($(ls -td *.xcodeproj))
19 | basename ${LIST[0]} .xcodeproj
20 |
--------------------------------------------------------------------------------
/xccov-to-sonarcloud-report.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euo pipefail
3 |
4 | function convert_file {
5 | local xccovarchive_file="$1"
6 | local file_name="$2"
7 | echo " "
8 | xcrun xccov view --file "$file_name" "$xccovarchive_file" | \
9 | sed -n '
10 | s/^ *\([0-9][0-9]*\): 0.*$/ /p;
11 | s/^ *\([0-9][0-9]*\): [1-9].*$/ /p
12 | '
13 | echo ' '
14 | }
15 |
16 | function xccov_to_generic {
17 | echo ''
18 | for xccovarchive_file in "$@"; do
19 | xcrun xccov view --file-list "$xccovarchive_file" | while read -r file_name; do
20 | convert_file "$xccovarchive_file" "$file_name"
21 | done
22 | done
23 | echo ''
24 | }
25 |
26 | xccov_to_generic "$@"
--------------------------------------------------------------------------------
/scripts/Kitura-Repos.txt:
--------------------------------------------------------------------------------
1 | BlueCryptor
2 | BlueECC
3 | BlueRSA
4 | BlueSignals
5 | BlueSocket
6 | BlueSSLService
7 | CircuitBreaker
8 | CloudEnvironment
9 | Configuration
10 | FileKit
11 | Health
12 | HeliumLogger
13 | Kitura
14 | Kitura-Cache
15 | Kitura-Compression
16 | KituraContracts
17 | Kitura-CORS
18 | Kitura-CouchDB
19 | Kitura-Credentials
20 | Kitura-CredentialsFacebook
21 | Kitura-CredentialsGitHub
22 | Kitura-CredentialsGoogle
23 | Kitura-CredentialsHTTP
24 | Kitura-CredentialsJWT
25 | KituraKit
26 | Kitura-Markdown
27 | Kitura-MustacheTemplateEngine
28 | Kitura-net
29 | Kitura-NIO
30 | Kitura-OpenAPI
31 | Kitura-redis
32 | Kitura-Sample
33 | Kitura-Session
34 | Kitura-Session-Redis
35 | Kitura-StencilTemplateEngine
36 | Kitura-TemplateEngine
37 | Kitura-WebSocket
38 | Kitura-WebSocket-NIO
39 | LoggerAPI
40 | Swift-cfenv
41 | swift-html-entities
42 | Swift-JWT
43 | Swift-Kuery
44 | SwiftKueryMySQL
45 | Swift-Kuery-ORM
46 | Swift-Kuery-PostgreSQL
47 | Swift-Kuery-SQLite
48 | Swift-SMTP
49 | SwiftyRequest
50 | TypeDecoder
51 | Package-Builder
52 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Description
4 |
5 |
6 | ## Motivation and Context
7 |
8 |
9 |
10 | ## How Has This Been Tested?
11 |
12 |
13 |
14 |
15 | ## Checklist:
16 |
17 |
18 | - [ ] I have signed the [CLA form](https://gist.github.com/dannys42/528d534571b7d0d77a631555b71de970) (provided by [cla-assistant.io](https://cla-assistant.io))
19 | - [ ] If applicable, I have updated the documentation accordingly.
20 | - [ ] If applicable, I have added tests to cover my changes.
21 |
--------------------------------------------------------------------------------
/generate-xcodeproj.sh:
--------------------------------------------------------------------------------
1 | ##
2 | # Copyright IBM Corporation 2016,2017,2018
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | ##
16 |
17 | # Determine if there is a custom command for generating xcode project
18 | CUSTOM_XCODE_PROJ_GEN_CMD="${projectFolder}/.swift-xcodeproj"
19 | if [[ -f "$CUSTOM_XCODE_PROJ_GEN_CMD" ]]; then
20 | echo ">> Running custom xcodeproj command: $(cat $CUSTOM_XCODE_PROJ_GEN_CMD)"
21 | PROJ_OUTPUT=$(source "$CUSTOM_XCODE_PROJ_GEN_CMD")
22 | else
23 | PROJ_OUTPUT=$(swift package generate-xcodeproj)
24 | fi
25 |
26 | PROJ_EXIT_CODE=$?
27 | echo "$PROJ_OUTPUT"
28 | if [[ $PROJ_EXIT_CODE != 0 ]]; then
29 | exit 1
30 | fi
31 |
--------------------------------------------------------------------------------
/backup/travis_script.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # Script used to issue the compile commands for the Package-Builder repo from
20 | # the parent repo's.
21 |
22 | # If any commands fail, we want the shell script to exit immediately.
23 | set -e
24 |
25 | # Verify input params
26 | if [ "$#" -ne 4 ]; then
27 | echo "Usage: script_travis [TRAVIS_OS_NAME] [TRAVIS_BRANCH] [TRAVIS_BUILD_DIR] [PROJECT]"
28 | exit 1
29 | fi
30 |
31 | # Set variables
32 | os=$1
33 | branch=$2
34 | build_dir=$3
35 | project=$4
36 |
37 | echo ">> Let's build and test the '$branch' branch for $project."
38 |
39 | ./Package-Builder/build-package.sh $branch $build_dir
40 |
41 | echo ">> Build and tests completed. See above for status."
42 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | We welcome contributions, and request you follow these guidelines.
4 |
5 | - [Raising issues](#raising-issues)
6 | - [Contributor License Agreement](#contributor-license-agreement)
7 | - [Guidelines](#guidelines)
8 |
9 | ## Raising issues
10 |
11 | Please raise any bug reports on the issue tracker. Be sure to
12 | search the list to see if your issue has already been raised.
13 |
14 | A good bug report is one that make it easy for us to understand what you were
15 | trying to do and what went wrong. Provide as much context as possible so we can try to recreate the issue.
16 |
17 | ### Contributor License Agreement
18 |
19 | In order for us to accept pull-requests, the contributor must first complete a Contributor License Agreement (CLA). This clarifies the intellectual property license granted with any contribution. It is for your protection as a Contributor as well as the protection of IBM and its customers; it does not change your rights to use your own Contributions for any other purpose.
20 |
21 | Our CLA process is automated through a CLAassistant bot which comments on each Pull Request. Please click through the link in the comment to sign the CLA in your browser.
22 |
23 | ### Guidelines
24 |
25 | Please ensure you follow these guidelines:
26 |
27 | - All files must have the Apache license in the header.
28 | - All PRs must have passing builds.
29 |
--------------------------------------------------------------------------------
/backup/script_travis.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -x
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # Script used to issue the compile commands for the Kitura-Build repo from
20 | # the parent repo's.
21 |
22 | # If any commands fail, we want the shell script to exit immediately.
23 | set -e
24 |
25 | # Verify input params
26 | if [ "$#" -ne 4 ]; then
27 | echo "Usage: script_travis [TRAVIS_OS_NAME] [TRAVIS_BRANCH] [TRAVIS_BUILD_DIR] [PROJECT]"
28 | exit 1
29 | fi
30 |
31 | # Set variables
32 | os=$1
33 | branch=$2
34 | build_dir=$3
35 | project=$4
36 |
37 | echo ">> Let's build and test the '$branch' branch for $project."
38 | if [ $os == "linux" ];
39 | then
40 | ./Package-Builder/run-kitura-ubuntu-container.sh $branch $build_dir $project
41 | fi
42 | if [ $os == "osx" ];
43 | then
44 | ./Package-Builder/build-package-old.sh
45 | fi
46 | echo ">> Build and tests completed. See above for status."
47 |
48 |
--------------------------------------------------------------------------------
/backup/package-build-trigger.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | ## References for triggering builds using Travis CI API
20 | # https://docs.travis-ci.com/user/triggering-builds
21 | # https://api.travis-ci.org/repos/Kitura/Kitura.json
22 |
23 | # If any commands fail, we want the shell script to exit immediately.
24 | set -e
25 |
26 | # Verify input params
27 | if [ "$#" -ne 2 ]; then
28 | echo "Usage: kitura-build-trigger [branch] [travis token]"
29 | exit 1
30 | fi
31 |
32 | # Set variables
33 | branch=$1
34 | token=$2
35 |
36 | # Payload for HTTP POST request
37 | body='{
38 | "request": {
39 | "branch":"'$branch'"
40 | }
41 | }'
42 |
43 | # Trigger build for Kitura parent repo.
44 | # Kitura's Travis CI ID is 7666864.
45 | curl -s -X POST \
46 | -H "Content-Type: application/json" \
47 | -H "Accept: application/json" \
48 | -H "Travis-API-Version: 3" \
49 | -H "Authorization: token $token" \
50 | -d "$body" \
51 | https://api.travis-ci.org/repo/7666864/requests
52 |
--------------------------------------------------------------------------------
/linux/install_swift_from_url.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016,2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script installs the Swift binaries. The following variable
20 | # must be set for this script to work:
21 | # SWIFT_SNAPSHOT - version of the Swift binaries to install.
22 |
23 | # If any commands fail, we want the shell script to exit immediately.
24 | set -e
25 |
26 | # Echo commands before executing them.
27 | #set -o verbose
28 |
29 | echo ">> Running ${BASH_SOURCE[0]}"
30 |
31 | # Suppress prompts of any kind while executing apt-get
32 | export DEBIAN_FRONTEND="noninteractive"
33 |
34 | sudo -E apt-get -q update
35 | sudo -E apt-get -y -q install clang lldb-3.8 libicu-dev libtool libcurl4-openssl-dev libbsd-dev build-essential libssl-dev uuid-dev tzdata libz-dev libblocksruntime-dev
36 |
37 | echo ">> Installing '${SWIFT_SNAPSHOT}'..."
38 | # Install Swift compiler
39 | cd $projectFolder
40 | wget --progress=dot:giga $SWIFT_SNAPSHOT
41 | FILENAME=$(echo $SWIFT_SNAPSHOT | rev | cut -d/ -f1 | rev)
42 | tar xzf $FILENAME
43 | SWIFT_FOLDER=$(basename -s .tar.gz $FILENAME)
44 | export PATH=$projectFolder/$SWIFT_FOLDER/usr/bin:$PATH
45 | rm $FILENAME
46 |
--------------------------------------------------------------------------------
/osx/install_swift_binaries.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016, 2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script installs the Swift binaries on macOS.
20 |
21 | # If any commands fail, we want the shell script to exit immediately.
22 | set -e
23 |
24 | # Echo commands before executing them.
25 | #set -o verbose
26 |
27 | echo ">> Running ${BASH_SOURCE[0]}"
28 |
29 | # Install Swift binaries
30 | # See http://apple.stackexchange.com/questions/72226/installing-pkg-with-terminal
31 |
32 | # Install macOS system level dependencies if required
33 | if [ ! -x "`which wget`" ]; then
34 | brew update > /dev/null
35 | #brew install curl
36 | brew install wget > /dev/null || brew outdated wget > /dev/null || brew upgrade wget > /dev/null
37 | fi
38 |
39 | #Download and install Swift
40 | echo "Swift installed $SWIFT_PREINSTALL does not match snapshot $SWIFT_SNAPSHOT."
41 |
42 | file_path="builds/$SNAPSHOT_TYPE/xcode/$SWIFT_SNAPSHOT/$SWIFT_SNAPSHOT-osx.pkg"
43 | wget --progress=dot:giga "https://files.kitura.net/swift.org/${file_path}" || \
44 | wget --progress=dot:giga "https://swift.org/${file_path}"
45 |
46 | sudo installer -pkg $SWIFT_SNAPSHOT-osx.pkg -target /
47 | export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
48 | rm $SWIFT_SNAPSHOT-osx.pkg
49 |
--------------------------------------------------------------------------------
/backup/run-kitura-ubuntu-container.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script builds the corresponding Kitura Swift Package in a
20 | # Docker ubuntu container (Travis CI).
21 |
22 | # If any commands fail, we want the shell script to exit immediately.
23 | set -e
24 |
25 | # Parse input parameters
26 | # Determnine branch to build
27 | if [ -z "$1" ]
28 | then
29 | branch="develop"
30 | else
31 | branch=$1
32 | fi
33 | echo ">> branch: $branch"
34 |
35 | # Determine volume to mount from host to docker container
36 | # Determine command clause (project path)
37 | if [[ (-z "$2") && (-z "$3") ]]
38 | then
39 | volumeClause=""
40 | cmdClause=""
41 | else
42 | hostFolder=$2
43 | projectName=$3
44 | volumeClause="-v $hostFolder:/root/$projectName"
45 | cmdClause="/root/$projectName/Package-Builder/build-package-old.sh"
46 | fi
47 | echo ">> volumeClause: $volumeClause"
48 | echo ">> cmdClause: $cmdClause"
49 |
50 | # Pull down docker image
51 | docker pull ibmcom/kitura-ubuntu:latest
52 |
53 | # Run docker container
54 | # Please note that when a volume from the host is mounted on the container,
55 | # if the same folder already exists in the container, then it is replaced
56 | # with the contents from the host.
57 | docker run --rm -e KITURA_BRANCH=$branch $volumeClause ibmcom/kitura-ubuntu:latest $cmdClause
58 |
--------------------------------------------------------------------------------
/backup/generate_linux_main.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #/**
4 | #* Copyright IBM Corporation 2016
5 | #*
6 | #* Licensed under the Apache License, Version 2.0 (the "License");
7 | #* you may not use this file except in compliance with the License.
8 | #* You may obtain a copy of the License at
9 | #*
10 | #* http://www.apache.org/licenses/LICENSE-2.0
11 | #*
12 | #* Unless required by applicable law or agreed to in writing, software
13 | #* distributed under the License is distributed on an "AS IS" BASIS,
14 | #* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | #* See the License for the specific language governing permissions and
16 | #* limitations under the License.
17 | #**/
18 |
19 | PKG_DIR=.
20 | TESTS_DIR="${PKG_DIR}/Tests"
21 | OUTPUT_FILE=${TESTS_DIR}/LinuxMain.swift
22 |
23 | if ! [ -d "${TESTS_DIR}" ]; then
24 | echo "The directory containing the tests must be named Tests"
25 | exit 1
26 | fi
27 |
28 | cat << 'EOF' > ${OUTPUT_FILE}
29 | /**
30 | * Copyright IBM Corporation 2016
31 | *
32 | * Licensed under the Apache License, Version 2.0 (the "License");
33 | * you may not use this file except in compliance with the License.
34 | * You may obtain a copy of the License at
35 | *
36 | * http://www.apache.org/licenses/LICENSE-2.0
37 | *
38 | * Unless required by applicable law or agreed to in writing, software
39 | * distributed under the License is distributed on an "AS IS" BASIS,
40 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | * See the License for the specific language governing permissions and
42 | * limitations under the License.
43 | **/
44 |
45 | import XCTest
46 | EOF
47 |
48 | find ${TESTS_DIR} -maxdepth 1 -mindepth 1 -type d -printf '@testable import %fTestSuite\n' >> ${OUTPUT_FILE}
49 |
50 | echo >> ${OUTPUT_FILE}
51 | echo XCTMain\(\[ >> ${OUTPUT_FILE}
52 | for FILE in `find ${TESTS_DIR}/*/ -name "*.swift"`; do
53 | FILE_NAME=`basename ${FILE}`
54 | FILE_NAME="${FILE_NAME%.*}"
55 | echo " testCase(${FILE_NAME}.allTests)," >> ${OUTPUT_FILE}
56 | done
57 | echo "])" >> ${OUTPUT_FILE}
58 |
--------------------------------------------------------------------------------
/scripts/setTravisVars.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Bulk update script for Travis environment variables. This can be used to
4 | # set (or update) a common variable across many repos. It requires the Travis
5 | # command line to be installed.
6 | #
7 | # You may either log in manually using 'travis login', or set the GITHUB_TOKEN
8 | # environment variable to contain a GitHub personal access token, which will
9 | # be used to execute 'travis login' for you.
10 | #
11 |
12 | # The list of repositories to act on.
13 | REPOS=`cat Kitura-Repos.txt`
14 | REPO_COUNT=`echo $REPOS | wc -w`
15 |
16 | # The Travis environment variable to set (or updated)
17 | TRAVIS_ENV_VAR="SWIFT_DEVELOPMENT_SNAPSHOT"
18 |
19 | # The value to be set
20 | TRAVIS_ENV_VALUE="swift-DEVELOPMENT-SNAPSHOT-2018-11-25-a"
21 |
22 | # The type of var: public is visible, private is hidden (eg. for credentials)
23 | TRAVIS_ENV_TYPE="public"
24 |
25 | SUCCESS="" # List of successful updates
26 | FAIL="" # List of failed updates
27 |
28 | # Builds a list of repositories that failed to update (if any)
29 | function fail {
30 | FAIL="$FAIL $REPO" && echo "$REPO: FAILED"
31 | return 1
32 | }
33 |
34 | # Check that current user is logged in to Travis
35 | echo "Checking Travis login status:"
36 | if ! travis accounts; then
37 | # Try to log in
38 | if [ -z "${GITHUB_TOKEN}" ]; then
39 | echo "Error: either log in, or define GITHUB_TOKEN for Travis login"
40 | exit 1
41 | fi
42 | travis login --org --github-token "${GITHUB_TOKEN}" || exit 1
43 | fi
44 |
45 | # Confirm actions before proceeding
46 | echo "You are about set $TRAVIS_ENV_VAR to $TRAVIS_ENV_VALUE (value is $TRAVIS_ENV_TYPE) for $REPO_COUNT repos."
47 | echo "Do you want to continue? [y/N]"
48 | read answer
49 | if [ "y" != "$answer" ]; then
50 | exit 1
51 | fi
52 |
53 | # Set environment for each repo
54 | for REPO in $REPOS; do
55 | echo "Setting ${TRAVIS_ENV_VAR}=${TRAVIS_ENV_VALUE} on ${REPO}"
56 | travis env set "${TRAVIS_ENV_VAR}" "${TRAVIS_ENV_VALUE}" --repo Kitura/${REPO} --${TRAVIS_ENV_TYPE} || fail || continue
57 | SUCCESS="$SUCCESS $REPO"
58 | done
59 |
60 | # Indicate which operations were successful and which failed
61 | echo Success: $SUCCESS
62 | echo Failed: $FAIL
63 | exit
64 |
--------------------------------------------------------------------------------
/codecov.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016,2017,2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | if [[ $TRAVIS_BRANCH != "master" && $TRAVIS_BRANCH != "develop" && $TRAVIS_EVENT_TYPE != "cron" ]]; then
20 | echo "Not master, develop or cron build. Skipping code coverage generation."
21 | exit 0
22 | fi
23 |
24 | echo ">> Starting code coverage analysis..."
25 | uname -a
26 |
27 | SDK=macosx
28 | xcodebuild -version
29 | xcodebuild -version -sdk $SDK
30 | if [[ $? != 0 ]]; then
31 | exit 1
32 | fi
33 |
34 | # Determine if there is a custom command for generating xcode project
35 | source ./Package-Builder/generate-xcodeproj.sh
36 |
37 | # Determine if there is a custom command for xcode build (code coverage tests)
38 | if [ -e ${projectFolder}/.swift-codecov ]; then
39 | XCODE_BUILD_CMD=$(cat ${projectFolder}/.swift-codecov)
40 | else
41 | PROJECT="${PROJ_OUTPUT##*/}"
42 | SCHEME=$(xcodebuild -list -project $PROJECT | grep --after-context=1 '^\s*Schemes:' | tail -n 1 | xargs)
43 | XCODE_BUILD_CMD="xcodebuild -quiet -project $PROJECT -scheme $SCHEME -sdk $SDK -enableCodeCoverage YES -skipUnavailableActions test"
44 | fi
45 |
46 | echo ">> Running: $XCODE_BUILD_CMD"
47 | eval "$XCODE_BUILD_CMD"
48 | if [[ $? != 0 ]]; then
49 | exit 1
50 | fi
51 |
52 | (( MODULE_COUNT = 0 ))
53 | BASH_BASE="bash <(curl -s https://codecov.io/bash)"
54 | for module in $(ls -F Sources/ 2>/dev/null | grep '/$'); do # get only directories in "Sources/"
55 | module=${module%/} # remove trailing slash
56 | BASH_CMD="$BASH_BASE -J '^${module}\$' -F '${module}'"
57 | (( MODULE_COUNT++ ))
58 |
59 | echo ">> Running: $BASH_CMD"
60 | eval "$BASH_CMD"
61 | if [[ $? != 0 ]]; then
62 | echo ">> Error running: $BASH_CMD"
63 | exit 1
64 | fi
65 | done
66 |
67 | if (( MODULE_COUNT == 0 )); then
68 | echo ">> Running: $BASH_BASE"
69 | eval "$BASH_BASE"
70 | if [[ $? != 0 ]]; then
71 | echo ">> Error running: $BASH_BASE"
72 | exit 1
73 | fi
74 | fi
75 |
76 | echo ">> Finished code coverage analysis."
77 |
--------------------------------------------------------------------------------
/run_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016,2017,2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | set +e # do not exit immediately temporarily so we can generate a backtrace for any crash
20 | ulimit -c unlimited # enable core file generation
21 | # Custom test scripts are not folded, as folding cannot be nested. Folding should be
22 | # implemented from within the custom script itself.
23 | if [ -n "${CUSTOM_TEST_SCRIPT}" ] && [ -e ${projectFolder}/$CUSTOM_TEST_SCRIPT ]; then
24 | echo ">> Running custom test command: $CUSTOM_TEST_SCRIPT"
25 | source ${projectFolder}/$CUSTOM_TEST_SCRIPT
26 | elif [ -e ${projectFolder}/.swift-test-macOS ] && [ "$osName" == "osx" ]; then
27 | echo ">> Running custom macOS test command: ${projectFolder}/.swift-test-macOS"
28 | source ${projectFolder}/.swift-test-macOS
29 | elif [ -e ${projectFolder}/.swift-test-linux ] && [ "$osName" == "linux" ]; then
30 | echo ">> Running custom Linux test command: ${projectFolder}/.swift-test-linux"
31 | source ${projectFolder}/.swift-test-linux
32 | else
33 | travis_start "swift_test"
34 | echo ">> Running test command: swift test ${SWIFT_TEST_ARGS}"
35 | swift test ${SWIFT_TEST_ARGS}
36 | SWIFT_TEST_STATUS=$?
37 | travis_end
38 | (exit $SWIFT_TEST_STATUS) # Ensure TEST_EXIT_CODE reflects swift test, not travis_end!
39 | fi
40 | TEST_EXIT_CODE=$?
41 |
42 | if [[ $TEST_EXIT_CODE != 0 ]]; then
43 | travis_start "swift_test_backtrace"
44 | if [ "$osName" == "osx" ]; then
45 | executable=`ls .build/debug/*Tests.xctest/Contents/MacOS/*Tests`
46 | coreFile=`ls -t /cores/* | head -n1`
47 | else
48 | executable=`ls .build/debug/*Tests.xctest`
49 | coreFile='./core'
50 | fi
51 |
52 | if [ ! -f "$coreFile" ]; then
53 | echo ">> Core file '$coreFile' not found."
54 | elif [ ! -x "$executable" ]; then
55 | echo ">> '$executable' not found or not an executable."
56 | lldb -c "$coreFile" --batch -o 'thread backtrace all' -o 'quit'
57 | else
58 | lldb "$executable" -c "$coreFile" --batch -o 'thread backtrace all' -o 'quit'
59 | fi
60 | travis_end
61 |
62 | exit $TEST_EXIT_CODE
63 | fi
64 |
65 | set -e
66 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Travis CI build file for Package-Builder.
2 | # Package-Builder runs on OS X and Linux (Ubuntu).
3 |
4 | # whitelist (branches that should be built)
5 | branches:
6 | only:
7 | - master
8 | - develop
9 | - /^issue.*$/
10 |
11 | matrix:
12 | include:
13 | - os: linux
14 | dist: trusty
15 | sudo: required
16 | # Tested by tests .swift-version
17 | # env: SWIFT_SNAPSHOT=4.0.3
18 | - os: linux
19 | dist: xenial
20 | sudo: required
21 | env: SWIFT_SNAPSHOT=4.1.3
22 | - os: linux
23 | dist: xenial
24 | sudo: required
25 | services: docker
26 | env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
27 | - os: linux
28 | dist: trusty
29 | sudo: required
30 | env: DOCKER_IMAGE=ubuntu:14.04 SWIFT_SNAPSHOT=5.0.3
31 | - os: linux
32 | dist: xenial
33 | sudo: required
34 | services: docker
35 | env: DOCKER_IMAGE=swift:5.0.3-xenial SWIFT_SNAPSHOT=5.0.3
36 | - os: linux
37 | dist: xenial
38 | sudo: required
39 | services: docker
40 | env: DOCKER_IMAGE=swift:5.1 SWIFT_SNAPSHOT=5.1
41 | - os: linux
42 | dist: xenial
43 | sudo: required
44 | services: docker
45 | env: DOCKER_IMAGE=swift:5.1 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
46 | - os: osx
47 | osx_image: xcode9.2
48 | sudo: required
49 | # Tested by tests .swift-version
50 | # env: SWIFT_SNAPSHOT=4.0.3
51 | - os: osx
52 | osx_image: xcode9.4
53 | sudo: required
54 | env: SWIFT_SNAPSHOT=4.1.2
55 | - os: osx
56 | osx_image: xcode10.1
57 | sudo: required
58 | env: SWIFT_SNAPSHOT=4.2.1
59 | - os: osx
60 | osx_image: xcode10.2
61 | sudo: required
62 | env: SWIFT_SNAPSHOT=5.0.1 JAZZY_ELIGIBLE=true
63 | - os: osx
64 | osx_image: xcode11
65 | sudo: required
66 | env: SWIFT_SNAPSHOT=5.1
67 | - os: osx
68 | osx_image: xcode11
69 | sudo: required
70 | env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
71 |
72 | script:
73 | # Set up build structure for test projects
74 | - mv tests/library ../library
75 | - mv tests/executable ../executable
76 | - cp -R ./ ../library/Package-Builder
77 | - cp -R ./ ../executable/Package-Builder
78 | - cp -R ../executable ../executable-no-swift-version
79 | - rm ../executable-no-swift-version/.swift-version
80 | # This tests Package-Builder with a library
81 | - cd ../library
82 | - ./Package-Builder/build-package.sh -projectDir $PWD
83 | # This tests Package-Builder with an executable
84 | - cd ../executable
85 | - ./Package-Builder/build-package.sh -projectDir $PWD
86 | # Test building a package that does not have a .swift-version file
87 | - cd ../executable-no-swift-version
88 | - ./Package-Builder/build-package.sh -projectDir $PWD
89 |
--------------------------------------------------------------------------------
/backup/install_swift_binaries.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script installs the Swift binaries. The following environment variables
20 | # must be set for this script to work:
21 | # SWIFT_SNAPSHOT - version of the Swift binaries to install.
22 | # UBUNTU_VERSION - Linux Ubuntu version for the Swift binaries.
23 | # UBUNTU_V ERSION_NO_DOTS - Linux Ubuntu version for the Swift binaries (no dots).
24 | # WORK_DIR - The working directory for the installation.
25 |
26 | # If any commands fail, we want the shell script to exit immediately.
27 | set -e
28 |
29 | # Environment vars
30 | version=`lsb_release -d | awk '{print tolower($2) $3}'`
31 | export UBUNTU_VERSION=`echo $version | awk -F. '{print $1"."$2}'`
32 | export UBUNTU_VERSION_NO_DOTS=`echo $version | awk -F. '{print $1$2}'`
33 |
34 | if [ -d "${WORK_DIR}/${SWIFT_SNAPSHOT}-${UBUNTU_VERSION}" ]; then
35 | echo ">> Swift binaries '${SWIFT_SNAPSHOT}' are already installed."
36 | else
37 | echo ">> Installing '${SWIFT_SNAPSHOT}'..."
38 | # Remove from PATH any references to previous versions of the Swift binaries
39 | for INSTALL_DIR in `find $WORK_DIR -type d -iname 'swift-DEVELOPMENT-SNAPSHOT-*'`;
40 | do
41 | export PATH=${PATH#${INSTALL_DIR}}
42 | done
43 | # Remove any older versions of the Swift binaries from the file system
44 | find $WORK_DIR -name 'swift-DEVELOPMENT-SNAPSHOT-*' | xargs rm -rf
45 | # Install Swift compiler
46 | cd $WORK_DIR
47 | wget https://swift.org/builds/development/$UBUNTU_VERSION_NO_DOTS/$SWIFT_SNAPSHOT/$SWIFT_SNAPSHOT-$UBUNTU_VERSION.tar.gz
48 | tar xzvf $SWIFT_SNAPSHOT-$UBUNTU_VERSION.tar.gz
49 | export PATH=$WORK_DIR/$SWIFT_SNAPSHOT-$UBUNTU_VERSION/usr/bin:$PATH
50 | swiftc -h
51 | # Clone and install swift-corelibs-libdispatch
52 | echo ">> Installing swift-corelibs-libdispatch..."
53 | # Remove any older versions of the Swift binaries from the file system
54 | find $WORK_DIR -name 'swift-corelibs-libdispatch' | xargs rm -rf
55 | git clone -b experimental/foundation https://github.com/apple/swift-corelibs-libdispatch.git
56 | cd swift-corelibs-libdispatch && git submodule init && git submodule update && sh ./autogen.sh && CFLAGS=-fuse-ld=gold ./configure --with-swift-toolchain=$WORK_DIR/$SWIFT_SNAPSHOT-$UBUNTU_VERSION/usr --prefix=$WORK_DIR/$SWIFT_SNAPSHOT-$UBUNTU_VERSION/usr && make && make install
57 | # Return to previous directory
58 | cd -
59 | fi
60 |
--------------------------------------------------------------------------------
/backup/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright IBM Corporation 2016
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Makefile
16 |
17 | ifndef BUILDER_SCRIPTS_DIR
18 | BUILDER_SCRIPTS_DIR = .
19 | endif
20 |
21 | UNAME := ${shell uname}
22 | SPECIAL_MAC_FILE_EXISTS := $(shell [ -e $(CURDIR)/.swift-build-macOS ] && echo 1 || echo 0 )
23 | OS_IS_MAC := $(shell [ "$(UNAME)" = "Darwin" ] && echo 1 || echo 0 )
24 | SPECIAL_LINUX_FILE_EXISTS := $(shell [ -e $(CURDIR)/.swift-build-linux ] && echo 1 || echo 0 )
25 | OS_IS_LINUX := $(shell [ "$(UNAME)" = "Linux" ] && echo 1 || echo 0 )
26 |
27 | all: buildDebug
28 |
29 | buildDebug:
30 | make SWIFT_BUILD_CONFIGURATION="debug" SWIFTC_FLAGS="-Xswiftc -DDEBUG" _build
31 |
32 | buildRelease:
33 | make SWIFT_BUILD_CONFIGURATION="release" _build
34 |
35 | build: buildDebug
36 |
37 | _build: custombuild
38 | @echo --- Running build on $(UNAME)
39 | @echo --- Build scripts directory: ${BUILDER_SCRIPTS_DIR}
40 | @echo --- Checking swift version
41 | swift --version
42 | @echo --- Checking swiftc version
43 | swiftc --version
44 | @echo --- Checking git version
45 | git --version
46 | @echo --- Checking git revision and branch
47 | -git rev-parse HEAD
48 | -git rev-parse --abbrev-ref HEAD
49 | ifeq ($(UNAME), Linux)
50 | @echo --- Checking Linux release
51 | -lsb_release -d
52 | endif
53 | @echo --- Invoking swift build
54 |
55 | ifeq ($(SPECIAL_MAC_FILE_EXISTS)$(OS_IS_MAC), 11)
56 | bash $(CURDIR)/.swift-build-macOS
57 | else
58 | ifeq ($(SPECIAL_LINUX_FILE_EXISTS)$(OS_IS_LINUX), 11)
59 | bash $(CURDIR)/.swift-build-linux
60 | else
61 | swift build -c ${SWIFT_BUILD_CONFIGURATION} $(SWIFTC_FLAGS)
62 | endif
63 | endif
64 |
65 | Tests/LinuxMain.swift:
66 | ifeq ($(UNAME), Linux)
67 | @echo --- Generating $@
68 | bash ${BUILDER_SCRIPTS_DIR}/generate_linux_main.sh
69 | endif
70 |
71 | test: build Tests/LinuxMain.swift
72 | @echo --- Invoking swift test
73 | swift test
74 |
75 | refetch:
76 | @echo --- Removing Packages directory
77 | rm -rf Packages
78 | @echo --- Fetching dependencies
79 | swift package fetch
80 |
81 | update:
82 | @echo --- Updating dependencies
83 | swift package update
84 |
85 | clean: customClean
86 | @echo --- Invoking swift build --clean
87 | -swift build --clean
88 | rm -rf .build
89 |
90 | generateXcode: build
91 | swift package generate-xcodeproj
92 |
93 | openXcode: generateXcode
94 | open ${shell bash ${BUILDER_SCRIPTS_DIR}/get_latest_xcodeproj.sh}.xcodeproj
95 |
96 | custombuild: # do nothing - for the calling Makefile to override
97 | customClean: # do nothing - for the calling Makefile to override
98 |
99 | .PHONY: clean build update refetch run test custombuild openXcode generateXcode
100 |
--------------------------------------------------------------------------------
/jazzy.sh:
--------------------------------------------------------------------------------
1 | ##
2 | # Copyright IBM Corporation 2016,2017,2018
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | ##
16 |
17 | # Check that we have credentials. In addition to the username and password,
18 | # we require an e-mail address for configuring our user when pushing docs
19 | # updates back to Github.
20 | if [ -z "${GITHUB_USERNAME}" -o -z "${GITHUB_PASSWORD}" -o -z "${GITHUB_EMAIL}" ]; then
21 | echo "Supplied jazzy docs flag, but credentials were not provided."
22 | echo "Expected: GITHUB_USERNAME, GITHUB_PASSWORD and GITHUB_EMAIL Env variables."
23 | exit 1
24 | fi
25 |
26 | # Check that projectFolder and SCRIPT_DIR exist. These should have been set
27 | # by the calling script (build-package.sh)
28 | if [ -z "${projectFolder}" ]; then
29 | projectFolder="$pwd"
30 | echo "Warning: projectFolder not set. Defaulting to pwd ($projectFolder)"
31 | fi
32 |
33 | if [ -z "${SCRIPT_DIR}" ]; then
34 | # Determine location of this script
35 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
36 | echo "Warning: SCRIPT_DIR not set. Defaulting to current script location ($SCRIPT_DIR}"
37 | fi
38 |
39 | # Check if .jazzy.yaml exists in the root folder of the repo. If we do not find
40 | # it, fail the build because the build explicitly requested docs generation.
41 | if [ ! -f "${projectFolder}/.jazzy.yaml" ]; then
42 | echo ".jazzy.yaml file does not exist"
43 | exit 1
44 | fi
45 |
46 | # Checkout to the current branch. The repo cloned by Travis is a shallow clone,
47 | # so we cannot check out the branch directly. Instead, create a new remote for
48 | # this purpose and checkout the branch from there.
49 | git remote add jazzy https://${GITHUB_USERNAME}:${GITHUB_PASSWORD}@github.com/${TRAVIS_REPO_SLUG}.git
50 | git fetch jazzy
51 | git checkout jazzy/${TRAVIS_PULL_REQUEST_BRANCH} -b ${TRAVIS_PULL_REQUEST_BRANCH}
52 |
53 | # Check whether the latest commit is itself a jazzy-doc commit, and bail out if
54 | # so. Otherwise, we would loop indefinitely creating documentation commits.
55 | LATEST_COMMIT_MESSAGE=`git log -1 --oneline`
56 | GIT_SUCCESS=$?
57 | if [ $GIT_SUCCESS -ne 0 -o -z "${LATEST_COMMIT_MESSAGE}" ]; then
58 | echo "Failed to get latest commit message - aborting."
59 | exit 1
60 | fi
61 | if [[ "${LATEST_COMMIT_MESSAGE}" =~ "[jazzy-doc]" ]]; then
62 | echo "Skipping jazzy-doc generation: latest commit is a jazzy-doc commit."
63 | exit 0
64 | fi
65 |
66 | # Install a specific version of jazzy (0.9.6 supports Swift 5). Future versions may also be fine,
67 | # but their output should be checked before upgrading.
68 | sudo gem install jazzy -v 0.9.6
69 | # Generate xcode project
70 | sourceScript "${SCRIPT_DIR}/generate-xcodeproj.sh" "xcodeproj generation"
71 | # Run jazzy
72 | jazzy
73 |
74 | # Configure user
75 | git config --global --add user.name Auto-Jazzy
76 | git config --global --add user.email ${GITHUB_EMAIL}
77 | git config --global --add push.default simple
78 |
79 | # Push the updated docs as a new commit to the PR branch
80 | git add docs/.
81 | git commit -m '[jazzy-doc] Documentation update'
82 | git push
83 |
--------------------------------------------------------------------------------
/linux/install_swift_binaries.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016,2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This should not be necessary anymore for Linux
20 | exit 0
21 |
22 | # This script installs the Swift binaries. The following variable
23 | # must be set for this script to work:
24 | # SWIFT_SNAPSHOT - version of the Swift binaries to install.
25 |
26 | # If any commands fail, we want the shell script to exit immediately.
27 | set -e
28 |
29 | # Echo commands before executing them.
30 | #set -o verbose
31 |
32 | echo ">> Running ${BASH_SOURCE[0]}"
33 |
34 | # Suppress prompts of any kind while executing apt-get
35 | export DEBIAN_FRONTEND="noninteractive"
36 |
37 | # Find the first numeric value in the swift version string. For example:
38 | # swift-5.0-DEVELOPMENT-SNAPSHOT-1234-56-78-a -> 5
39 | # 4.0.3 -> 4
40 | swiftMajor=`echo $SWIFT_SNAPSHOT | sed -e's#[^0-9]*\([0-9]\).*#\1#'`
41 |
42 | # Get the Ubuntu ID and VERSION_ID from /etc/os-release, stripping quotes
43 | distribution=`grep '^ID=' /etc/os-release | sed -e's#.*="\?\([^"]*\)"\?#\1#'`
44 | version=`grep '^VERSION_ID=' /etc/os-release | sed -e's#.*="\?\([^"]*\)"\?#\1#'`
45 | version_no_dots=`echo $version | awk -F. '{print $1$2}'`
46 | versionMajor=`echo $version | awk -F. '{print $1}'`
47 | export UBUNTU_VERSION="${distribution}${version}"
48 | export UBUNTU_VERSION_NO_DOTS="${distribution}${version_no_dots}"
49 |
50 | # Customize package dependencies based on Ubuntu version
51 | case $versionMajor in
52 | 14)
53 | libCurlPackage="libcurl3"
54 | gccPackageVersion="4.8"
55 | ;;
56 | 15|16|17)
57 | libCurlPackage="libcurl3"
58 | gccPackageVersion="5"
59 | ;;
60 | *)
61 | libCurlPackage="libcurl4"
62 | gccPackageVersion="5"
63 | ;;
64 | esac
65 |
66 | # Install prerequisites for this version of Swift
67 | sudo -E apt-get -q update
68 | case $swiftMajor in
69 | 3|4)
70 | sudo -E apt-get -y -q install \
71 | libcurl4-openssl-dev \
72 | libssl-dev \
73 | clang \
74 | lldb-3.8 \
75 | libicu-dev \
76 | libtool \
77 | libbsd-dev \
78 | build-essential \
79 | uuid-dev \
80 | tzdata \
81 | libz-dev \
82 | libblocksruntime-dev
83 | ;;
84 | *)
85 | sudo -E apt-get -y -q install \
86 | libcurl4-openssl-dev \
87 | libssl-dev \
88 | libatomic1 \
89 | libbsd0 \
90 | ${libCurlPackage} \
91 | libxml2 \
92 | libedit2 \
93 | libsqlite3-0 \
94 | libc6-dev \
95 | binutils \
96 | libgcc-${gccPackageVersion}-dev \
97 | libstdc++-${gccPackageVersion}-dev \
98 | libpython2.7 \
99 | tzdata \
100 | pkg-config
101 | ;;
102 | esac
103 |
104 | echo ">> Installing '${SWIFT_SNAPSHOT}'..."
105 | # Install Swift compiler
106 | cd $projectFolder
107 | wget --progress=dot:giga https://swift.org/builds/$SNAPSHOT_TYPE/$UBUNTU_VERSION_NO_DOTS/$SWIFT_SNAPSHOT/$SWIFT_SNAPSHOT-$UBUNTU_VERSION.tar.gz
108 | tar xzf $SWIFT_SNAPSHOT-$UBUNTU_VERSION.tar.gz
109 | export PATH=$projectFolder/$SWIFT_SNAPSHOT-$UBUNTU_VERSION/usr/bin:$PATH
110 | rm $SWIFT_SNAPSHOT-$UBUNTU_VERSION.tar.gz
111 |
--------------------------------------------------------------------------------
/sonarcloud.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | ##
4 | # Copyright Ladislas de Toldi 2018
5 | # Copyright IBM Corporation 2016,2017,2018
6 | #
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | ##
19 |
20 | if [[ $TRAVIS_BRANCH != "master" && $TRAVIS_BRANCH != "develop" && $TRAVIS_EVENT_TYPE != "cron" ]]; then
21 | echo "Not master, develop or cron build. Skipping code coverage generation."
22 | exit 0
23 | fi
24 |
25 | echo ">> Starting Sonar Cloud code coverage analysis..."
26 | uname -a
27 |
28 | SDK=macosx
29 | DERIVED_DATA=.build/scanner
30 | xcodebuild -version
31 | xcodebuild -version -sdk $SDK
32 | if [[ $? != 0 ]]; then
33 | exit 1
34 | fi
35 |
36 | # Determine if there is a custom command for generating xcode project
37 | source ./Package-Builder/generate-xcodeproj.sh
38 |
39 | # Determine if there is a custom command for xcode build (code coverage tests)
40 | if [ -e ${projectFolder}/.swift-codecov ]; then
41 | XCODE_BUILD_CMD=$(cat ${projectFolder}/.swift-codecov)
42 | else
43 | PROJECT="${PROJ_OUTPUT##*/}"
44 | SCHEME=$(xcodebuild -list -project $PROJECT | grep --after-context=1 '^\s*Schemes:' | tail -n 1 | xargs)
45 | XCODE_BUILD_CMD="xcodebuild -project $PROJECT -scheme $SCHEME -derivedDataPath $DERIVED_DATA -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO"
46 | fi
47 |
48 | echo ">> Running: $XCODE_BUILD_CMD"
49 | eval "$XCODE_BUILD_CMD"
50 | if [[ $? != 0 ]]; then
51 | echo ">> Error running: $XCODE_BUILD_CMD"
52 | exit 1
53 | fi
54 |
55 | BASH_BASE="bash <(cat ${SCRIPT_DIR}/xccov-to-sonarcloud-report.sh)"
56 | XCCOV_ARCHIVE_PATH="$DERIVED_DATA/Logs/Test/*.xcresult/*_Test/action.xccovarchive/"
57 | if [ -z ${SONAR_COVERAGE_REPORT_PATH+x} ]; then
58 | SONAR_COVERAGE_REPORT_PATH="sonarscanner-coverage-report.xml"
59 | fi
60 |
61 | BASH_CMD="$BASH_BASE $XCCOV_ARCHIVE_PATH > $SONAR_COVERAGE_REPORT_PATH"
62 |
63 | echo ">> Running: $BASH_CMD"
64 | eval "$BASH_CMD"
65 | if [[ $? != 0 ]]; then
66 | echo ">> Error running: $BASH_CMD"
67 | exit 1
68 | fi
69 |
70 | if [ -e ${projectFolder}/.swift-sonarcloud ]; then
71 | echo ".swift-sonarcloud found, running sonar-scanner with .swift-sonarcloud."
72 | SONAR_UPLOAD_CMD=$(cat ${projectFolder}/.swift-sonarcloud)
73 | elif [ -e ${projectFolder}/sonar-project.properties ]; then
74 | echo "sonar-project.properties found, running sonar-scanner with sonar-project.properties."
75 | SONAR_UPLOAD_CMD="sonar-scanner -Dsonar.login=$SONAR_LOGIN_TOKEN"
76 | else
77 | echo ".swift-sonarcloud not found, running sonar-scanner env variables provided by .travis.yml"
78 | SONAR_UPLOAD_CMD="sonar-scanner \
79 | -Dsonar.projectKey=$SONAR_PROJECT_KEY \
80 | -Dsonar.organization=$SONAR_ORGANIZATION \
81 | -Dsonar.sources=\"${SONAR_SOURCES}\" \
82 | -Dsonar.exclusions=\"Package-Builder/**, ${SONAR_COVERAGE_REPORT_PATH}, ${SONAR_SOURCES_EXCLUSIONS}\" \
83 | -Dsonar.tests=\"${SONAR_TESTS}\" \
84 | -Dsonar.coverageReportPaths=\"${SONAR_COVERAGE_REPORT_PATH}\" \
85 | -Dsonar.coverage.exclusions=\"${SONAR_COVERAGE_EXCLUSIONS}\" \
86 | -Dsonar.host.url=https://sonarcloud.io \
87 | -Dsonar.login=$SONAR_LOGIN_TOKEN"
88 | fi
89 |
90 | echo ">> Running: $SONAR_UPLOAD_CMD"
91 | eval "$SONAR_UPLOAD_CMD"
92 | if [[ $? != 0 ]]; then
93 | echo ">> Error running: $SONAR_UPLOAD_CMD"
94 | exit 1
95 | fi
96 |
97 | echo ">> Finished code coverage analysis."
98 |
--------------------------------------------------------------------------------
/backup/build-package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script builds the Kitura sample app on Travis CI.
20 | # If running on the OS X platform, homebrew (http://brew.sh/) must be installed
21 | # for this script to work.
22 |
23 | # If any commands fail, we want the shell script to exit immediately.
24 | set -e
25 |
26 | export WORK_DIR=/root
27 |
28 | # Utility functions
29 | function sourceScript () {
30 | if [ -e "$1" ]; then
31 | source "$1"
32 | echo "$2"
33 | fi
34 | }
35 |
36 | # Determine platform/OS
37 | echo ">> uname: $(uname)"
38 | if [ "$(uname)" == "Darwin" ]; then
39 | osName="osx"
40 | elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
41 | osName="linux"
42 | else
43 | echo ">> Unsupported platform!"
44 | exit 1
45 | fi
46 | echo ">> osName: $osName"
47 |
48 | # Make the working directory the parent folder of this script
49 | cd "$(dirname "$0")"/..
50 |
51 | # Get project name from project folder
52 | export projectFolder=`pwd`
53 | projectName="$(basename $projectFolder)"
54 | echo ">> projectName: $projectName"
55 | echo
56 |
57 | # Swift version for build
58 | if [ -f "$projectFolder/.swift-version" ]; then
59 | string="$(cat $projectFolder/.swift-version)";
60 | if [[ $string == *"swift-"* ]]; then
61 | echo ">> using SWIFT_VERSION from file"
62 | export SWIFT_SNAPSHOT=$string
63 | else
64 | echo ">> normalizing SWIFT_VERSION from file"
65 | add="swift-"
66 | export SWIFT_SNAPSHOT=$add$string
67 | fi
68 | else
69 | echo ">> no swift-version file using default value"
70 | export SWIFT_SNAPSHOT=swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a
71 | fi
72 |
73 | echo ">> SWIFT_SNAPSHOT: $SWIFT_SNAPSHOT"
74 |
75 | # Install Swift binaries
76 | source ${projectFolder}/Package-Builder/${osName}/install_swift_binaries.sh
77 |
78 | # Show path
79 | echo ">> PATH: $PATH"
80 |
81 | # Run SwiftLint to ensure Swift style and conventions
82 | # swiftlint
83 |
84 | # Build swift package from makefile
85 | echo ">> Running makefile..."
86 | cd ${projectFolder} && make
87 | echo ">> Finished running makefile"
88 |
89 |
90 | # Copy test credentials for project if available
91 | if [ -e "${projectFolder}/Kitura-TestingCredentials/${projectName}" ]; then
92 | echo ">> Found folder with test credentials for ${projectName}."
93 | # Copy test credentials over
94 | echo ">> copying ${projectFolder}/Kitura-TestingCredentials/${projectName} to ${projectFolder}"
95 | cp -RP ${projectFolder}/Kitura-TestingCredentials/${projectName}/* ${projectFolder}
96 | else
97 | echo ">> No folder found with test credentials for ${projectName}."
98 | fi
99 |
100 | # Execute OS specific pre-test steps
101 | sourceScript "${projectFolder}/Package-Builder/${projectName}/${osName}/before_tests.sh" ">> Completed ${osName} pre-tests steps."
102 |
103 | # Execute common pre-test steps
104 | sourceScript "${projectFolder}/Package-Builder/${projectName}/common/before_tests.sh" ">> Completed common pre-tests steps."
105 |
106 | # Execute test cases
107 | if [ -e "${projectFolder}/Tests" ]; then
108 | echo ">> Testing Kitura package..."
109 | swift test
110 | echo ">> Finished testing Kitura package."
111 | echo
112 | else
113 | echo ">> No testcases exist..."
114 | fi
115 |
116 |
117 | # Execute common post-test steps
118 | sourceScript "${projectFolder}/Package-Builder/${projectName}/common/after_tests.sh" ">> Completed common post-tests steps."
119 |
120 | # Execute OS specific post-test steps
121 | sourceScript "${projectFolder}/Package-Builder/${projectName}/${osName}/after_tests.sh" ">> Completed ${osName} post-tests steps."
122 |
123 |
--------------------------------------------------------------------------------
/backup/build-package-old.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script builds the Kitura sample app on Travis CI.
20 | # If running on the OS X platform, homebrew (http://brew.sh/) must be installed
21 | # for this script to work.
22 |
23 | # If any commands fail, we want the shell script to exit immediately.
24 | set -e
25 |
26 | export WORK_DIR=/root
27 |
28 | # Utility functions
29 | function sourceScript () {
30 | if [ -e "$1" ]; then
31 | source "$1"
32 | echo "$2"
33 | fi
34 | }
35 |
36 | # Determine platform/OS
37 | echo ">> uname: $(uname)"
38 | if [ "$(uname)" == "Darwin" ]; then
39 | osName="osx"
40 | elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
41 | osName="linux"
42 | else
43 | echo ">> Unsupported platform!"
44 | exit 1
45 | fi
46 | echo ">> osName: $osName"
47 |
48 | # Make the working directory the parent folder of this script
49 | cd "$(dirname "$0")"/..
50 |
51 | # Get project name from project folder
52 | export projectFolder=`pwd`
53 | projectName="$(basename $projectFolder)"
54 | echo ">> projectName: $projectName"
55 | echo
56 |
57 | # Swift version for build
58 | if [ -f "$projectFolder/.swift-version" ]; then
59 | string="$(cat $projectFolder/.swift-version)";
60 | if [[ $string == *"swift-"* ]]; then
61 | echo ">> using SWIFT_VERSION from file"
62 | export SWIFT_SNAPSHOT=$string
63 | else
64 | echo ">> normalizing SWIFT_VERSION from file"
65 | add="swift-"
66 | export SWIFT_SNAPSHOT=$add$string
67 | fi
68 | else
69 | echo ">> no swift-version file using default value"
70 | export SWIFT_SNAPSHOT=swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a
71 | fi
72 |
73 | echo ">> SWIFT_SNAPSHOT: $SWIFT_SNAPSHOT"
74 |
75 | # Install Swift binaries
76 | if [ $osName == "linux" ]; then
77 | source ${projectFolder}/Package-Builder/${osName}/install_swift_binaries_old.sh
78 | else
79 | source ${projectFolder}/Package-Builder/${osName}/install_swift_binaries.sh
80 | fi
81 |
82 | # Show path
83 | echo ">> PATH: $PATH"
84 |
85 | # Run SwiftLint to ensure Swift style and conventions
86 | # swiftlint
87 |
88 | # Build swift package from makefile
89 | echo ">> Running makefile..."
90 | cd ${projectFolder} && make
91 | echo ">> Finished running makefile"
92 |
93 |
94 | # Copy test credentials for project if available
95 | if [ -e "${projectFolder}/Kitura-TestingCredentials/${projectName}" ]; then
96 | echo ">> Found folder with test credentials for ${projectName}."
97 | # Copy test credentials over
98 | echo ">> copying ${projectFolder}/Kitura-TestingCredentials/${projectName} to ${projectFolder}"
99 | cp -RP ${projectFolder}/Kitura-TestingCredentials/${projectName}/* ${projectFolder}
100 | else
101 | echo ">> No folder found with test credentials for ${projectName}."
102 | fi
103 |
104 | # Execute OS specific pre-test steps
105 | sourceScript "${projectFolder}/Package-Builder/${projectName}/${osName}/before_tests.sh" ">> Completed ${osName} pre-tests steps."
106 |
107 | # Execute common pre-test steps
108 | sourceScript "${projectFolder}/Package-Builder/${projectName}/common/before_tests.sh" ">> Completed common pre-tests steps."
109 |
110 | # Execute test cases
111 | if [ -e "${projectFolder}/Tests" ]; then
112 | echo ">> Testing Kitura package..."
113 | swift test
114 | echo ">> Finished testing Kitura package."
115 | echo
116 | else
117 | echo ">> No testcases exist..."
118 | fi
119 |
120 |
121 | # Execute common post-test steps
122 | sourceScript "${projectFolder}/Package-Builder/${projectName}/common/after_tests.sh" ">> Completed common post-tests steps."
123 |
124 | # Execute OS specific post-test steps
125 | sourceScript "${projectFolder}/Package-Builder/${projectName}/${osName}/after_tests.sh" ">> Completed ${osName} post-tests steps."
126 |
127 |
--------------------------------------------------------------------------------
/install-swift.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | # Copyright IBM Corporation 2016,2017,2018
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | ##
18 |
19 | # This script builds the Swift package on Travis CI.
20 | # If running on the OS X platform, homebrew (http://brew.sh/) must be installed
21 | # for this script to work.
22 |
23 | # If any commands fail, we want the shell script to exit immediately.
24 | set -e
25 |
26 | # Determine SWIFT_SNAPSHOT for build
27 | if [ -z $SWIFT_SNAPSHOT ]; then
28 | echo ">> No 'SWIFT_SNAPSHOT' set, checking for existing Swift install..."
29 | if which swift > /dev/null; then
30 | SWIFT_SNAPSHOT=$(swift --version 2>/dev/null | grep 'Swift version' | sed 's/^.*Swift version \([0-9][0-9\.]*\) .*$/\1/; ')
31 | echo ">> Use existing swift version: ${SWIFT_SNAPSHOT}"
32 | else
33 | echo ">> No 'SWIFT_SNAPSHOT' set and no existing install, checking for .swift-version file..."
34 | if [ -f "$projectFolder/.swift-version" ]; then
35 | echo ">> Found .swift-version file."
36 | SWIFT_SNAPSHOT="$(cat $projectFolder/.swift-version)";
37 | # Else use default
38 | else
39 | echo ">> No swift-version file found, using default value: $DEFAULT_SWIFT"
40 | SWIFT_SNAPSHOT=$DEFAULT_SWIFT
41 | fi
42 | fi
43 | fi
44 |
45 | #If SWIFT_SNAPSHOT is a URL then we call the alternative download function
46 | if [[ $SWIFT_SNAPSHOT == https* ]]; then
47 | # Starts script to install Swift.
48 | source ${projectFolder}/Package-Builder/${osName}/install_swift_from_url.sh
49 | else
50 | # reconcile version with naming conventions by prepending "swift-" if nesseccary
51 | if [[ $SWIFT_SNAPSHOT == *"swift-"* ]]; then
52 | export SWIFT_SNAPSHOT
53 | else
54 | echo ">> Normalizing SWIFT_VERSION from .swift-version file."
55 | prefix="swift-"
56 | export SWIFT_SNAPSHOT=$prefix$SWIFT_SNAPSHOT
57 | fi
58 |
59 | echo ">> SWIFT_SNAPSHOT: $SWIFT_SNAPSHOT"
60 |
61 | if [[ ${SWIFT_SNAPSHOT} =~ ^.*RELEASE.*$ ]]; then
62 | SNAPSHOT_TYPE=$(echo "$SWIFT_SNAPSHOT" | tr '[:upper:]' '[:lower:]')
63 | elif [[ ${SWIFT_SNAPSHOT} =~ ^swift-.*-DEVELOPMENT.*$ ]]; then
64 | SNAPSHOT_TYPE=${SWIFT_SNAPSHOT%-DEVELOPMENT*}-branch
65 | elif [[ ${SWIFT_SNAPSHOT} =~ ^.*DEVELOPMENT.*$ ]]; then
66 | SNAPSHOT_TYPE=development
67 | else
68 | SNAPSHOT_TYPE="$(echo "$SWIFT_SNAPSHOT" | tr '[:upper:]' '[:lower:]')-release"
69 | SWIFT_SNAPSHOT="${SWIFT_SNAPSHOT}-RELEASE"
70 | fi
71 |
72 | # Swift has to be installed to run commands, if Swift isn't installed, skip checks.
73 | if [[ $(swift --version) ]]; then
74 | # Get the version already installed, if any. OS dependant.
75 | if [[ "$OSTYPE" == "darwin"* ]]; then
76 | SWIFT_PREINSTALL="swift-$(swift --version | awk '{print $4}')"
77 | elif [[ "$OSTYPE" == "linux-gnu" ]]; then
78 | SWIFT_PREINSTALL="swift-$(swift --version | awk '{print $3}')"
79 | else
80 | echo "Unsupported OS. Exiting..."
81 | exit 1
82 | fi
83 | fi
84 |
85 | # Checks for if the needed version of swift matches the one already on the system.
86 | if [[ $SWIFT_PREINSTALL == "" ]]; then
87 | echo "Swift is not installed."
88 | source ${projectFolder}/Package-Builder/${osName}/install_swift_binaries.sh
89 | else
90 | if [[ ${SWIFT_SNAPSHOT} == ${SWIFT_PREINSTALL} ]]; then
91 | echo "Required Swift version is already installed, skipping download..."
92 | elif [[ ${SWIFT_SNAPSHOT} == "${SWIFT_PREINSTALL}-RELEASE" ]]; then
93 | echo "Required Swift version is already installed, skipping download..."
94 | else
95 | # Starts script to install Swift.
96 | source ${projectFolder}/Package-Builder/${osName}/install_swift_binaries.sh
97 | fi
98 | fi
99 | fi
100 |
101 | # Output swift version
102 | echo ">> Swift version shown below: "
103 | swift -version
104 | echo
105 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/Kitura/Package-Builder)
2 |
3 | # Package-Builder
4 |
5 | This repository contains build and utility scripts used for continuous integration builds on the Travis CI environment. It offers many extension points for customizing builds and tests.
6 |
7 | ## Build prerequisites
8 |
9 | Package-Builder is intended to be used as part of Travis CI tests, and will operate on both Ubuntu 14.04 and macOS. At a minimum, the `.travis.yml` file of your application will look something like this:
10 |
11 | ```
12 | $ cat .travis.yml
13 |
14 | matrix:
15 | include:
16 | - os: linux
17 | dist: trusty
18 | sudo: required
19 | - os: osx
20 | osx_image: xcode9
21 | sudo: required
22 |
23 | before_install:
24 | - git clone https://github.com/Kitura/Package-Builder.git
25 |
26 | script:
27 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR
28 | ```
29 |
30 | If you need to install system-level dependencies such as libmysqlclient-dev, you can do so in the `before_install` section of the `.travis.yml` file so that the Travis CI build environment is ready for compilation and testing of your Swift package.
31 |
32 | ### How to start the build-package.sh script
33 | This script must be started form the folder that contains your Swift package. Also, please note that the `projectDir` argument passed to the script should be the directory of the whole repository. For most projects, this is the same as the folder that contains your Swift package, as shown in the example above. However, there are repositories where the Swift packaage is a sub-folder in the main project.
34 |
35 | ### Providing custom credentials
36 | It is not uncommon for swift packages to need to connect to secure services, offerings, and middleware such as databases. To do this, credentials are needed from properties files. To ensure the security of these credentials, many teams use private repositories to store these credentials while their public ones contain dummy files like the one below:
37 |
38 | ```
39 | $ cat configuration.json
40 |
41 | {
42 | ...
43 | "credentials": {
44 | "url": "",
45 | "name": "",
46 | "password": ""
47 | }
48 | ...
49 | }
50 | ```
51 |
52 | The true credentials, show below, should be stored in a private repository:
53 |
54 | ```
55 | $ cat configuration.json
56 |
57 | {
58 | ...
59 | "credentials": {
60 | "url": "api.ng.bluemix.net/v2/authenticate",
61 | "name": "sample@us.ibm.com",
62 | "password": "passw0rd"
63 | }
64 | ...
65 | }
66 | ```
67 |
68 | In order to meet this need, Package-Builder will copy and overwrite these dummy files with the credentials from the private repository. To leverage this functionality, be sure to clone the credentials in the `before_install` section, and then use the following in your `.travis.yml`, pointing towards the folder where the cloned credentials exist:
69 |
70 | ```
71 | script:
72 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR -credentialsDir
73 | ```
74 |
75 | ### Codecov
76 | [Codecov](https://codecov.io/) is used in Package-Builder to determine how much test coverage exists in your code. Codecov allows us to determine which methods and statements in our code are not currently covered by the automated test cases included in the project. Codecov performs its analysis by generating an Xcode project.
77 |
78 | To turn on Codecov, you need to add the following to your `.travis.yml` file:
79 |
80 | ```yaml
81 | env:
82 | global:
83 | - CODECOV_ELIGIBLE=true
84 | ```
85 |
86 | For example, see the [current test coverage](https://codecov.io/gh/Kitura/Swift-cfenv) for the [Swift-cfenv](https://github.com/Kitura/Swift-cfenv) package.
87 |
88 | 
89 |
90 | Please note that Codecov is only leveraged when executing builds on the macOS platform.
91 |
92 | ### SonarCloud
93 | In parallel to Codecov, you can also use [SonarCloud](https://sonarcloud.io). SonarCloud will provide you both with code coverage and code analysis tools.
94 |
95 | Just as Codecov, SonarCloud is only leveraged when executing builds on the macOS platform.
96 |
97 | A little customization to your `.travis.yml` file is needed:
98 |
99 | ```yaml
100 | env:
101 | global:
102 | - SONARCLOUD_ELIGIBLE=true
103 | - SONAR_LOGIN_TOKEN={your login token -- better add this in Travis directly}
104 | ```
105 |
106 | Feel free to read the source for more info: [sonarcloud.sh](https://github.com/Kitura/Package-Builder/blob/master/sonarcloud.sh#L69)
107 |
108 | It is recommended to use a `sonar-project.properties` at the root of your project. Here's a good example: [sonar-project.properties](https://github.com/ladislas/Swift-Travis-Sonarcloud-CI/blob/master/sonar-project.properties). The whole [Swift-Travis-Sonarcloud-CI repo](https://github.com/ladislas/Swift-Travis-Sonarcloud-CI) is a good starting point for both Travis-CI & Sonarcloud.
109 |
110 | You can also provide a `.swift-sonarcloud` file with your custom `sonar-scanner` command.
111 |
112 | ### Auto Jazzy Docs Build
113 | [Jazzy](https://github.com/realm/jazzy) provides automatic documentation construction. To simplify the process of updating public facing api/documentation, package builder can automate the creation and pushing of updated docs for a Pull Request.
114 |
115 | To indicate that documentation should be generated, add the `jazzy-doc` label to the Pull Request.
116 |
117 | In order for a PR to receive automatic documentation generation, the following must be configured:
118 | - The Travis configuration for the repository must define the following environment variables, specifying the credentials of a user that has sufficient permissions to push to PR branches:
119 | - `GITHUB_USERNAME`
120 | - `GITHUB_PASSWORD`
121 | - `GITHUB_EMAIL`
122 | - The repository must have a `jazzy-doc` label defined
123 | - The `.travis.yaml` for the project must contain one macOS build with `env: JAZZY_ELIGIBLE=true`
124 | - The PR must have the `jazzy-doc` label applied
125 |
126 | Once the regular build has executed, Jazzy will be run for MacOS builds and the resulting documentation pushed to the PR branch in a new `[jazzy-doc]` commit. Docs will be generated for each new commit to the PR branch whose commit message does not contain the text `[jazzy-doc]`.
127 |
128 | ### Custom Xcode project generation
129 | If for Codecov, you need a custom command to generate the Xcode project for your Swift package, you should include a `.swift-xcodeproj` file that contains your custom `swift package generate-xcodeproj` command.
130 |
131 | ### Custom code coverage
132 | If you need to run a custom command to generate code coverage for your Swift package, you should include a `.swift-codecov` file that contains your command.
133 |
134 | ### Custom SwiftLint
135 | [SwiftLint](https://github.com/realm/SwiftLint) is a tool to enforce Swift style and conventions. Ensure that your team's coding standard conventions are being met by providing your own `.swiftlint.yml` in the root directory with the specified rules to be run by Package-Builder. For now each project should provide their own `.swiftlint.yml` file to adhere to your preferences. A default may be used in the future, but as of now no SwiftLint operations are performed unless a `.swiftlint.yml` file exists.
136 |
137 | Please note that SwiftLint is only leveraged when executing builds on the macOS platform.
138 |
139 | ### Using different Swift versions and snapshots
140 | Package-Builder uses, by default, the most recent release version of Swift, which at the time of writing is `4.0.3`. If you need a specific version of Swift to build and compile your repo, you should specify that version in a `.swift-version` file in the root level of your repository. Valid contents of this file include release and development snapshots from [Swift.org](https://swift.org/).
141 |
142 | ```
143 | $ cat .swift-version
144 |
145 | swift-DEVELOPMENT-SNAPSHOT-2017-02-14-a
146 | ```
147 | ### Testing with multiple Swift versions
148 | To test your package using a different version of Swift than the one specified in your `.swift-version` file, simply add the `SWIFT_SNAPSHOT` environment variable to your `.travis.yml` file in each one of the entries under the matrix section as shown below:
149 | ```
150 | $ cat .travis.yml
151 |
152 | matrix:
153 | include:
154 | - os: linux
155 | dist: trusty
156 | sudo: required
157 | - os: linux
158 | dist: trusty
159 | sudo: required
160 | env: SWIFT_SNAPSHOT=3.1.1
161 |
162 | before_install:
163 | - git clone https://github.com/Kitura/Package-Builder.git
164 |
165 | script:
166 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR
167 | ```
168 |
169 | In this example above, the first build uses the version specified in the `.swift-version` of the project, or the default version supported by Package-Builder. The second one declares a `SWIFT_SNAPSHOT` environment variable, which overrides the default and `.swift-version` versions for that build.
170 |
171 | ### Testing under Docker
172 | To test your package using a different version of Linux, add the `DOCKER_IMAGE` environment variable to your `.travis.yml` file in each one of the entries under the matrix section as shown below:
173 | ```
174 | $ cat .travis.yml
175 |
176 | matrix:
177 | include:
178 | - os: linux
179 | dist: trusty
180 | sudo: required
181 | env: SWIFT_SNAPSHOT=4.1.3
182 | - os: linux
183 | dist: trusty
184 | sudo: required
185 | env: DOCKER_IMAGE=ubuntu:16.04 SWIFT_SNAPSHOT=4.1.3
186 |
187 | before_install:
188 | - git clone https://github.com/Kitura/Package-Builder.git
189 |
190 | script:
191 | - ./Package-Builder/build-package.sh -projectDir $TRAVIS_BUILD_DIR
192 | ```
193 |
194 | In the above example, the first build uses Ubuntu 14.04 (Trusty) which is supported natively by Travis. The second build uses Trusty to download a 16.04 (Xenial) Docker container, and will then re-execute the Package-Builder command within that container.
195 |
196 | #### Additional environment variables
197 |
198 | Selected environment variables are passed through to the container. These are currently: `SWIFT_SNAPSHOT` and `KITURA_NIO`. Additional environment variables can be passed through by setting the `DOCKER_ENVIRONMENT` variable as follows:
199 | ```
200 | env: DOCKER_IMAGE=ubuntu:16.04 DOCKER_ENVIRONMENT="CUSTOMENV1 CUSTOMENV2"
201 | ```
202 |
203 | #### Additional system packages
204 |
205 | A number of system packages are installed within the Docker container by default (this includes `pkg-config` for SwiftPM, and packages required by Package-Builder itself). Additional system package dependencies can be specified by setting the `DOCKER_PACKAGES` variable as follows:
206 | ```
207 | env: DOCKER_IMAGE=ubuntu:16.04 DOCKER_PACKAGES="libSomePackage someOtherPackage"
208 | ```
209 |
210 | ### Custom build and test commands
211 | If you need a custom command for **compiling** your Swift package, you should include a `.swift-build-linux` or `.swift-build-macOS` file in the root level of your repository and specify in it the exact compilation command for the corresponding platform.
212 |
213 | ```
214 | $ cat .swift-build-linux
215 |
216 | swift build -Xcc -I/usr/include/postgresql
217 | ```
218 |
219 | If you need a custom command for **testing** your Swift package, you should include a `.swift-test-linux` or `.swift-test-macOS` file in the root level of your repository and specify in it the exact testing command for the corresponding platform.
220 |
221 | ```
222 | $ cat .swift-test-linux
223 |
224 | swift test -Xcc -I/usr/include/postgresql
225 | ```
226 |
227 | If you require more granularity than the platform files above provide you can also set the CUSTOM_BUILD_SCRIPT and CUSTOM_TEST_SCRIPT environment variables in your travis configuration. The scripts these environment variables point to will be executed in place of the platform custom scripts or default commands.
228 |
229 | ```
230 | $ cat .build-ubuntu1404
231 | swift build -Xlinker -L/usr/lib -Xcc -I/usr/include/ -Xcc -I/usr/include/mysql/
232 |
233 | $ cat .test-ubuntu1404
234 | swift test -Xlinker -L/usr/lib -Xcc -I/usr/include/ -Xcc -I/usr/include/mysql/
235 |
236 | $ cat .travis.yml
237 | matrix:
238 | include:
239 | - os: linux
240 | dist: trusty
241 | services: docker
242 | env:
243 | - DOCKER_IMAGE=ubuntu:14.04 CUSTOM_BUILD_SCRIPT=.build-ubuntu1404 CUSTOM_TEST_SCRIPT=.test-ubuntu1404
244 | sudo: required
245 | ```
246 | #### Custom `swift test` arguments
247 | If you only need to provide arguments to the `swift test` command, rather than providing a customized test script, you can define the `SWIFT_TEST_ARGS` environment variable. For example:
248 | ```
249 | SWIFT_TEST_ARGS="--parallel --num-workers=16"
250 | ```
251 |
252 | ### Custom configuration for executing tests
253 | Sometimes, a dependency must be set up before the testing process can begin. You may also have the need to execute certain actions after your tests have completed (e.g. shutting down a server). Package-Builder provides an extension point to do this; you can include a `before_tests.sh` and/or a `after_tests.sh` file containing the commands to be executed before and after the tests.
254 |
255 | These files should be placed in a folder structure that matches the outline shown below (see the `linux`, `osx`, and `common` folders):
256 |
257 | 
258 |
259 | *Before Tests:* The `linux/before_tests.sh` and `osx/before_tests.sh` scripts will be executed first if present, followed by `common/before_tests.sh`. Once complete, the tests will commence.
260 |
261 | *After Tests:* After the tests are performed, `common/after_tests.sh` is executed first, followed by `linux/after_tests.sh` or `osx/after_tests.sh`.
262 |
263 | ## Troubleshooting
264 | If there is a crash during the execution of test cases, Package-Builder will perform a log dump to provide meaningful diagnosis of where the failure has occurred.
265 |
--------------------------------------------------------------------------------