Skip to content

Commit

Permalink
Add android GUI client (#33)
Browse files Browse the repository at this point in the history
* feat: add gomobile bindings for Android GUI

- Create mobile package with SpeedTest interface
- Add configuration structure for mobile bindings
- Create build script for generating mobile bindings

* fix time duration

* feat: add android project and update gitignore

1. Add Android project structure
2. Update gitignore for Android and Go mobile artifacts
3. Successfully build AAR library

* chore: add gradle wrapper

1. Add Gradle wrapper version 8.2
2. Update .gitignore to keep wrapper files

* complete Android project init.

* add src file.

* fix public key.

* update workflow

* fix pipeline

* change test config.

* remove gomobile

* use raw kotlin to build code.

* use raw kotlin to test

* fix max scan point.

* add ipPortTextView

* get all result from channel.

* change max scan count to 100.

* feat: add Android CI/CD workflow

* add workflow file.

* update workflow

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci trigger scope

* revert unused changes

* fix ci

* fix ci
  • Loading branch information
peanut996 authored Dec 20, 2024
1 parent bce264e commit 6e5fb23
Show file tree
Hide file tree
Showing 25 changed files with 1,186 additions and 3 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CloudflareWarpSpeedTest Android CI/CD

on:
push:
branches: [ "*", "*/*" ]
tags:
- 'v*'
pull_request:
branches: [ "*", "*/*" ]

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

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x android/gradlew

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
sdk-platform: '34'
build-tools: '34.0.0'

- name: Build with Gradle
working-directory: ./android
run: ./gradlew build

- name: Run Tests
working-directory: ./android
run: ./gradlew test

- name: Run Lint
working-directory: ./android
run: ./gradlew lint

- name: Upload Build Reports
if: always()
uses: actions/upload-artifact@v3
with:
name: build-reports
path: android/app/build/reports

- name: Build Release APK
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ./android
run: ./gradlew assembleRelease

- name: Sign Release APK
if: startsWith(github.ref, 'refs/tags/v')
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: android/app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: "34.0.0"

- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: |
${{ env.SIGNED_RELEASE_FILE }}
draft: true
prerelease: true

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Go Build and Test

on:
push:
branches: [ "*" ]
branches: [ "*", "*/*" ]
pull_request:
branches: [ "*" ]
branches: [ "*", "*/*" ]

jobs:
build-and-test:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Release for multiple platforms
on:
release:
types: [created]
push:
tags:
- 'v*'

permissions:
contents: write
Expand Down
38 changes: 37 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
dist
Releases
CloudflareWarpSpeedTest
# CloudflareWarpSpeedTest
*.exe
*.csv
.idea
.vscode

# Go build artifacts
*.o
*.a
*.so

# Android build artifacts
*.aar
*.apk
*.aab
*.dex
*.class
android/app/build/
android/.gradle/
android/local.properties
android/.idea/
android/app/release/
android/app/debug/
android/captures/
android/app/libs/
android/build/

# Keep Gradle Wrapper
!android/gradle/wrapper/gradle-wrapper.jar
!android/gradle/wrapper/gradle-wrapper.properties
!android/gradlew
!android/gradlew.bat

# macOS system files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes

# IDE files
55 changes: 55 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.peanut996.cloudflarewarpspeedtest'
compileSdk 34

defaultConfig {
applicationId "com.peanut996.cloudflarewarpspeedtest"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '17'
}

buildFeatures {
viewBinding true
}
buildToolsVersion '34.0.0'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
23 changes: 23 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CloudflareWarpSpeedTest">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Loading

0 comments on commit 6e5fb23

Please sign in to comment.