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

Commit

Permalink
Add support for kokoro and bazel continuous integration. (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey authored Oct 31, 2017
1 parent fc5076d commit fd570d7
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
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

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
Expand Down
60 changes: 60 additions & 0 deletions .kokoro
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
#
# Copyright 2017-present The Material Foundation 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.

# Fail on any error.
set -e

# Display commands to stderr.
set -x

KOKORO_RUNNER_VERSION="v3.*"

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

rewrite_source() {
find "${stashed_dir}${tests_dir_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "$1" {} + || true
}

stashed_dir=""
rewrite_source "s/import MDFTextAccessibility/import _MDFTextAccessibility/"
stashed_dir="$(pwd)/"
reset_imports() {
# Undoes our source changes from above.
rewrite_source "s/import _MDFTextAccessibility/import MDFTextAccessibility/"
}
trap reset_imports EXIT
}

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 --sort=v:refname -l "$KOKORO_RUNNER_VERSION" | tail -n1)
git checkout "$TAG" > /dev/null
popd

fix_bazel_imports

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

echo "Success!"
55 changes: 55 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2017-present The Material Foundation 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.

load("@bazel_ios_warnings//:strict_warnings_objc_library.bzl", "strict_warnings_objc_library")
load("@build_bazel_rules_apple//apple:swift.bzl", "swift_library")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

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

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

ios_unit_test(
name = "UnitTests",
deps = [
":UnitTestsSwiftLib"
],
timeout = "short",
visibility = ["//visibility:private"],
)
25 changes: 25 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017-present The Material Foundation 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.

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",
tag = "v1.0.1",
)

0 comments on commit fd570d7

Please sign in to comment.