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

Commit a40eb16

Browse files
authored
Replace arc with bazel and kokoro build runner for continuous integration. (#47)
1 parent 0406d3c commit a40eb16

File tree

9 files changed

+154
-87
lines changed

9 files changed

+154
-87
lines changed

.arcconfig

Lines changed: 0 additions & 26 deletions
This file was deleted.

.arclint

Lines changed: 0 additions & 45 deletions
This file was deleted.

.arcunit

Lines changed: 0 additions & 12 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
bazel-*
2+
.kokoro-ios-runner
3+
14
# Jazzy
25
docs/
36

.kokoro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Fail on any error.
4+
set -e
5+
6+
# Display commands to stderr.
7+
set -x
8+
9+
if [ ! -d .kokoro-ios-runner ]; then
10+
git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner
11+
fi
12+
13+
pushd .kokoro-ios-runner
14+
git fetch > /dev/null
15+
TAG=$(git tag -l "v3*" | sort | tail -n1)
16+
git checkout $TAG > /dev/null
17+
popd
18+
19+
if [ -z "$KOKORO_BUILD_NUMBER" ]; then
20+
tests_dir_prefix=""
21+
else
22+
tests_dir_prefix="github/repo/"
23+
fi
24+
25+
# Fixes a bug in bazel where objc_library targets have a _ prefix.
26+
find ${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import Motion(.+)/import _Motion\1/" {} + || true
27+
stashed_dir=$(pwd)
28+
reset_imports() {
29+
# Undoes our source changes from above.
30+
find ${stashed_dir}/${tests_dir_prefix}tests/unit -type f -name '*.swift' -exec sed -i '' -E "s/import _Motion(.+)/import Motion\1/" {} + || true
31+
}
32+
trap reset_imports EXIT
33+
34+
./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0
35+
36+
echo "Success!"

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ osx_image: xcode8.1
33
sudo: false
44
before_install:
55
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
6-
- git clone https://github.com/phacility/arcanist.git
7-
- git clone https://github.com/phacility/libphutil.git
8-
- git clone --recursive https://github.com/material-foundation/material-arc-tools.git
96
- pod install --repo-update
107
script:
118
- set -o pipefail
12-
- arcanist/bin/arc unit --everything --trace
139
- xcodebuild build -workspace MotionTransitioning.xcworkspace -scheme TransitionsCatalog -sdk "iphonesimulator10.1" -destination "name=iPhone 6s,OS=10.1" ONLY_ACTIVE_ARCH=YES | xcpretty -c;
1410
after_success:
1511
- bash <(curl -s https://codecov.io/bash)

BUILD

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Description:
2+
# Light-weight API for building UIViewController transitions.
3+
4+
licenses(["notice"]) # Apache 2.0
5+
6+
exports_files(["LICENSE"])
7+
8+
load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library")
9+
10+
strict_warnings_objc_library(
11+
name = "MotionTransitioning",
12+
srcs = glob([
13+
"src/*.m",
14+
"src/private/*.m",
15+
]),
16+
hdrs = glob([
17+
"src/*.h",
18+
"src/private/*.h",
19+
]),
20+
enable_modules = 1,
21+
includes = ["src"],
22+
visibility = ["//visibility:public"],
23+
)
24+
25+
load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
26+
27+
swift_library(
28+
name = "UnitTestsSwiftLib",
29+
srcs = glob([
30+
"tests/unit/*.swift",
31+
"tests/unit/Transitions/*.swift",
32+
]),
33+
deps = [":MotionTransitioning"],
34+
visibility = ["//visibility:private"],
35+
)
36+
37+
objc_library(
38+
name = "UnitTestsLib",
39+
srcs = glob([
40+
"tests/unit/*.m",
41+
]),
42+
deps = [":MotionTransitioning"],
43+
visibility = ["//visibility:private"],
44+
)
45+
46+
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
47+
48+
ios_unit_test(
49+
name = "UnitTests",
50+
deps = [
51+
":UnitTestsLib",
52+
":UnitTestsSwiftLib"
53+
],
54+
minimum_os_version = "8.0",
55+
timeout = "short",
56+
visibility = ["//visibility:private"],
57+
)

WORKSPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
git_repository(
2+
name = "build_bazel_rules_apple",
3+
remote = "https://github.com/bazelbuild/rules_apple.git",
4+
commit = "7ea0557",
5+
)
6+
7+
git_repository(
8+
name = "bazel_ios_warnings",
9+
remote = "https://github.com/material-foundation/bazel_ios_warnings.git",
10+
commit = "3e61cb5b60f52c8b9c77b5d62364d8b4d25e528f",
11+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2017-present The Material Motion Authors. All Rights Reserved.
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+
import UIKit
18+
import MotionTransitioning
19+
20+
final class CompositeTransition: NSObject, Transition, TransitionWithCustomDuration {
21+
22+
let transitions: [Transition]
23+
init(transitions: [Transition]) {
24+
self.transitions = transitions
25+
26+
super.init()
27+
}
28+
29+
// The sole method we're expected to implement, start is invoked each time the view controller is
30+
// presented or dismissed.
31+
func start(with context: TransitionContext) {
32+
transitions.forEach { context.compose(with: $0) }
33+
34+
context.transitionDidEnd()
35+
}
36+
37+
// MARK: TransitionWithCustomDuration
38+
39+
func transitionDuration(with context: TransitionContext) -> TimeInterval {
40+
let duration = transitions.flatMap { $0 as? TransitionWithCustomDuration }.map { $0.transitionDuration(with: context) }.max { $0 < $1 }
41+
if let duration = duration {
42+
return duration
43+
}
44+
return 0.35
45+
}
46+
}
47+

0 commit comments

Comments
 (0)