Skip to content

Commit

Permalink
Update master (#36)
Browse files Browse the repository at this point in the history
* Add screenshot tests

* Setup of CircleCI

* Add CircleCI badge

* Refactoring/convert main source and tests to Kotlin (#32)

* Reuse super state instead of instantiate a new one during the saving instance

* Update tests and screenshots

* Update dependencies and properties to publish into Bintray

* Apply badge color mask only for default color (#35)

* Reuse super state instead of instantiate a new one during the saving instance

* Apply badge color mask only if there is no badge color defined

* Remove lint warnings

* Update screenshots for tests

* Bump to version 1.2.2
  • Loading branch information
andremion authored Sep 26, 2019
1 parent 1a8d56e commit 5d498a7
Show file tree
Hide file tree
Showing 18 changed files with 646 additions and 361 deletions.
164 changes: 164 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
version: 2

references:

## Cache

cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "counterfab/build.gradle" }}-{{ checksum "sample/build.gradle" }}
restore_cache: &restore_cache
restore_cache:
<<: *cache_key
save_cache: &save_cache
save_cache:
<<: *cache_key
paths:
- ~/.gradle
- ~/.m2

## Workspace

workspace: &workspace
~/workspace
attach_debug_workspace: &attach_debug_workspace
attach_workspace:
at: *workspace
persist_debug_workspace: &persist_debug_workspace
persist_to_workspace:
root: *workspace
paths:
- sample/build/outputs/androidTest-results
- sample/build/outputs/apk
- sample/build/outputs/code-coverage
attach_firebase_workspace: &attach_firebase_workspace
attach_workspace:
at: *workspace
persist_firebase_workspace: &persist_firebase_workspace
persist_to_workspace:
root: *workspace
paths:
- firebase

## Docker image configurations

android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-28-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
gcloud_config: &gcloud_config
working_directory: *workspace
docker:
- image: google/cloud-sdk:latest
environment:
TERM: dumb

# Google Cloud Service

export_gcloud_key: &export_gcloud_key
run:
name: Export Google Cloud Service key environment variable
command: echo 'export GCLOUD_SERVICE_KEY="$GCLOUD_SERVICE_KEY"' >> $BASH_ENV
decode_gcloud_key: &decode_gcloud_key
run:
name: Decode Google Cloud credentials
command: echo $GCLOUD_SERVICE_KEY | base64 -di > ${HOME}/client-secret.json

jobs:

## Build debug APK and instrumented test APK

build_debug:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *save_cache
- run:
name: Gradle build (debug)
command: ./gradlew assembleDebug assembleAndroidTest
- *persist_debug_workspace
- store_artifacts:
path: sample/build/outputs/apk/
destination: apk

## Run instrumented tests

test_instrumented:
<<: *gcloud_config
steps:
- *attach_debug_workspace
- *export_gcloud_key
- *decode_gcloud_key
- run:
name: Set Google Cloud target project
command: gcloud config set project counterfab-b6643
- run:
name: Authenticate with Google Cloud
command: gcloud auth activate-service-account --key-file ${HOME}/client-secret.json
- run:
name: Run instrumented test on Firebase Test Lab
command: >-
gcloud firebase test android run --no-auto-google-login
--type instrumentation
--app sample/build/outputs/apk/debug/sample-debug.apk
--test sample/build/outputs/apk/androidTest/debug/sample-debug-androidTest.apk
--device model=walleye,version=28,locale=en_US,orientation=portrait
--environment-variables coverage=true,coverageFile=/sdcard/coverage.ec
--directories-to-pull=/sdcard
--timeout 20m
- run:
name: Create directory to store test results
command: mkdir firebase
- run:
name: Download instrumented test results from Firebase Test Lab
command: gsutil -m cp -r -U "`gsutil ls gs://test-lab-734qaq4mq93km-wb8y9z8s6fud2 | tail -1`*" /root/workspace/firebase/
- *persist_firebase_workspace
- store_artifacts:
path: firebase/
destination: instrumentation
- store_test_results:
path: firebase/

## Submit screenshot tests

report_screenshot_tests:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *attach_debug_workspace
- *attach_firebase_workspace
- run:
name: Move Firebase screenshot resources
command: >-
mkdir -p sample/screenshots &&
cp -r firebase/walleye-28-en_US-portrait/artifacts/sdcard/screenshots/com.andremion.counterfab.sample.test/*
sample/screenshots/
- run:
name: Generate Screenshot test report
command: ./gradlew executeScreenshotTests
- store_artifacts:
path: sample/build/reports/shot/verification/
destination: reports

workflows:
version: 2
workflow:
jobs:
- build_debug
- test_instrumented:
requires:
- build_debug
- report_screenshot_tests:
requires:
- test_instrumented
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=true)](http://www.apache.org/licenses/LICENSE-2.0)
![minSdkVersion 16](https://img.shields.io/badge/minSdkVersion-16-red.svg?style=true)
![compileSdkVersion 24](https://img.shields.io/badge/compileSdkVersion-24-yellow.svg?style=true)
[![CircleCI](https://circleci.com/gh/andremion/CounterFab.svg?style=svg)](https://circleci.com/gh/andremion/CounterFab)
[![Download](https://api.bintray.com/packages/andremion/github/CounterFab/images/download.svg)](https://bintray.com/andremion/github/CounterFab/_latestVersion)

[![Android Arsenal CounterFab](https://img.shields.io/badge/Android%20Arsenal-CounterFab-green.svg?style=true)](https://android-arsenal.com/details/1/5052)
Expand Down
28 changes: 10 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
apply from: 'configuration/properties.gradle'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${compiling.kotlinVersion}"
classpath 'com.karumi:shot:2.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

Expand All @@ -17,30 +18,21 @@ plugins {

allprojects {
repositories {
jcenter()
google()
jcenter()
}
project.ext {

compileSdkVersion = 28
minSdkVersion = 16
targetSdkVersion = 28

versionCode = 7
versionName = "1.2.1"

materialVersion = '1.0.0'

junitVersion = '4.12'
espressoCoreVersion = '3.1.1'
versionCode = 9
versionName = '1.2.2'

name = 'CounterFab'
description = 'A FloatingActionButton subclass that shows a counter badge on right top corner'
url = 'https://play.google.com/store/apps/details?id=com.andremion.counterfab.sample'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
allLicenses = ['Apache-2.0']

bintrayRepo = 'github'
group = 'com.github.andremion'
Expand Down
39 changes: 39 additions & 0 deletions configuration/properties.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
project.ext {

compiling = [
javaVersion : JavaVersion.VERSION_1_8,
kotlinVersion: '1.3.21'
]

android = [
compileSdkVersion: 28,
minSdkVersion : 16,
targetSdkVersion : 28
]

application = [
id: 'com.andremion.counterfab.sample'
]

aux = [
appCompatVersion: '1.0.2',
ktxCoreVersion : '1.0.1'
]

ui = [
materialVersion: '1.0.0'
]

testing = [
junitVersion : '4.12',
espressoCoreVersion : '3.1.1',
rulesVersion : '1.1.1',
screenshotTestingVersion: '0.8.0'
]

building = [
runningOnCI : System.getenv('CI') == 'true',
// allows for -DpreDex=false to be set
preDexEnabled: System.getProperty('preDex', 'true') == 'true'
]
}
25 changes: 16 additions & 9 deletions counterfab/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

def deps = rootProject.extensions.ext

android {
compileSdkVersion project.ext.compileSdkVersion
compileSdkVersion deps.android.compileSdkVersion
defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
versionCode project.ext.versionCode
versionName project.ext.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdkVersion deps.android.minSdkVersion
targetSdkVersion deps.android.targetSdkVersion
versionCode deps.versionCode
versionName deps.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -21,11 +25,14 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.google.android.material:material:$materialVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$compiling.kotlinVersion"
implementation "com.google.android.material:material:$ui.materialVersion"
implementation "androidx.appcompat:appcompat:$aux.appCompatVersion"
implementation "androidx.core:core-ktx:$aux.ktxCoreVersion"

testImplementation "junit:junit:$junitVersion"
testImplementation "junit:junit:$testing.junitVersion"

androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCoreVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$testing.espressoCoreVersion"
}

//apply from: 'https://raw.githubusercontent.com/andremion/JCenter/master/deploy.gradle'
Loading

0 comments on commit 5d498a7

Please sign in to comment.