-
Notifications
You must be signed in to change notification settings - Fork 45
/
.travis.yml
160 lines (136 loc) · 5.99 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Validate with: ruby -ryaml -e 'YAML.load_file ".travis.yml"'
# Generic option gives us Git, Ruby, NodeJS, JVM, i.e. everything we need.
# https://docs.travis-ci.com/user/languages/minimal-and-generic/#generic
language: generic
# Travis CI does not fetch the repository alltogether by default, and we need
# to count commits to evaluate application build number. See also:
# https://github.com/travis-ci/travis-ci/issues/7422.
# TODO(dotdoom): use CI build number instead of commit count.
git:
depth: false
env:
global:
- TERM=dumb
- PAGER=cat
- SDK_ROOT="$HOME/sdk"
- ANDROID_SDK_ROOT="$SDK_ROOT/android"
# Gradle uses old env: https://issuetracker.google.com/issues/125138969.
- ANDROID_HOME="$ANDROID_SDK_ROOT"
- PATH="$SDK_ROOT/flutter/bin:$SDK_ROOT/google-cloud-sdk/bin:$PATH"
- GRADLE_OPTS="-Dorg.gradle.daemon=false"
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
- ANDROID_KEYSTORE_PATH="$HOME/.android/release.keystore"
# This environment variable is read by Firebase CLI, which uses the same
# account we use to access GCloud, to deploy Firebase artifacts.
- GOOGLE_APPLICATION_CREDENTIALS="$HOME/gcloud-service-account.json"
# This environment variable is read by Fastlane Supply, which uses the same
# account we use to access GCloud, to upload the app to Play Store.
- SUPPLY_JSON_KEY="$GOOGLE_APPLICATION_CREDENTIALS"
# A workaround to hide large dumps of text files, see also
# https://github.com/flutter/flutter/pull/4989.
- BOT=false
os: osx
# Starting March 2019, all iOS apps submitted to the App Store must be built
# with the iOS 12.1 SDK or later, included in Xcode 10.1 or later.
osx_image: xcode10.1
branches:
only:
- master
- /^[0-9]+[.][0-9]+[.][0-9]+$/
cache:
timeout: 500
directories:
# Caching a lot of small files is slow because of md5 calculation of each:
# https://github.com/travis-ci/travis-ci/issues/9009. Cache selectively.
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $ANDROID_SDK_ROOT
- $SDK_ROOT/flutter
# When one of the steps in the install fails, the build stops immediately and is
# marked as errored.
install:
- tools/ci.sh
# Install and build flutter (may be cached)
- flutter upgrade || git clone --depth=2 --branch=beta
https://github.com/flutter/flutter.git "${SDK_ROOT?}/flutter"
- flutter precache
- flutter --version
- bundle --version
# TODO(dotdoom): make it bundle install --deployment.
- bundle install
# TODO(dotdoom): file bug: Travis ignores node_js and .nvmrc for generic lang.
# Firebase requires Node version > 8.
- nvm install 8
- nvm alias default 8
- node --version
- npm --version
- ( cd firebase && npm install --no-save )
- ( cd firebase/functions && npm install --no-save )
- ( cd firebase/www && ../node_modules/.bin/bower --allow-root install )
# TODO(dotdoom): this step is very slow and should not even be necessary.
- pod setup
# When one of the build commands returns a non-zero exit code, the Travis CI
# build runs the subsequent commands as well, and accumulates the build result.
script:
- ( cd flutter && bundle exec fastlane build )
- ( cd flutter && flutter test --coverage )
- bash <(curl -s https://codecov.io/bash)
- npm --prefix firebase run build
- npm --prefix firebase/functions run lint
- npm --prefix firebase/functions run build
- ( cd firebase/www && ../node_modules/.bin/polymer lint )
- bundle exec fastlane ensure_clean_git
- |
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo 'Building a tag or a branch. Deploy Firebase to debug,'
echo 'publish to Play Store (internal track).'
# Install and configure gcloud
# Since the script is too noisy printing "tar -xv", we drop stderr.
curl -sSL https://sdk.cloud.google.com | \
bash -s -- --disable-prompts --install-dir="${SDK_ROOT?}" >/dev/null \
2>&1
# This is needed only for iOS to fetch Fastlane match keys repository.
git config --global \
credential.https://source.developers.google.com.helper \
gcloud.sh
gcloud version
echo "${GCLOUD_SERVICE_ACCOUNT_DATA?}" > \
"${GOOGLE_APPLICATION_CREDENTIALS?}"
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS?}"
gsutil cp gs://dasfoo-keystore/delern.jks "${ANDROID_KEYSTORE_PATH?}"
bundle exec fastlane ensure_clean_git &&
PROJECT=delern-debug npm --prefix firebase run deploy &&
PROJECT=delern-e1b33 npm --prefix firebase run deploy &&
( cd flutter && bundle exec fastlane android publish ) &&
if [ -n "$TRAVIS_TAG" ]; then
echo 'Building a tag. Upload to TestFlight.'
( cd flutter && bundle exec fastlane ios publish )
elif [[ "$TRAVIS_BRANCH" == "master" ]]; then
echo 'Building "master" branch. Build debug version, sign. Do not'
echo 'upload to TestFlight (review process is too slow, besides,'
echo 'version number format will look like a.b.c-N-gCOMMIT, which is'
echo 'not accepted by Apple Store).'
( cd flutter && bundle exec fastlane ios build )
else
echo 'Unexpected condition for triggering the build!' >&2
false
fi
else
echo 'Building a PR. No access to keys. Build debug version w/o signing.'
( cd flutter && bundle exec fastlane android build ) &&
# TODO(dotdoom): write proper lane for fastlane.
( cd flutter && flutter build ios --debug --no-codesign ) &&
bundle exec fastlane ensure_clean_git
fi
before_cache:
- |
# Delete volatile files:
# https://docs.travis-ci.com/user/languages/java/#projects-using-gradle
rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
rm -f $HOME/.gradle/caches/*/javaCompile/javaCompile.lock
rm -fr $HOME/.gradle/caches/journal-1/
rm -fr $HOME/.gradle/caches/transforms-1/
rm -fr $HOME/.gradle/caches/*/plugin-resolution/
rm -fr $HOME/.gradle/caches/*/fileHashes/
rm -fr $HOME/.gradle/caches/*/scripts-remapped/