Skip to content

Commit

Permalink
Merge branch 'main' of github.com:arildojr7/iris-mock into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	sample/build.gradle.kts
  • Loading branch information
arildojr7 committed Mar 26, 2024
2 parents d6d16c8 + 2c7ac4d commit a2b39c8
Show file tree
Hide file tree
Showing 41 changed files with 409 additions and 954 deletions.
88 changes: 75 additions & 13 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
- name: Run checks
run: ./gradlew ktlintCheck

unit-tests:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: temurin
Expand All @@ -34,10 +36,76 @@ jobs:
- name: Setup gradle
uses: gradle/[email protected]

- name: Run unit tests
run: ./gradlew test
- name: Build iris-mock
run: ./gradlew :iris-mock:publishToMavenLocal

build:
- name: Build iris-mock-plugin
run: ./gradlew :iris-mock-plugin:publishToMavenLocal

- name: Build iris-mock-compiler
run: ./gradlew :iris-mock-compiler:publishToMavenLocal

- name: Build app sample
run: ./gradlew :sample:assembleDebug

- uses: actions/upload-artifact@v4
with:
name: app-sample
path: sample/build/outputs/apk/debug/sample-debug.apk

ui-tests:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
api-level: [29]
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/download-artifact@v4
with:
name: app-sample

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run UI tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb uninstall dev.arildo.iris.mock || true
adb install sample-debug.apk
curl -Ls "https://get.maestro.mobile.dev" | bash
$HOME/.maestro/bin/maestro test .maestro/
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -50,11 +118,5 @@ jobs:
- name: Setup gradle
uses: gradle/[email protected]

- name: Build iris-mock
run: ./gradlew :iris-mock:assemble

- name: Build iris-mock-plugin
run: ./gradlew :iris-mock-plugin:assemble

- name: Build app sample
run: ./gradlew :sample:assembleDebug
- name: Run unit tests
run: ./gradlew test
2 changes: 1 addition & 1 deletion .maestro/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
appId: dev.arildo.iris.mock
---
- launchApp
- assertVisible: "Intercepted!"
- assertVisible: "Intercepted!"
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("com.android.application") version "7.2.2" apply false
id("com.android.library") version "7.2.2" apply false
id("org.jetbrains.kotlin.android") version "1.8.21" apply false
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
alias(libs.plugins.application) apply false
alias(libs.plugins.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.jvm) apply false
}
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")

configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("dev.arildo:iris-mock"))
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ android.useAndroidX=true
kotlin.code.style=official
android.nonTransitiveRClass=true
kotlin.compiler.execution.strategy=in-process
android.nonFinalResIds=true

GROUP_ID=dev.arildo
LIB_ARTIFACT_ID=iris-mock
Expand Down
68 changes: 68 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[versions]
kotlin = "1.9.10"
agp = "8.3.0"
okhttp = "3.14.9"
okio = "2.8.0"
asm = "9.6"
buildconfig = "3.0.3"
gradlePublish = "1.2.1"
ktlintPlugin = "11.3.2"
autoService = "1.1.1"
irisMock = "1.1.0-alpha04"
androidx-appcompat = "1.6.1"
androidx-core = "1.12.0"
androidx-material = "1.11.0"
retrofit = "2.9.0"
retrofitGson = "2.7.1"
androidx-constraintLayout = "2.1.4"
androidx-lifecycle = "2.7.0"
coroutinesCore = "1.7.3"
serializationJson = "1.5.1"
junit = "5.10.2"
mockk = "1.13.5"

[libraries]
agp420 = { module = "com.android.tools.build:gradle", version = "4.2.0" }
agp710 = { module = "com.android.tools.build:gradle", version = "7.1.0" }
agp722 = { module = "com.android.tools.build:gradle", version = "7.2.2" }

androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-material = { module = "com.google.android.material:material", version.ref = "androidx-material" }
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-constraintLayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintLayout" }
androidx-lifecycle = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }

kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesCore" }
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serializationJson" }

retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofitGson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofitGson" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }

asm-core = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-util = { module = "org.ow2.asm:asm-util", version.ref = "asm" }
asm-commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm" }

kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }

autoService-processor = { module = "com.google.auto.service:auto-service", version.ref = "autoService" }
autoService-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" }

test-junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
test-mockk = { module = "io.mockk:mockk", version.ref = "mockk" }

[bundles]
asm = ["asm-core", "asm-commons", "asm-util"]

[plugins]
application = { id = "com.android.application", version.ref = "agp" }
library = { id = "com.android.library", version.ref = "agp" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" }
gradlePublish = { id = "com.gradle.plugin-publish", version.ref = "gradlePublish" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintPlugin" }
irisMock = { id = "dev.arildo.iris-mock-plugin", version.ref = "irisMock" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 12 16:18:12 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
20 changes: 11 additions & 9 deletions iris-mock-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("jvm")
kotlin("kapt")
id("java-library")
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.buildconfig)
alias(libs.plugins.ktlint)
id("maven-publish")
id("signing")
id("com.github.gmazzo.buildconfig") version "3.0.3"
}

publishing {
Expand Down Expand Up @@ -64,7 +67,7 @@ java {
withSourcesJar()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += listOf(
"-opt-in=kotlin.RequiresOptIn",
Expand All @@ -74,10 +77,9 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
}

dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.21")

compileOnly("com.google.auto.service:auto-service-annotations:1.0.1")
kapt("com.google.auto.service:auto-service:1.0.1")
compileOnly(libs.kotlin.compiler)
compileOnly(libs.autoService.annotations)
kapt(libs.autoService.processor)
}

val pluginId = findProperty("PLUGIN_ID").toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ package dev.arildo.iris.plugin
import com.google.auto.service.AutoService
import dev.arildo.iris.plugin.codegen.CodeGenerationExtension
import dev.arildo.iris.plugin.codegen.CodeGenerator
import dev.arildo.iris.plugin.codegen.IrisMockModuleDescriptorImpl
import dev.arildo.iris.plugin.utils.srcGenDirKey
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.resolve.extensions.AnalysisHandlerExtension
Expand All @@ -16,23 +13,19 @@ import java.util.ServiceLoader
@AutoService(CompilerPluginRegistrar::class)
class IrisMockComponentRegistrar : CompilerPluginRegistrar() {

override val supportsK2: Boolean = false // TODO review it
override val supportsK2: Boolean = true // TODO review it

override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
val logger =
configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)

AnalysisHandlerExtension.registerExtension(
CodeGenerationExtension(
codeGenDir = File(configuration.getNotNull(srcGenDirKey)),
codeGenerators = loadCodeGenerators(),
moduleDescriptorFactory = IrisMockModuleDescriptorImpl.Factory()
codeGenerator = loadCodeGenerator()
)
)
}

private fun loadCodeGenerators(): List<CodeGenerator> {
return ServiceLoader.load(CodeGenerator::class.java, CodeGenerator::class.java.classLoader)
.toList()
}
private fun loadCodeGenerator() = ServiceLoader.load(
CodeGenerator::class.java,
CodeGenerator::class.java.classLoader
).firstOrNull()
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit a2b39c8

Please sign in to comment.