Skip to content

Commit

Permalink
Update dependencies and workflows, use gradle-managed device (#35)
Browse files Browse the repository at this point in the history
* Update dependencies, use BOM for Compose

* CI: update workflows, use gradle-managed device
  • Loading branch information
rfc2822 authored Apr 1, 2024
1 parent f0964cb commit a47efae
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 87 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/build-kdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@ jobs:
name: Build and publish KDoc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v2
cache: gradle
- uses: gradle/actions/setup-gradle@v3

- name: Build KDoc
run: ./gradlew --no-daemon --no-configuration-cache cert4android:dokkaHtml

- name: Publish KDoc
if: success()
uses: crazy-max/ghaction-github-pages@v2
uses: actions/upload-pages-artifact@v3
with:
target_branch: gh-pages
build_dir: lib/build/dokka/html
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
path: lib/build/dokka/html

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
12 changes: 6 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-java@v2
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/actions/setup-gradle@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,6 +56,6 @@ jobs:
run: ./gradlew --no-daemon cert4android:assemble

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
category: "/language:${{matrix.language}}"
61 changes: 12 additions & 49 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v2
cache: gradle
- uses: gradle/actions/setup-gradle@v3

- name: Check
run: ./gradlew cert4android:check
- name: Archive results
uses: actions/upload-artifact@v2
with:
name: test-results
path: |
lib/build/outputs/lint*
lib/build/reports

test_on_emulator:
name: Tests with emulator
Expand All @@ -36,53 +28,24 @@ jobs:
api-level: [ 31 ]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-java@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v2
cache: gradle
- uses: gradle/actions/setup-gradle@v3

- name: Enable KVM group perms
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: Cache AVD and APKs
uses: actions/cache@v3
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 }}
arch: x86_64
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 tests
uses: reactivecircus/android-emulator-runner@v2
- name: Cache AVD
uses: actions/cache@v4
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
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: ./gradlew --no-daemon cert4android:connectedCheck
path: ~/.config/.android/avd
key: avd-${{ hashFiles('lib/build.gradle.kts') }} # gradle-managed devices are defined there

- name: Archive results
uses: actions/upload-artifact@v2
with:
name: test-results
path: |
lib/build/reports
- name: Run device tests
run: ./gradlew --no-daemon virtualCheck
32 changes: 15 additions & 17 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.2.2"
agp = "8.3.1"
androidx-activityCompose = "1.8.2"
androidx-appcompat = "1.6.1"
androidx-core = "1.12.0"
Expand All @@ -8,19 +8,16 @@ androidx-test-core = "1.5.0"
androidx-test-runner = "1.5.2"
androidx-test-rules = "1.5.0"
conscrypt = "2.5.2"
compose-compiler = "1.5.8"
compose-material = "1.6.0"
compose-runtime = "1.6.0"
compose-ui = "1.6.0"
compose-bom = "2024.03.00"
# https://developer.android.com/jetpack/androidx/releases/compose-kotlin
compose-compiler = "1.5.11"
dokka = "1.9.10"
junit = "4.13.2"
kotlin = "1.9.22"
material = "1.11.0"
mockk = "1.13.9"
kotlin = "1.9.23"
mockk = "1.13.10"
okhttp3 = "4.12.0"

[libraries]
android-material = { module = "com.google.android.material:material", version.ref = "material" }
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
Expand All @@ -30,20 +27,21 @@ androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmode
androidx-test-core = { module = "androidx.test:core-ktx", version.ref = "androidx-test-core" }
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" }
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test-rules" }
compose-material = { module = "androidx.compose.material:material", version.ref = "compose-material" }
compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata", version.ref = "compose-runtime" }
compose-ui-base = { module = "androidx.compose.ui:ui", version.ref = "compose-ui" }
compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics", version.ref = "compose-ui" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose-ui" }
compose-ui-toolingPreview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose-ui" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
compose-material = { module = "androidx.compose.material:material" }
compose-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
compose-ui-base = { module = "androidx.compose.ui:ui" }
compose-ui-graphics = { module = "androidx.compose.ui:ui-graphics" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-toolingPreview = { module = "androidx.compose.ui:ui-tooling-preview" }
conscrypt = { module = "org.conscrypt:conscrypt-android", version.ref = "conscrypt" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
okttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp3" }
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
okttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp3" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
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 @@
#Wed May 17 11:37:23 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
17 changes: 14 additions & 3 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ android {
aarMetadata {
minCompileSdk = 29
}

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
Expand All @@ -39,8 +41,17 @@ android {
disable += listOf("MissingTranslation", "ExtraTranslation")
}

defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@Suppress("UnstableApiUsage")
testOptions {
managedDevices {
localDevices {
create("virtual") {
device = "Pixel 3"
apiLevel = 33
systemImageSource = "aosp-atd"
}
}
}
}

testFixtures {
Expand Down Expand Up @@ -82,11 +93,11 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.lifecycle.livedata)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.android.material)
implementation(libs.conscrypt)

// Jetpack Compose
implementation(libs.androidx.activityCompose)
implementation(platform(libs.compose.bom))
implementation(libs.compose.material)
implementation(libs.compose.runtime.livedata)
debugImplementation(libs.compose.ui.tooling)
Expand Down
3 changes: 1 addition & 2 deletions sample-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ dependencies {
implementation(libs.androidx.lifecycle.runtime)

implementation(libs.androidx.appcompat)
implementation(libs.android.material)

implementation(libs.androidx.activityCompose)
implementation(libs.compose.material)
Expand All @@ -62,4 +61,4 @@ dependencies {
implementation(libs.compose.runtime.livedata)

implementation(project(":cert4android"))
}
}
2 changes: 1 addition & 1 deletion sample-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
tools:targetApi="31">

<activity
Expand Down

0 comments on commit a47efae

Please sign in to comment.