Skip to content

Commit

Permalink
Migrate to GitHub Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Jun 19, 2020
1 parent d04f560 commit ae343fd
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 100 deletions.
23 changes: 0 additions & 23 deletions .buildscript/deploy_snapshot.sh

This file was deleted.

71 changes: 0 additions & 71 deletions .circleci/config.yml

This file was deleted.

91 changes: 91 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build

on:
pull_request:
branches:
- main
push:
branches:
- main

env:
CI: true
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false
TERM: dumb

jobs:
assemble:
name: Assemble
runs-on: ubuntu-latest
env:
JAVA_TOOL_OPTIONS: -Xmx4g

steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
- name: Install android-30 platform
run: |
sudo chown $USER:$USER $ANDROID_HOME -R
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
- uses: actions/setup-java@v1
with:
java-version: 14
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- run: |
./gradlew assemble
checks:
name: Checks (unit tests and static analysis)
runs-on: ubuntu-latest
env:
JAVA_TOOL_OPTIONS: -Xmx4g

steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
- name: Install android-30 platform
run: |
sudo chown $USER:$USER $ANDROID_HOME -R
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
- uses: actions/setup-java@v1
with:
java-version: 14
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- run: |
./gradlew check -PslimTests
deploy-snapshot:
name: Deploy snapshot
needs: [assemble, checks]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
JAVA_TOOL_OPTIONS: -Xmx4g
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}

steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
- name: Install android-30 platform
run: |
sudo chown $USER:$USER $ANDROID_HOME -R
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
- uses: actions/setup-java@v1
with:
java-version: 14
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- run: |
./gradlew clean androidSourcesJar androidJavadocsJar uploadArchives --no-daemon --no-parallel
18 changes: 13 additions & 5 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ on:
paths:
- '**.md'
- 'mkdocs.yml'
- '.github/workflows/**'

jobs:
deploy-website:
name: Generate API docs and deploy website
runs-on: macOS-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
# TODO remove the following once android-30 platform is pre-installed in GitHub Actions VMs
- name: Install android-30 platform
run: |
$ANDROID_HOME/tools/bin/sdkmanager --install "platforms;android-30" > /dev/null
- uses: actions/setup-java@v1
with:
java-version: 14
- run: mv ~/.gradle/caches ~/.gradle/.invalid_caches
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- run: |
pip3 install mkdocs-material mkdocs-minify-plugin
.buildscript/deploy_website.sh
env:
CI: true
JAVA_TOOL_OPTIONS: -Xmx3g
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false -Dkotlin.compiler.execution.strategy=in-process
JAVA_TOOL_OPTIONS: -Xmx4g
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dkotlin.incremental=false
DEPLOY_TOKEN: ${{ secrets.GH_DEPLOY_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FlowBinding

[![CircleCI](https://circleci.com/gh/ReactiveCircus/FlowBinding.svg?style=svg)](https://circleci.com/gh/ReactiveCircus/FlowBinding)
![CI](https://github.com/ReactiveCircus/FlowBinding/workflows/Build/badge.svg)
[![Build Status](https://api.cirrus-ci.com/github/ReactiveCircus/FlowBinding.svg)](https://cirrus-ci.com/github/ReactiveCircus/FlowBinding)
[![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)
[![Android API](https://img.shields.io/badge/API-14%2B-blue.svg?label=API&maxAge=300)](https://www.android.com/history/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class FlowBindingPlugin : Plugin<Project> {
is LibraryPlugin -> {
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
project.extensions.getByType<LibraryExtension>().configureAndroidLibraryOptions(project)
project.configureSlimTests()
}
is AppPlugin -> {
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions(project.gradle.startParameter)
project.configureSlimTests()
}
}
}
Expand Down
37 changes: 37 additions & 0 deletions buildSrc/src/main/kotlin/reactivecircus/flowbinding/SlimTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package reactivecircus.flowbinding

import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.findByType
import org.gradle.language.nativeplatform.internal.BuildType

/**
* When the "slimTests" project property is provided, disable the unit test tasks
* on `release` build type to avoid running the same tests repeatedly
* in different build variants.
*
* Examples:
* `./gradlew test -PslimTests` will run unit tests for `debug` build variants
* in Android App and Library projects, and all tests in JVM projects.
*/
@Suppress("UnstableApiUsage")
internal fun Project.configureSlimTests() {
if (providers.gradleProperty(SLIM_TESTS_PROPERTY).forUseAtConfigurationTime().isPresent) {
// disable unit test tasks on the release build type for Android Library projects
extensions.findByType<LibraryExtension>()?.run {
onVariants.withBuildType(BuildType.RELEASE.name) {
unitTest { enabled = false }
}
}

// disable unit test tasks on the release build type for Android Application projects.
extensions.findByType<BaseAppModuleExtension>()?.run {
onVariants.withBuildType(BuildType.RELEASE.name) {
unitTest { enabled = false }
}
}
}
}

private const val SLIM_TESTS_PROPERTY = "slimTests"

0 comments on commit ae343fd

Please sign in to comment.