Skip to content

Commit

Permalink
merge latest
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Oct 10, 2023
2 parents c4032b4 + 12a6704 commit 9836398
Show file tree
Hide file tree
Showing 34 changed files with 603 additions and 546 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/browerstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
run: |
git config --global url."https://${{ secrets.GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@v1
with:
version: latest
token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets
organization: getlantern
project: android

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -62,7 +70,7 @@ jobs:
CI: "true"
run: |
flutter pub get
make do-android-debug ANDROID_ARCH=all
make appium-test-build
- name: List files in current directory
run: ls -la
Expand All @@ -74,7 +82,7 @@ jobs:
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-prod-debug.apk"
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-appiumtest-debug.apk"
run: |
response=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ permissions:
env:
GOPRIVATE: github.com/getlantern
S3_BUCKET: lantern
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_SITE: datadoghq.eu
jobs:
set-version:
runs-on:
Expand Down Expand Up @@ -84,6 +82,14 @@ jobs:
run: |
git config --global url."https://${{ secrets.GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@v1
with:
version: latest
token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets
organization: getlantern
project: android

- name: Setup JDK 11
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -118,16 +124,9 @@ jobs:
fileDir: './android/app'
encodedString: ${{ secrets.KEYSTORE }}

- name: Install Datadog CI
run: npm install -g @datadog/datadog-ci

- name: Build Android installers
run: make package-android
env:
DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_SITE: datadoghq.eu
INTERSTITIAL_AD_UNIT: "${{ secrets.INTERSTITIAL_AD_UNIT_ID }}"
VERSION: "${{ env.version }}"

Expand Down
8 changes: 8 additions & 0 deletions .run/Appium Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Appium Test" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define=app.flavor=appiumTest" />
<option name="buildFlavor" value="appiumTest" />
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ ADB := $(call get-command,adb)
OPENSSL := $(call get-command,openssl)
GMSAAS := $(call get-command,gmsaas)
SENTRY := $(call get-command,sentry-cli)
DATADOGCI := $(call get-command,datadog-ci)
BASE64 := $(call get-command,base64)

GIT_REVISION_SHORTCODE := $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -90,7 +89,6 @@ PROD_BASE_NAME ?= $(INSTALLER_NAME)
## secrets Keys
INTERSTITIAL_AD_UNIT=ca-app-pub-2685698271254859/9922829329
## vault secrets
VAULT_DD_SECRETS_PATH ?= secret/apps/datadog/android
VAULT_ADS_SECRETS_PATH ?= secret/googleAds

## vault keys
Expand Down Expand Up @@ -245,10 +243,6 @@ require-magick:
require-sentry:
@if [[ -z "$(SENTRY)" ]]; then echo 'Missing "sentry-cli" command. See sentry.io for installation instructions.'; exit 1; fi

.PHONY: require-datadog-ci
require-datadog-ci:
@if [[ -z "$(DATADOGCI)" ]]; then echo 'Missing "datadog-ci" command. See https://www.npmjs.com/package/@datadog/datadog-ci for installation instructions.'; exit 1; fi

release-autoupdate: require-version
@TAG_COMMIT=$$(git rev-list --abbrev-commit -1 $(TAG)) && \
if [[ -z "$$TAG_COMMIT" ]]; then \
Expand Down Expand Up @@ -280,9 +274,12 @@ $(MOBILE_ANDROID_LIB): $(ANDROID_LIB)
mkdir -p $(MOBILE_LIBS) && \
cp $(ANDROID_LIB) $(MOBILE_ANDROID_LIB)

.PHONY: android-lib
.PHONY: android-lib appium-test-build
android-lib: $(MOBILE_ANDROID_LIB)

appium-test-build:
flutter build apk --flavor=appiumTest --dart-define=app.flavor=appiumTest --debug

$(MOBILE_TEST_APK) $(MOBILE_TESTS_APK): $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
@$(GRADLE) -PandroidArch=$(ANDROID_ARCH) \
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
Expand All @@ -299,7 +296,7 @@ do-android-debug: $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
echo "Value of DART_DEFINES is: $$DART_DEFINES" && \
CI="$$CI" && \
echo "Value of CI is: $$CI" && \
$(GRADLE) -Pdart-defines="$$DART_DEFINES" -PlanternVersion=$(DEBUG_VERSION) -PddClientToken=$$DD_CLIENT_TOKEN -PddApplicationID=$$DD_APPLICATION_ID \
$(GRADLE) -Pdart-defines="$$DART_DEFINES" -PlanternVersion=$(DEBUG_VERSION) \
-PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) -Pcountry=$(COUNTRY) \
-PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) \
Expand All @@ -314,7 +311,7 @@ $(MOBILE_DEBUG_APK): $(MOBILE_SOURCES) $(GO_SOURCES)
make do-android-debug && \
cp $(MOBILE_ANDROID_DEBUG) $(MOBILE_DEBUG_APK)

$(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
$(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-sentry
echo $(MOBILE_ANDROID_LIB) && \
mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
Expand All @@ -328,13 +325,12 @@ $(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) req
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PversionCode=$(VERSION_CODE) -PdevelopmentMode=$(DEVELOPMENT_MODE) -b $(MOBILE_DIR)/app/build.gradle assembleProdSideload && \
DATADOG_API_KEY=4901456bb88bbf1dc7799eab7d4f71ae DATADOG_SITE=datadoghq.eu datadog-ci flutter-symbols upload --service-name lantern-android --dart-symbols-location build/app/intermediates/merged_native_libs/prodSideload/out/lib \
--android-mapping-location build/app/outputs/mapping/prodSideload/mapping.txt --android-mapping --ios-dsyms && \
sentry-cli upload-dif --wait -o getlantern -p android build/app/intermediates/merged_native_libs/prodSideload/out/lib && \
cp $(MOBILE_ANDROID_RELEASE) $(MOBILE_RELEASE_APK) && \
cat $(MOBILE_RELEASE_APK) | bzip2 > lantern_update_android_arm.bz2


$(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
$(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-sentry
@mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
COUNTRY="$$COUNTRY" && \
Expand All @@ -344,6 +340,7 @@ $(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-
$(GRADLE) -PlanternVersion=$$VERSION -PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) -PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
-PddClientToken=$(DD_CLIENT_TOKEN) -PddApplicationID=$(DD_APPLICATION_ID) -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=true -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) -b $(MOBILE_DIR)/app/build.gradle bundlePlay && \
sentry-cli upload-dif --wait -o getlantern -p android build/app/intermediates/merged_native_libs/prodPlay/out/lib && \
cp $(MOBILE_ANDROID_BUNDLE) $(MOBILE_BUNDLE)

android-debug: $(MOBILE_DEBUG_APK)
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,42 @@ You'd most probably wanna run this against Lantern's staging servers **and** tur

- You can debug pro-server-neu's staging instance (i.e., `api-staging.getiantem.org`) using a combination of log, telemetry and checking the staging Redis instance (see [here](https://github.com/getlantern/pro-server-neu/blob/c79c1b8da9e418bc4b075392fde9b051c699141d/README.md?plain=1#L125) for more info)

## Running Appium tests locally

To run the Appium tests locally with a connected device, you need to follow a few steps:

1. Install appium with npm:

```bash
npm install -g appium
```

2. Install the necessary drivers:

```bash
appium driver install uiautomator2
appium driver install --source=npm appium-flutter-driver
appium driver install espresso
```

3. Generate a debug build with `CI=true make android-debug ANDROID_ARCH=all` ... CI needs to be set to true to enable the
Flutter driver extension.

4. Modify [local_config.json](appium_kotlin/app/src/test/resources/local/local_config.json) to specify the path of a debug build APK on your system, and change `appium:udid` to specify your device ID (you can get this from `adb devices`)

5. Make sure your device is connected to your computer and then run

```bash
cd appium_kotlin
./gradlew test
```

To run a specific test, you can do

```bash
./gradlew test --tests '*GooglePlay*'
```

## Source Dump
Lantern Android source code is made available via source dump tarballs. To create one, run:

Expand Down
55 changes: 34 additions & 21 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'com.google.protobuf'
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "1.10.0"
id "io.sentry.android.gradle" version "3.13.0"
}

def localProperties = new Properties()
Expand Down Expand Up @@ -170,8 +170,7 @@ android {
}

buildTypes {

debug {
debug {
minifyEnabled false
shrinkResources false
debuggable true
Expand All @@ -180,8 +179,6 @@ android {
buildConfigField "boolean", "STICKY_CONFIG", getBoolean("stickyConfig")
buildConfigField "boolean", "STAGING", getBoolean("useStaging")
buildConfigField "boolean", "PLAY_VERSION", getBoolean("playVersion")
buildConfigField "String", "DD_CLIENT_TOKEN", ddClientToken()
buildConfigField "String", "DD_APPLICATION_ID", ddApplicationID()
buildConfigField "String", "COUNTRY", userCountry()
buildConfigField "String", "PAYMENT_PROVIDER", paymentProvider()
buildConfigField "String", "PRO_SERVER_URL", proServerUrl()
Expand Down Expand Up @@ -256,6 +253,9 @@ android {
autoTest {
versionCode 1 // so we can always test auto-update.
}
appiumTest {
buildConfigField "boolean", "CI", "true"
}
}

splits {
Expand Down Expand Up @@ -323,22 +323,6 @@ def getInt(name) {
return value.toInteger()
}

def ddApplicationID() {
def value = project.getProperties().get("ddApplicationID")
if (value == null || !value?.trim()) {
return "\"\""
}
return String.format("\"%s\"", value)
}

def ddClientToken() {
def value = project.getProperties().get("ddClientToken")
if (value == null || !value?.trim()) {
return "\"\""
}
return String.format("\"%s\"", value)
}

def userCountry() {
def value = project.getProperties().get("country")
if (value == null || !value?.trim()) {
Expand Down Expand Up @@ -473,3 +457,32 @@ dependencies {
}

apply plugin: 'com.google.gms.google-services'

sentry {

// Disables or enables the handling of Proguard mapping for Sentry.
// If enabled the plugin will generate a UUID and will take care of
// uploading the mapping to Sentry. If disabled, all the logic
// related to proguard mapping will be excluded.
// Default is enabled.
includeProguardMapping = true


// Whether the plugin should attempt to auto-upload the mapping file to Sentry or not.
// If disabled the plugin will run a dry-run and just generate a UUID.
// The mapping file has to be uploaded manually via sentry-cli in this case.
// Default is enabled.
autoUploadProguardMapping = true

// Disables or enables the automatic configuration of Native Symbols
// for Sentry. This executes sentry-cli automatically so
// you don't need to do it manually.
// Default is disabled.
uploadNativeSymbols = true

// Does or doesn't include the source code of native code for Sentry.
// This executes sentry-cli with the --include-sources param. automatically so
// you don't need to do it manually.
// Default is disabled.
includeNativeSources = false
}
3 changes: 3 additions & 0 deletions android/app/libs/liblantern-all.aar
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import io.lantern.model.BaseModel
import io.lantern.model.Vpn
import org.getlantern.lantern.BuildConfig
import org.getlantern.lantern.LanternApp
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.model.Bandwidth
import org.getlantern.lantern.model.Stats
import org.getlantern.lantern.model.Utils
Expand Down Expand Up @@ -329,7 +328,7 @@ abstract class SessionManager(application: Application) : Session {
val isPaymentTestMode: Boolean
get() {
val paymentTestMode = prefs.getBoolean(PAYMENT_TEST_MODE, false)
val ciValue = BuildConfig.CI
val ciValue = BuildConfig.FLAVOR == "appiumTest"
return ciValue || paymentTestMode
}

Expand Down Expand Up @@ -386,7 +385,6 @@ abstract class SessionManager(application: Application) : Session {

override fun setCountry(country: String) {
prefs.edit().putString(GEO_COUNTRY_CODE, country).apply()
Datadog.setCountry(country)
}

private val hasUpdatedStats = AtomicBoolean()
Expand Down
5 changes: 0 additions & 5 deletions android/app/src/main/kotlin/io/lantern/model/SessionModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.getlantern.lantern.MainActivity
import org.getlantern.lantern.R
import org.getlantern.lantern.activity.FreeKassaActivity_
import org.getlantern.lantern.activity.WebViewActivity_
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.model.LanternHttpClient
import org.getlantern.lantern.model.LanternHttpClient.ProCallback
import org.getlantern.lantern.model.LanternHttpClient.ProUserCallback
Expand Down Expand Up @@ -182,10 +181,6 @@ class SessionModel(
}
}

"trackUserAction" -> {
Datadog.trackUserClick(call.argument("message")!!)
}

"acceptTerms" -> {
LanternApp.getSession().acceptTerms()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.os.StrictMode
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.multidex.MultiDex
Expand All @@ -16,7 +15,7 @@ import org.getlantern.lantern.notification.Notifications
import org.getlantern.lantern.service.LanternConnection
import org.getlantern.lantern.util.debugOnly
import org.getlantern.lantern.util.LanternProxySelector
import org.getlantern.mobilesdk.Logger
import org.getlantern.lantern.util.SentryUtil
import org.getlantern.mobilesdk.util.HttpClient

open class LanternApp : Application() {
Expand Down Expand Up @@ -45,13 +44,14 @@ open class LanternApp : Application() {

override fun onCreate() {
super.onCreate()
SentryUtil.enableGoPanicEnrichment(this)

// Necessary to locate a back arrow resource we use from the
// support library. See http://stackoverflow.com/questions/37615470/support-library-vectordrawable-resourcesnotfoundexception
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
appContext = applicationContext
session = LanternSessionManager(this)

LanternProxySelector(session)

if (session.isPlayVersion) inAppBilling = InAppBilling(this)
Expand Down
Loading

0 comments on commit 9836398

Please sign in to comment.