Skip to content

Commit

Permalink
Merge pull request #8 from UbiqueInnovation/feature/dry-run
Browse files Browse the repository at this point in the history
dry-run upload
  • Loading branch information
fbzli authored Oct 7, 2024
2 parents 66102f6 + 59f60be commit 4900396
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on: [ push, workflow_dispatch ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
module: ["examplekts", "examplegroovy"]
task: ["assemble", "uploadToAlpakaTeschtRelease --alpaka-dryrun"]
steps:
# Checkout repository
- name: Checkout
Expand All @@ -17,10 +21,6 @@ jobs:
distribution: 'zulu'
java-version: '17'

# Run the Gradle Build task
- name: Build Kts Example App
run: ./gradlew clean :examplekts:assemble

# Run the Gradle Build task
- name: Build Groovy Example App
run: ./gradlew clean :examplegroovy:assemble
# Run the Gradle task
- name: Run :${{ matrix.module }}:${{ matrix.task }}
run: ./gradlew clean :${{ matrix.module }}:${{ matrix.task }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ch.ubique.gradle.alpaka.extensions

import kotlin.reflect.KProperty1

fun Any.prettyPrint(): String {
return this::class
.members
.filterIsInstance<KProperty1<Any, *>>()
.joinToString(separator = "\n") { property ->
property.name + ": " + property.get(this).toString().replace("\n", "\\n")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package ch.ubique.gradle.alpaka.task

import ch.ubique.gradle.alpaka.extensions.getResDirs
import ch.ubique.gradle.alpaka.extensions.prettyPrint
import ch.ubique.gradle.alpaka.model.UploadRequest
import ch.ubique.gradle.alpaka.network.BackendRepository
import ch.ubique.gradle.alpaka.network.OkHttpInstance
Expand Down Expand Up @@ -64,6 +65,10 @@ abstract class UploadToAlpakaBackendTask : DefaultTask() {
@get:InputFile
abstract var webIcon: Provider<File>

@get:Input
@set:Option(option = "alpaka-dryrun", description = "Execute the Alpaka upload as a dry-run.")
var dryrun: Boolean = false

@TaskAction
fun uploadAction() {
val proxy = proxy
Expand All @@ -84,10 +89,22 @@ abstract class UploadToAlpakaBackendTask : DefaultTask() {
signature = signature,
)

val apkFile = apk.get()
val webIconFile = webIcon.get()

logger.lifecycle("apk file: ${apkFile.relativeTo(project.rootDir).path} (${apkFile.length() / 1024} kB)")
logger.lifecycle("icon file: ${webIconFile.relativeTo(project.rootDir).path} (${webIconFile.length() / 1024} kB)")
logger.lifecycle("metadata:\n${uploadRequest.prettyPrint().prependIndent()}")

if (dryrun) {
logger.lifecycle("Dry-run completed.")
return
}

logger.lifecycle("Starting upload to Alpaka.")
try {
val backendRepository = BackendRepository()
backendRepository.appsUpload(uploadRequest, apk.get(), webIcon.get(), uploadKey)
backendRepository.appsUpload(uploadRequest, apkFile, webIconFile, uploadKey)
logger.lifecycle("Upload to Alpaka successful.")
} catch (e: Exception) {
val message = if (e is HttpException) {
Expand Down
2 changes: 1 addition & 1 deletion examplegroovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdk 26
targetSdk 34
versionCode 1
versionName project.version.toString()
versionName "1.0"

alpakaUploadKey = "defaultConfig upload key"
}
Expand Down
4 changes: 4 additions & 0 deletions examplegroovy/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
4 changes: 2 additions & 2 deletions examplekts/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ch.ubique.gradle.alpaka.extensions.applicationvariant.launcherIconLabel
import ch.ubique.gradle.alpaka.extensions.applicationvariant.alpakaUploadKey
import ch.ubique.gradle.alpaka.extensions.applicationvariant.launcherIconLabel

plugins {
alias(libs.plugins.androidApplication)
Expand All @@ -16,7 +16,7 @@ android {
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = project.version.toString()
versionName = "1.0"

alpakaUploadKey = "defaultConfig upload key"
}
Expand Down
4 changes: 4 additions & 0 deletions examplekts/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down

0 comments on commit 4900396

Please sign in to comment.