Skip to content

add workflows #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root=true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to add this in #1


[*]
insert_final_newline=true

[*.md]
trim_trailing_whitespace=false

[*.gradle]
indent_size=2

[*.{kt,kts}]
indent_size=2
continuation_indent_size=4
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build & Integration tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11

- name: Setup gradle
uses: gradle/gradle-build-action@v2

- name: Ktlint
run: ./gradlew lintKotlin --stacktrace

- name: Check Lint
run: ./gradlew lintDebug --stacktrace

- name: Build all build types
run: ./gradlew assemble --stacktrace

- name: Run Bucketeer unit tests
run: ./gradlew :bucketeer:testDebugUnitTest --stacktrace

- name: upload bucketeer build reports
if: always()
uses: actions/upload-artifact@v3
with:
name: bucketeer-build-reports
path: bucketeer/build/reports

androidTest:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow for the main branch will run both unit tests and integration tests

needs: build
runs-on: macos-latest # enables hardware acceleration in the virtual machine
Copy link
Contributor Author

@yshrsmz yshrsmz Sep 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to use macos to run instrumentation test

ReactiveCircus/android-emulator-runner#46

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout-minutes: 45
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11

- name: Setup gradle
uses: gradle/gradle-build-action@v2

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to switch to Gradle Managed Device once we update AGP to 7.3.x
GMD should be much more reliable.

https://developer.android.com/studio/test/gradle-managed-devices

android/sunflower#785
android/nowinandroid#210

env:
API_KEY: ${{ secrets.E2E_API_KEY }}
API_URL: ${{ secrets.E2E_API_URL }}
with:
api-level: 29
arch: x86_64
script: ./gradlew connectedCheck --stacktrace

- name: upload bucketeer build reports
if: always()
uses: actions/upload-artifact@v3
with:
name: bucketeer-instrumentation-build-reports
path: bucketeer/build/reports

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError -XX:MetaspaceSize=1g"
49 changes: 49 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Pull Request
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be a bit faster than Bitrise, but the on-push workflow takes more than I imagined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but subsequent runs should be faster as I've added cache step...


on:
pull_request:
paths-ignore:
- '*.md'
workflow_dispatch:

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
Comment on lines +9 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI build on a pull request will be canceled if you push a new commit to the branch.


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: 11

- name: Setup gradle
uses: gradle/gradle-build-action@v2

- name: Ktlint
run: ./gradlew lintKotlin --stacktrace

- name: Check Lint
run: ./gradlew lintDebug --stacktrace

- name: Build all build types
run: ./gradlew assemble --stacktrace

- name: Run Bucketeer unit tests
run: ./gradlew :bucketeer:testDebugUnitTest --stacktrace
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow for pull-request will run lint, assemble, and unit tests. Integration tests will be executed on main branch.


- name: upload bucketeer build reports
if: always()
uses: actions/upload-artifact@v3
with:
name: bucketeer-build-reports
path: bucketeer/build/reports

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=true -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError -XX:MetaspaceSize=1g"
1 change: 1 addition & 0 deletions .idea/dictionaries/bucketeer.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion bucketeer/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.nio.file.Files
import java.nio.file.Paths

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
Expand All @@ -8,7 +11,9 @@ plugins {
}

def properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
if (Files.exists(Paths.get("$rootProject.rootDir/local.properties"))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in CI environment, we don't have local.properties so added a check.
should be fine because all necessary variables are provided via environment variables.

properties.load(rootProject.file('local.properties').newDataInputStream())
}

android {
namespace = "io.bucketeer.sdk.android"
Expand Down
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ allprojects {
version = VERSION_NAME
}

subprojects {
afterEvaluate {
// Ktlint ignore generated files
// https://github.com/jeremymailen/kotlinter-gradle/issues/242
[
"lintKotlinDebug", "lintKotlinMain", "lintKotlinRelease",
"formatKotlinDebug", "formatKotlinMain", "formatKotlinRelease"
].forEach { name ->
tasks.named(name) {
exclude { it.file.path.contains("generated/") }
}
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
7 changes: 6 additions & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import java.nio.file.Files
import java.nio.file.Paths

def properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
if (Files.exists(Paths.get("$rootProject.rootDir/local.properties"))) {
properties.load(rootProject.file('local.properties').newDataInputStream())
}

// basic publishing configurations are stored in gradle.properties

Expand Down
7 changes: 6 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import java.nio.file.Files
import java.nio.file.Paths

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlinter)
}

def properties = new Properties()
properties.load(rootProject.file('local.properties').newDataInputStream())
if (Files.exists(Paths.get("$rootProject.rootDir/local.properties"))) {
properties.load(rootProject.file('local.properties').newDataInputStream())
}

android {
compileSdkVersion project.findProperty("android.compileSdkVersion") as int
Expand Down