Skip to content

Commit

Permalink
Code refactoring and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
leinardi committed Jun 29, 2023
1 parent 175541b commit 0bd77fc
Show file tree
Hide file tree
Showing 115 changed files with 4,212 additions and 3,988 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down
108 changes: 57 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
- master
workflow_dispatch:

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
checks:
name: Checking manifest and deps
Expand All @@ -17,7 +22,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -43,11 +48,11 @@ jobs:
with:
arguments: copyMergedManifests

- uses: UnicornGlobal/has-changes-action@ea00e6f831a9e785271645729fa251907b314707
id: merged_manifests
- id: merged_manifests
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_ENV

- name: Check if there are changes
if: steps.merged_manifests.outputs.changed == 1
if: steps.merged_manifests.outputs.changed != 0
run: |
echo '::error::Uncommitted changes to the merged manifests!'
git diff
Expand All @@ -58,27 +63,25 @@ jobs:
with:
arguments: generateRuntimeDependenciesReport

- uses: UnicornGlobal/has-changes-action@ea00e6f831a9e785271645729fa251907b314707
id: compile_dependencies_report
- id: compile_dependencies_report
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_ENV

- name: Check if there are changes
if: steps.compile_dependencies_report.outputs.changed == 1
if: steps.compile_dependencies_report.outputs.changed != 0
run: |
echo '::error::Uncommitted changes to the compile dependencies report!'
exit 1
build-release:
name: Build release
build-debug:
name: Build debug
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 40
env:
TERM: dumb

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand All @@ -96,40 +99,32 @@ jobs:
- name: Create Local Properties File
run: touch local.properties

- name: Decrypt secrets
run: ./release/decrypt-secrets.sh
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}

## Actual task
## Actual tasks
- name: Build
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_RELEASE_KEYSTORE_PWD: ${{ secrets.RELEASE_KEYSTORE_PWD }}
with:
arguments: bundleRelease # analyzeReleaseBundle <- Disable due to https://github.com/spotify/ruler/issues/116

- name: Clean secrets
if: always()
run: ./release/clean-secrets.sh
cache-read-only: false
arguments: assembleDebug assembleDebugAndroidTest -PsaveBuildLogToFile=true

# Disable due to https://github.com/spotify/ruler/issues/116
# - name: Upload Ruler report
# uses: actions/upload-artifact@v3
# with:
# name: ruler
# path: apps/forlago/build/reports/ruler
- name: Archiving violations report
if: ${{ always() && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: violations-build-debug
path: ./**/build/logs/buildlog*.txt

build-debug:
name: Build debug
build-release:
name: Build release
runs-on: ubuntu-latest
timeout-minutes: 40
timeout-minutes: 30
env:
TERM: dumb

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup JDK
uses: actions/setup-java@v3
Expand All @@ -147,18 +142,29 @@ jobs:
- name: Create Local Properties File
run: touch local.properties

## Actual tasks
- name: Decrypt secrets
run: ./release/decrypt-secrets.sh
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}

## Actual task
- name: Build
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_RELEASE_KEYSTORE_PWD: ${{ secrets.RELEASE_KEYSTORE_PWD }}
with:
arguments: assembleDebug -PsaveBuildLogToFile=true
arguments: bundleRelease # analyzeReleaseBundle <- Disable due to https://github.com/spotify/ruler/issues/116

- name: Archiving violations report
if: ${{ always() && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: violations-build-debug
path: ./**/build/logs/buildlog*.txt
- name: Clean secrets
if: always()
run: ./release/clean-secrets.sh

# Disable due to https://github.com/spotify/ruler/issues/116
# - name: Upload Ruler report
# uses: actions/upload-artifact@v3
# with:
# name: ruler
# path: apps/forlago/build/reports/ruler

detekt:
name: Detekt
Expand All @@ -169,7 +175,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand All @@ -191,7 +197,7 @@ jobs:
- name: Detekt
uses: gradle/gradle-build-action@v2
with:
arguments: detektMain detektTest
arguments: detektDebug detektTest

- name: Archiving violations report
if: ${{ always() && github.event_name == 'pull_request' }}
Expand All @@ -209,7 +215,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down Expand Up @@ -242,7 +248,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down Expand Up @@ -289,7 +295,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down Expand Up @@ -339,7 +345,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down Expand Up @@ -433,7 +439,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mobsf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup JDK
uses: actions/setup-java@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Create release tag
uses: actions/github-script@v5
Expand All @@ -54,7 +54,7 @@ jobs:
})
- name: Workaround to fetch the tag # Is there a better way to do it?
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
env:
ORG_GRADLE_PROJECT_RELEASE_KEYSTORE_PWD: ${{ secrets.RELEASE_KEYSTORE_PWD }}
with:
arguments: publishBundle --track ${{ github.event.inputs.track }} --update-priority ${{ github.event.inputs.updatePriority }} --debug
arguments: publishBundle --track ${{ github.event.inputs.track }} --update-priority ${{ github.event.inputs.updatePriority }}

- name: Clean secrets
if: always()
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete release tag
if: failure()
if: ${{ failure() || cancelled() }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
5 changes: 5 additions & 0 deletions .idea/detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ you can use the `release/encrypt-secrets.sh` to safely encrypt them (it's recomm

## Baseline Profile

Baseline Profiles improve code execution speed from the first launch by avoiding interpretation and just-in-time (JIT) compilation steps for included code paths.
Baseline Profiles improve code execution speed from the first launch by avoiding interpretation and just-in-time (JIT) compilation steps for included
code paths.

### How to generate Baseline profile

Expand All @@ -119,11 +120,13 @@ Just run this command, and it will generate baseline-profile.txt to add to the p
```

The baseline profile generated will be at this path:

```
macrobenchmark/build/outputs/managed_device_android_test_additional_output/pixel6Api31/BaselineProfileGenerator_startup-baseline-prof.txt
```

And you have to rename and move it to:

```
apps/forlago/src/main/baselineProfiles/baseline-prof.txt
```
Expand Down
9 changes: 4 additions & 5 deletions apps/forlago/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ android {

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("release/app-debug.jks")
storeFile = rootProject.file("release/app-debug.jks")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
Expand Down Expand Up @@ -77,8 +77,6 @@ android {

matchingFallbacks.addAll(listOf("release"))
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules-benchmark.pro")
matchingFallbacks += listOf("release")
isDebuggable = false
}
}
}
Expand All @@ -87,13 +85,12 @@ val serviceAccountCredentialsFile: File = rootProject.file("release/play-account
if (serviceAccountCredentialsFile.exists()) {
play {
serviceAccountCredentials.set(serviceAccountCredentialsFile)
releaseStatus.set(if (track.get() == "internal") ReleaseStatus.DRAFT else ReleaseStatus.COMPLETED)
releaseStatus.set(if (track.get() == "internal") ReleaseStatus.COMPLETED else ReleaseStatus.DRAFT)
defaultToAppBundles.set(true)
}
}
println("play-account.json ${if (serviceAccountCredentialsFile.exists()) "" else "NOT "}found!")


dependencies {
// Modules
implementation(projects.modules.featureAccount)
Expand All @@ -109,6 +106,7 @@ dependencies {
implementation(projects.modules.libraryUi)

implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.process)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.profileinstaller) // Need this to side load a Baseline Profile when Benchmarking
implementation(libs.androidx.startup)
Expand All @@ -118,4 +116,5 @@ dependencies {
kaptAndroidTest(libs.hilt.android.compiler)

debugImplementation(libs.androidx.compose.tooling)
debugImplementation(libs.androidx.tracing) // can be removed after the AGP fixes this https://github.com/android/android-test/issues/1755
}
3 changes: 1 addition & 2 deletions apps/forlago/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2023 Roberto Leinardi.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
6 changes: 3 additions & 3 deletions apps/forlago/src/main/kotlin/com/leinardi/forlago/Forlago.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import coil.memory.MemoryCache
import coil.util.DebugLogger
import com.leinardi.forlago.library.feature.Feature
import com.leinardi.forlago.library.feature.FeatureManager
import com.leinardi.forlago.library.preferences.api.interactor.ReadCertificatePinningIsEnabledInteractor
import com.leinardi.forlago.library.network.api.interactor.ReadCertificatePinningEnabledInteractor
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.runBlocking
import okhttp3.OkHttpClient
Expand All @@ -42,7 +42,7 @@ class Forlago : Application(), ImageLoaderFactory {

@Inject lateinit var okHttpClient: OkHttpClient

@Inject lateinit var readCertificatePinningIsEnabledInteractor: ReadCertificatePinningIsEnabledInteractor
@Inject lateinit var readCertificatePinningEnabledInteractor: ReadCertificatePinningEnabledInteractor

override fun onCreate() {
super.onCreate()
Expand Down Expand Up @@ -85,7 +85,7 @@ class Forlago : Application(), ImageLoaderFactory {
detectUnsafeIntentLaunch()
}
runBlocking {
if (readCertificatePinningIsEnabledInteractor()) {
if (readCertificatePinningEnabledInteractor()) {
detectCleartextNetwork()
}
}
Expand Down
Loading

0 comments on commit 0bd77fc

Please sign in to comment.