Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Replace arc with bazel and kokoro build runner for continuous integration #47

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .arcconfig

This file was deleted.

45 changes: 0 additions & 45 deletions .arclint

This file was deleted.

12 changes: 0 additions & 12 deletions .arcunit

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bazel-*
.kokoro-ios-runner

# Jazzy
docs/

Expand Down
36 changes: 36 additions & 0 deletions .kokoro
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Fail on any error.
set -e

# Display commands to stderr.
set -x

if [ ! -d .kokoro-ios-runner ]; then
git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner
fi

pushd .kokoro-ios-runner
git fetch > /dev/null
TAG=$(git tag -l "v3*" | sort | tail -n1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic Versioning support FTW!

git checkout $TAG > /dev/null
popd

if [ -z "$KOKORO_BUILD_NUMBER" ]; then
tests_dir_prefix=""
else
tests_dir_prefix="github/repo/"
fi

# Fixes a bug in bazel where objc_library targets have a _ prefix.
find ${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import Motion(.+)/import _Motion\1/" {} + || true
stashed_dir=$(pwd)
reset_imports() {
# Undoes our source changes from above.
find ${stashed_dir}/${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import _Motion(.+)/import Motion\1/" {} + || true
}
trap reset_imports EXIT

./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0

echo "Success!"
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ osx_image: xcode8.1
sudo: false
before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- git clone https://github.com/phacility/arcanist.git
- git clone https://github.com/phacility/libphutil.git
- git clone --recursive https://github.com/material-foundation/material-arc-tools.git
- pod install --repo-update
script:
- set -o pipefail
- arcanist/bin/arc unit --everything --trace
- xcodebuild build -workspace MotionTransitioning.xcworkspace -scheme TransitionsCatalog -sdk "iphonesimulator10.1" -destination "name=iPhone 6s,OS=10.1" ONLY_ACTIVE_ARCH=YES | xcpretty -c;
after_success:
- bash <(curl -s https://codecov.io/bash)
57 changes: 57 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Description:
# Light-weight API for building UIViewController transitions.

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library")

strict_warnings_objc_library(
name = "MotionTransitioning",
srcs = glob([
"src/*.m",
"src/private/*.m",
]),
hdrs = glob([
"src/*.h",
"src/private/*.h",
]),
enable_modules = 1,
includes = ["src"],
visibility = ["//visibility:public"],
)

load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")

swift_library(
name = "UnitTestsSwiftLib",
srcs = glob([
"tests/unit/*.swift",
"tests/unit/Transitions/*.swift",
]),
deps = [":MotionTransitioning"],
visibility = ["//visibility:private"],
)

objc_library(
name = "UnitTestsLib",
srcs = glob([
"tests/unit/*.m",
]),
deps = [":MotionTransitioning"],
visibility = ["//visibility:private"],
)

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")

ios_unit_test(
name = "UnitTests",
deps = [
":UnitTestsLib",
":UnitTestsSwiftLib"
],
minimum_os_version = "8.0",
timeout = "short",
visibility = ["//visibility:private"],
)
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
git_repository(
name = "build_bazel_rules_apple",
remote = "https://github.com/bazelbuild/rules_apple.git",
commit = "7ea0557",
)

git_repository(
name = "bazel_ios_warnings",
remote = "https://github.com/material-foundation/bazel_ios_warnings.git",
commit = "3e61cb5b60f52c8b9c77b5d62364d8b4d25e528f",
)
47 changes: 47 additions & 0 deletions tests/unit/Transitions/CompositeTransition.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2017-present The Material Motion Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import UIKit
import MotionTransitioning

final class CompositeTransition: NSObject, Transition, TransitionWithCustomDuration {

let transitions: [Transition]
init(transitions: [Transition]) {
self.transitions = transitions

super.init()
}

// The sole method we're expected to implement, start is invoked each time the view controller is
// presented or dismissed.
func start(with context: TransitionContext) {
transitions.forEach { context.compose(with: $0) }

context.transitionDidEnd()
}

// MARK: TransitionWithCustomDuration

func transitionDuration(with context: TransitionContext) -> TimeInterval {
let duration = transitions.flatMap { $0 as? TransitionWithCustomDuration }.map { $0.transitionDuration(with: context) }.max { $0 < $1 }
if let duration = duration {
return duration
}
return 0.35
}
}