Skip to content

Commit

Permalink
Merge pull request #4 from stickytools/ci-cd
Browse files Browse the repository at this point in the history
CI/CD
  • Loading branch information
tonystone authored May 2, 2018
2 parents 5bc8dd4 + 1347f82 commit 347c167
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage:
ignore:
- cmake-debug-build/*
- Example/*
- Scripts/*
- Documentaion/*
- Tests/*
- Pods/*
- Applications/Xcode.app/*
- vendor/*
- Carthage/*
- build/*
- .build/*
- .vagrant/*

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,8 @@ cmake-build-debug
# Python
#==============================================================================#
*.pyc

#==============================================================================#
# Ruby
#==============================================================================#
Gemfile.lock
130 changes: 130 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
language: generic

git:
submodules: false

notifications:
slack:
secure: "kgflM3rOhAUsGm6hbs7VUJcXr+FCcslBsg8tRVre569mzI+eMUauMtJINdhRn5nGwUXGinvORbFwmHHh+2TJrYGVCg/FZzTlm3dCdziiGnJnZ+6Pj4vGCgRlpawSSpRuUEYORRzCA9p2GKMKU2hBYPGGzshUfWq5XGJtyWBJuTAqKAP3Foc2kHL7ANFgmo48Nhc2T2CCXW9uFZ98M9Vpg5pi0PRKpEIywUz//xvP6MCmtuXzpQKTVT9IsvFtDJn4R+RZ//geNyJm+u5AlX6PNrQ7y2fqW0wmPJdwAh2E9EoZE2bWD/xL0W+J27kGTeEHkyPmDo7SPsbyhD5Y/rViXOSZXi3PICFAzJ7z1WkhgpzpV2J1JEKcqPSfjq2ZQiE0ZkDUfr/HekYrHgu6IKzB4PCZn6la3c7ncEGNXUzrWmrFip60D34/xsjW8Frh2JOwzs+iQbYunxS/UVuhCH4AXfdZ9uqGBmjKfWxyj+KERYqX3AyyftmZBvLJ0gOjYhUqoD8gBcZCS1KdVXpTMBsnJpMohoyHb8wuAB6e45eQz7ayaqaLaiUBlRqmz3AwVyL6MKXvUhTYwx1YeRRfOM7WEIOnXB9FeyFyvhJuQvvRfY2Mp6LiUyfpdl3wRN18xUZqD65ThPoqe9HB/V8seg+5kfhEPqlFEXpf2WPAJf4IYW8="

env:
global:
- PROJECT=StickyLocking.xcodeproj
- SCHEME=StickyLocking-Package
- TEST_SDK=iphonesimulator

matrix:
include:
-
os: linux
dist: trusty
sudo: required
env:
- BUILD="cmake build"
-
os: osx
osx_image: xcode9.3
env:
- BUILD="cmake build"
-
os: linux
dist: trusty
sudo: required
env:
- BUILD="swift build"
-
os: osx
osx_image: xcode9.3
env:
- BUILD="swift build"
-
os: osx
osx_image: xcode9.3
env:
- BUILD="pod lint"
-
os: osx
osx_image: xcode9.3
env:
- BUILD="xcodebuild"
- TEST_DEST="platform=iOS Simulator,OS=11.3,name=iPhone 8"


# don't re-build for tags so that [publish binary] is not re-run
# https://github.com/travis-ci/travis-ci/issues/1532
branches:
except:
- /^[0-9]/

before_install:
#
# If there is a Gemfile for this os, install bundler and ask bundler to install the gems
#
- |
if [ -e Gemfile ]; then
export BUNDLE_GEMFILE=Gemfile
gem install bundler
bundler install
fi
#
# OSX requires swiftlint be installed
#
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew unlink swiftlint
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/b4bd27d43e3df20735e2704eaf05b37ce5a6d626/Formula/swiftlint.rb
fi
#
# Linux requires downloading Swift and tools
#
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo apt-get update -y
sudo apt-get -y install clang-3.8 lldb-3.8 libicu-dev
wget https://swift.org/builds/swift-4.1-release/ubuntu1404/swift-4.1-RELEASE/swift-4.1-RELEASE-ubuntu14.04.tar.gz
tar xzvf swift-4.1-RELEASE-ubuntu14.04.tar.gz
export PATH=$(pwd)/swift-4.1-RELEASE-ubuntu14.04/usr/bin:$PATH
fi
script:
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
# Fix travis issue: https://github.com/travis-ci/travis-ci/issues/6307
rvm get head --auto-dotfiles || true
fi
- |
if [[ "$BUILD" == "cmake build" ]]; then
set -e # Fail (and stop build) on first non zero exit code
cmake ./
make tests
set +e
fi
- |
if [[ "$BUILD" == "swift build" ]]; then
set -e # Fail (and stop build) on first non zero exit code
swift test
set +e
fi
- |
if [[ "$BUILD" == "pod lint" ]]; then
set -e # Fail (and stop build) on first non zero exit code
bundler exec pod repo update
bundler exec pod lib lint
set +e
fi
- |
if [[ "$BUILD" == "xcodebuild" ]]; then
set -e # Fail (and stop build) on first non zero exit code
cmake ./
make xcode-project
set -o pipefail
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$TEST_DEST" -sdk "$TEST_SDK" -enableCodeCoverage YES build-for-testing | bundler exec xcpretty
xcodebuild -project "$PROJECT" -scheme "$SCHEME" -destination "$TEST_DEST" -sdk "$TEST_SDK" -enableCodeCoverage YES test | bundler exec xcpretty
set +o pipefail
set +e
fi
after_success:
- bash <(curl -s https://codecov.io/bash)

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'cocoapods', '~> 1.5.0'
gem 'xcpretty', '~> 0.2.4'
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ let package = Package(
products: [
.library(name: "StickyLocking", type: .dynamic, targets: ["StickyLocking"])
],
dependencies: [
.package(url: "https://github.com/stickytools/sticky-utilities.git", .branch("master"))
],
targets: [
/// Module targets
.target(name: "StickyLocking", dependencies: ["StickyUtilities"], path: "Sources/StickyLocking"),
.target(name: "StickyLocking", dependencies: [], path: "Sources/StickyLocking"),

/// Tests
.testTarget(name: "StickyLockingTests", dependencies: ["StickyLocking"], path: "Tests/StickyLockingTests")
Expand Down
22 changes: 22 additions & 0 deletions StickyLocking.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Pod::Spec.new do |s|
s.name = "StickyLocking"
s.version = "1.0.0-beta.1"
s.summary = "A general purpose embedded hierarchical lock manager used to build highly concurrent applications of all types."

s.homepage = "https://github.com/stickytools/sticky-locking"
s.license = 'Apache License, Version 2.0'
s.author = { "Tony Stone" => "https://github.com/tonystone" }
s.source = { :git => "https://github.com/stickytools/sticky-locking.git", :tag => s.version.to_s }

s.swift_version = '4.0'

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'

s.requires_arc = true

s.source_files = 'Sources/StickyLocking/**/*.swift'
end
12 changes: 9 additions & 3 deletions Tests/StickyLockingTests/Locker+ExtendedLockModeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ class LockerExtendedLockModeTests: XCTestCase {
/// ```
///
func testLockConversionScenario3Example1Deadlock() {

let input = "database1"

let requester = DispatchGroup()
Expand All @@ -610,7 +611,7 @@ class LockerExtendedLockModeTests: XCTestCase {
cleanup.enter()
blocked.enter()

for _ in 0..<2 {
for i in 0..<5 {

locked.enter()
DispatchQueue.global().async(group: requester) {
Expand All @@ -620,8 +621,13 @@ class LockerExtendedLockModeTests: XCTestCase {
blocked.wait()

/// Now upgrade the lock
XCTAssertEqual(self.locker.lock(input, mode: .X, timeout: .now() + 0.2), .timeout)

if i <= 0 {
/// the first one we send with no timeout as this will be the lock that is granted once the time out happens for the remainder of the locks.
XCTAssertEqual(self.locker.lock(input, mode: .X), .granted)
} else {
/// These will deadlock with the first one and altimately timeout.
XCTAssertEqual(self.locker.lock(input, mode: .X, timeout: .now() + 0.2), .timeout)
}
cleanup.wait() /// Wait to cleanup

XCTAssertEqual(self.locker.unlock(input), true)
Expand Down

0 comments on commit 347c167

Please sign in to comment.