Skip to content

Commit 9e76b35

Browse files
Initial import of Compose support from main Workflow repo.
0 parents  commit 9e76b35

37 files changed

+1902
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apply from: rootProject.file('.buildscript/configure-android-defaults.gradle')
2+
3+
dependencies {
4+
implementation(Deps.get("androidx.appcompat"))
5+
implementation(Deps.get("timber"))
6+
implementation(Deps.get("workflow.core"))
7+
implementation(Deps.get("workflow.runtime"))
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
android {
2+
defaultConfig {
3+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4+
}
5+
}
6+
7+
dependencies {
8+
androidTestImplementation Deps.get("test.androidx.espresso.core")
9+
androidTestImplementation Deps.get("test.androidx.junitExt")
10+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2020 Square Inc.
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+
/*
18+
* We use JetBrain's Kotlin Binary Compatibility Validator to track changes to our public binary
19+
* APIs.
20+
* When making a change that results in a public ABI change, the apiCheck task will fail. When this
21+
* happens, run ./gradlew apiDump to generate updated *.api files, and add those to your commit.
22+
* See https://github.com/Kotlin/binary-compatibility-validator
23+
*/
24+
25+
apply plugin: 'binary-compatibility-validator'
26+
27+
apiValidation {
28+
// Ignore all sample projects, since they're not part of our API.
29+
// Only leaf project name is valid configuration, and every project must be individually ignored.
30+
// See https://github.com/Kotlin/binary-compatibility-validator/issues/3
31+
ignoredProjects += project('samples').subprojects.collect { it.name }
32+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
android {
2+
compileSdkVersion Versions.targetSdk
3+
buildToolsVersion '29.0.2'
4+
5+
compileOptions {
6+
sourceCompatibility JavaVersion.VERSION_1_8
7+
targetCompatibility JavaVersion.VERSION_1_8
8+
}
9+
10+
defaultConfig {
11+
minSdkVersion 21
12+
targetSdkVersion Versions.targetSdk
13+
versionCode 1
14+
versionName "1.0"
15+
}
16+
17+
buildFeatures.viewBinding = true
18+
19+
// See https://github.com/Kotlin/kotlinx.coroutines/issues/1064#issuecomment-479412940
20+
packagingOptions {
21+
exclude 'META-INF/atomicfu.kotlin_module'
22+
exclude 'META-INF/common.kotlin_module'
23+
exclude 'META-INF/android_debug.kotlin_module'
24+
exclude 'META-INF/android_release.kotlin_module'
25+
}
26+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2020 Square Inc.
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+
/*
18+
In addition applying this file, as of dev10 modules that use Compose also need to include this
19+
code snippet to avoid warnings about using compiler version 1.4 (this is because the compiler plugin
20+
is built against compiler source that is in a liminal state between 1.3 and 1.4, the warnings are
21+
safe to ignore and this suppresses them):
22+
23+
tasks.withType<KotlinCompile>().configureEach {
24+
kotlinOptions.apiVersion = "1.3"
25+
}
26+
*/
27+
28+
android {
29+
buildFeatures {
30+
compose true
31+
}
32+
composeOptions {
33+
kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
34+
kotlinCompilerExtensionVersion Versions.compose
35+
}
36+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2019 Square Inc.
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+
apply plugin: 'com.vanniktech.maven.publish'
18+
19+
group = GROUP
20+
version = VERSION_NAME

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*.kt]
2+
indent_size = 2
3+
continuation_indent_size=4

.github/workflows/kotlin.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Kotlin CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
8+
env:
9+
# Must use $HOME here, NOT a tilde, because of the order in which bash does expansion:
10+
# Tilde happens before variables, so will be used literally, whereas $HOME will be
11+
# recursively expanded.
12+
GRADLE_CACHE_PATH: $HOME/.gradle/caches
13+
14+
jobs:
15+
assemble:
16+
name: Assemble
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
steps:
20+
# These setup steps should be common across all jobs in this workflow.
21+
- uses: actions/checkout@v2
22+
- uses: gradle/wrapper-validation-action@v1
23+
- name: set up JDK 1.8
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 1.8
27+
28+
## Caching
29+
- name: Cache gradle dependencies
30+
uses: actions/cache@v1
31+
with:
32+
path: ${{ env.GRADLE_CACHE_PATH }}
33+
# Include the SHA in the hash so this step always adds a cache entry. If we didn't use the SHA, the artifacts
34+
# would only get cached once for each build config hash.
35+
# Don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
36+
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
37+
# The first time a SHA is assembled, we still want to load dependencies from the cache.
38+
# Note that none of jobs dependent on this one need restore keys, since they'll always have an exact hit.
39+
restore-keys: |
40+
gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-
41+
42+
# We want to keep the dependencies from the cache, but clear out the build cache which contains the actual
43+
# compiled artifacts from this project. This ensures we don't run into any issues with stale cache entries,
44+
# and that the resulting cache we upload for the other jobs won't waste any space on stale binaries.
45+
# A simpler approach would be simply to delete the build-cache before uploading the cache archive, however
46+
# if we did that in this job it would defeat the purpose of sharing that directory with dependent jobs,
47+
# and there's no way to modify the cache after the job that created it finishes.
48+
- name: Clean gradle build cache to assemble fresh
49+
run: |
50+
ls -lhrt $GRADLE_CACHE_PATH || true
51+
rm -rf $GRADLE_CACHE_PATH/build-cache-1
52+
ls -lhrt $GRADLE_CACHE_PATH || true
53+
54+
## Actual task
55+
- name: Assemble with gradle
56+
run: ./gradlew assemble --build-cache --no-daemon --stacktrace
57+
58+
# Runs all check tasks in parallel.
59+
check:
60+
name: Check
61+
needs: assemble
62+
runs-on: ubuntu-latest
63+
timeout-minutes: 10
64+
strategy:
65+
# Run all checks, even if some fail.
66+
fail-fast: false
67+
matrix:
68+
gradle-task:
69+
# Unit tests
70+
- test
71+
# Binary compatibility
72+
- apiCheck
73+
- lint
74+
- ktlintCheck
75+
- detekt
76+
# Build the JMH benchmarks to verify, but don't run them.
77+
- jmhJar
78+
steps:
79+
- uses: actions/checkout@v2
80+
- name: set up JDK 1.8
81+
uses: actions/setup-java@v1
82+
with:
83+
java-version: 1.8
84+
85+
## Caching
86+
- name: Cache build artifacts
87+
uses: actions/cache@v1
88+
with:
89+
path: ${{ env.GRADLE_CACHE_PATH }}
90+
# Don't set restore-keys so cache is always only valid for the current build config.
91+
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
92+
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
93+
94+
## Actual task
95+
- name: Check with Gradle
96+
run: ./gradlew ${{ matrix.gradle-task }} --build-cache --no-daemon --stacktrace
97+
98+
instrumentation-tests:
99+
name: Instrumentation tests
100+
needs: assemble
101+
runs-on: macos-latest
102+
timeout-minutes: 20
103+
strategy:
104+
# Allow tests to continue on other devices if they fail on one device.
105+
fail-fast: false
106+
matrix:
107+
api-level:
108+
# Tests are failing on APIs <24.
109+
#- 21
110+
#- 23
111+
- 24
112+
- 29
113+
steps:
114+
- uses: actions/checkout@v2
115+
- name: set up JDK 1.8
116+
uses: actions/setup-java@v1
117+
with:
118+
java-version: 1.8
119+
120+
## Caching
121+
- name: Cache build artifacts
122+
uses: actions/cache@v1
123+
with:
124+
path: ${{ env.GRADLE_CACHE_PATH }}
125+
# Don't set restore-keys so cache is always only valid for the current build config.
126+
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
127+
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
128+
129+
## Actual task
130+
- name: Instrumentation Tests
131+
uses: reactivecircus/android-emulator-runner@v2
132+
with:
133+
api-level: ${{ matrix.api-level }}
134+
arch: x86_64
135+
script: ./gradlew connectedCheck --build-cache --no-daemon --stacktrace

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# macOS
2+
.DS_Store
3+
4+
# Compiled class file
5+
*.class
6+
7+
# Log file
8+
*.log
9+
10+
# BlueJ files
11+
*.ctxt
12+
13+
# Mobile Tools for Java (J2ME)
14+
.mtj.tmp/
15+
16+
# Package Files #
17+
*.jar
18+
*.war
19+
*.nar
20+
*.ear
21+
*.zip
22+
*.tar.gz
23+
*.rar
24+
25+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
26+
hs_err_pid*
27+
28+
# Gradle
29+
out/
30+
.gradle/
31+
build/
32+
local.properties
33+
34+
# Intellij
35+
*.iml
36+
.idea/

.idea/dictionaries/workflow.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)