Skip to content

Commit ae343fd

Browse files
committed
Migrate to GitHub Actions.
1 parent d04f560 commit ae343fd

File tree

7 files changed

+144
-100
lines changed

7 files changed

+144
-100
lines changed

.buildscript/deploy_snapshot.sh

-23
This file was deleted.

.circleci/config.yml

-71
This file was deleted.

.github/workflows/build.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
env:
12+
CI: true
13+
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false
14+
TERM: dumb
15+
16+
jobs:
17+
assemble:
18+
name: Assemble
19+
runs-on: ubuntu-latest
20+
env:
21+
JAVA_TOOL_OPTIONS: -Xmx4g
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: gradle/wrapper-validation-action@v1
26+
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
27+
- name: Install android-30 platform
28+
run: |
29+
sudo chown $USER:$USER $ANDROID_HOME -R
30+
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
31+
- uses: actions/setup-java@v1
32+
with:
33+
java-version: 14
34+
- uses: actions/cache@v1
35+
with:
36+
path: ~/.gradle/caches
37+
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
38+
- run: |
39+
./gradlew assemble
40+
41+
checks:
42+
name: Checks (unit tests and static analysis)
43+
runs-on: ubuntu-latest
44+
env:
45+
JAVA_TOOL_OPTIONS: -Xmx4g
46+
47+
steps:
48+
- uses: actions/checkout@v2
49+
- uses: gradle/wrapper-validation-action@v1
50+
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
51+
- name: Install android-30 platform
52+
run: |
53+
sudo chown $USER:$USER $ANDROID_HOME -R
54+
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
55+
- uses: actions/setup-java@v1
56+
with:
57+
java-version: 14
58+
- uses: actions/cache@v1
59+
with:
60+
path: ~/.gradle/caches
61+
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
62+
- run: |
63+
./gradlew check -PslimTests
64+
65+
deploy-snapshot:
66+
name: Deploy snapshot
67+
needs: [assemble, checks]
68+
if: github.ref == 'refs/heads/main'
69+
runs-on: ubuntu-latest
70+
env:
71+
JAVA_TOOL_OPTIONS: -Xmx4g
72+
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
73+
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
74+
75+
steps:
76+
- uses: actions/checkout@v2
77+
- uses: gradle/wrapper-validation-action@v1
78+
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
79+
- name: Install android-30 platform
80+
run: |
81+
sudo chown $USER:$USER $ANDROID_HOME -R
82+
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
83+
- uses: actions/setup-java@v1
84+
with:
85+
java-version: 14
86+
- uses: actions/cache@v1
87+
with:
88+
path: ~/.gradle/caches
89+
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
90+
- run: |
91+
./gradlew clean androidSourcesJar androidJavadocsJar uploadArchives --no-daemon --no-parallel

.github/workflows/deploy-website.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,32 @@ on:
77
paths:
88
- '**.md'
99
- 'mkdocs.yml'
10+
- '.github/workflows/**'
1011

1112
jobs:
1213
deploy-website:
1314
name: Generate API docs and deploy website
14-
runs-on: macOS-latest
15+
runs-on: macos-latest
1516
steps:
1617
- uses: actions/checkout@v2
1718
- uses: gradle/wrapper-validation-action@v1
19+
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
20+
- name: Install android-30 platform
21+
run: |
22+
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
23+
- uses: actions/setup-java@v1
24+
with:
25+
java-version: 14
26+
- run: mv ~/.gradle/caches ~/.gradle/.invalid_caches
1827
- uses: actions/cache@v1
1928
with:
2029
path: ~/.gradle/caches
21-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
22-
restore-keys: ${{ runner.os }}-gradle-
30+
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
2331
- run: |
2432
pip3 install mkdocs-material mkdocs-minify-plugin
2533
.buildscript/deploy_website.sh
2634
env:
2735
CI: true
28-
JAVA_TOOL_OPTIONS: -Xmx3g
29-
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false -Dkotlin.compiler.execution.strategy=in-process
36+
JAVA_TOOL_OPTIONS: -Xmx4g
37+
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false
3038
DEPLOY_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FlowBinding
22

3-
[![CircleCI](https://circleci.com/gh/ReactiveCircus/FlowBinding.svg?style=svg)](https://circleci.com/gh/ReactiveCircus/FlowBinding)
3+
![CI](https://github.com/ReactiveCircus/FlowBinding/workflows/Build/badge.svg)
44
[![Build Status](https://api.cirrus-ci.com/github/ReactiveCircus/FlowBinding.svg)](https://cirrus-ci.com/github/ReactiveCircus/FlowBinding)
55
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.reactivecircus.flowbinding/flowbinding-android/badge.svg)](https://search.maven.org/search?q=g:io.github.reactivecircus.flowbinding)
66
[![Android API](https://img.shields.io/badge/API-14%2B-blue.svg?label=API&maxAge=300)](https://www.android.com/history/)

buildSrc/src/main/kotlin/reactivecircus/flowbinding/FlowBindingPlugin.kt

+2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class FlowBindingPlugin : Plugin<Project> {
4949
is LibraryPlugin -> {
5050
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
5151
project.extensions.getByType<LibraryExtension>().configureAndroidLibraryOptions(project)
52+
project.configureSlimTests()
5253
}
5354
is AppPlugin -> {
5455
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
56+
project.configureSlimTests()
5557
}
5658
}
5759
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package reactivecircus.flowbinding
2+
3+
import com.android.build.gradle.LibraryExtension
4+
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
5+
import org.gradle.api.Project
6+
import org.gradle.kotlin.dsl.findByType
7+
import org.gradle.language.nativeplatform.internal.BuildType
8+
9+
/**
10+
* When the "slimTests" project property is provided, disable the unit test tasks
11+
* on `release` build type to avoid running the same tests repeatedly
12+
* in different build variants.
13+
*
14+
* Examples:
15+
* `./gradlew test -PslimTests` will run unit tests for `debug` build variants
16+
* in Android App and Library projects, and all tests in JVM projects.
17+
*/
18+
@Suppress("UnstableApiUsage")
19+
internal fun Project.configureSlimTests() {
20+
if (providers.gradleProperty(SLIM_TESTS_PROPERTY).forUseAtConfigurationTime().isPresent) {
21+
// disable unit test tasks on the release build type for Android Library projects
22+
extensions.findByType<LibraryExtension>()?.run {
23+
onVariants.withBuildType(BuildType.RELEASE.name) {
24+
unitTest { enabled = false }
25+
}
26+
}
27+
28+
// disable unit test tasks on the release build type for Android Application projects.
29+
extensions.findByType<BaseAppModuleExtension>()?.run {
30+
onVariants.withBuildType(BuildType.RELEASE.name) {
31+
unitTest { enabled = false }
32+
}
33+
}
34+
}
35+
}
36+
37+
private const val SLIM_TESTS_PROPERTY = "slimTests"

0 commit comments

Comments
 (0)