|
1 | 1 | #!/bin/bash |
| 2 | +# |
| 3 | +# Copyright 2017-present The Material Motion Authors. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
2 | 16 |
|
3 | 17 | # Fail on any error. |
4 | 18 | set -e |
5 | 19 |
|
6 | 20 | # Display commands to stderr. |
7 | 21 | set -x |
8 | 22 |
|
| 23 | +KOKORO_RUNNER_VERSION="v3.*" |
| 24 | + |
| 25 | +fix_bazel_imports() { |
| 26 | + if [ -z "$KOKORO_BUILD_NUMBER" ]; then |
| 27 | + repo_prefix="" |
| 28 | + else |
| 29 | + repo_prefix="github/repo/" |
| 30 | + fi |
| 31 | + |
| 32 | + # Fixes a bug in bazel where objc_library targets have a _ prefix. |
| 33 | + find "${repo_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "s/import Motion(.+)/import _Motion\1/" {} + || true |
| 34 | + stashed_dir=$(pwd) |
| 35 | + reset_imports() { |
| 36 | + # Undoes our source changes from above. |
| 37 | + find "${stashed_dir}/${tests_dir_prefix}tests/unit" -type f -name '*.swift' -exec sed -i '' -E "s/import _Motion(.+)/import Motion\1/" {} + || true |
| 38 | + } |
| 39 | + trap reset_imports EXIT |
| 40 | +} |
| 41 | + |
9 | 42 | if [ ! -d .kokoro-ios-runner ]; then |
10 | 43 | git clone https://github.com/material-foundation/kokoro-ios-runner.git .kokoro-ios-runner |
11 | 44 | fi |
12 | 45 |
|
13 | 46 | pushd .kokoro-ios-runner |
14 | 47 | git fetch > /dev/null |
15 | | -TAG=$(git tag -l "v3*" | sort | tail -n1) |
16 | | -git checkout $TAG > /dev/null |
| 48 | +TAG=$(git tag --sort=v:refname -l "$KOKORO_RUNNER_VERSION" | tail -n1) |
| 49 | +git checkout "$TAG" > /dev/null |
17 | 50 | popd |
18 | 51 |
|
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 |
| 52 | +fix_bazel_imports |
33 | 53 |
|
34 | 54 | ./.kokoro-ios-runner/bazel.sh test //:UnitTests 8.1.0 |
35 | 55 |
|
|
0 commit comments