Skip to content

Commit

Permalink
Merge pull request #695 from fmidev/feature/690-testing-build-for-and…
Browse files Browse the repository at this point in the history
…roid

issue-690: Testing build for Android
  • Loading branch information
geosaaga authored Nov 22, 2024
2 parents 6a8dd74 + efadad7 commit 308d191
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 11 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,15 @@ jobs:
run: |
echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" > .env
chmod +x ./gradlew
bundle exec fastlane android build_apk
working-directory: android

- name: Rename APK
run:
mv "./app/build/outputs/apk/release/app-release.apk" "./app/build/outputs/apk/release/latest.apk"
bundle exec fastlane android build_test_apk
working-directory: android

# Upload artifact
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: latest.apk
name: app-latest.apk
path: |
${{ github.workspace }}/android/app/build/outputs/apk/release/latest.apk
${{ github.workspace }}/android/app/build/outputs/apk/latest/app-latest.apk
retention-days: 7
overwrite: true
7 changes: 7 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ android {
debug {
signingConfig signingConfigs.debug
}
latest {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
matchingFallbacks = ['release']
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
Expand Down
1 change: 0 additions & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning"
/>
</manifest>
9 changes: 9 additions & 0 deletions android/app/src/latest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning"
/>
</manifest>
1 change: 1 addition & 0 deletions android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">192.168.50.155</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
14 changes: 14 additions & 0 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ platform :android do
"android.injected.signing.key.password" => ENV["SIGNING_KEY_PASSWORD"]
})
end

# Build APK only
desc "Android build APK for testing"
lane :build_test_apk do
# Gradle clean
gradle(task: 'clean', project_dir: './')
# Gradle sign aab -file
gradle(task: 'assemble', build_type: "Latest", project_dir: './',properties: {
"android.injected.signing.store.file" => ENV["KEYSTORE"],
"android.injected.signing.store.password" => ENV["SIGNING_STORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["SIGNING_KEY_ALIAS"],
"android.injected.signing.key.password" => ENV["SIGNING_KEY_PASSWORD"]
})
end

# Sign, build and deploy to Google Play Store
desc "Sign, build, and deploy to Google Play Store"
Expand Down
8 changes: 8 additions & 0 deletions android/fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ Increment build and version number and push to repository - Build number = versi

Android build APK

### android build_test_apk

```sh
[bundle exec] fastlane android build_test_apk
```

Android build APK for testing

### android build_sign_and_deploy

```sh
Expand Down
7 changes: 6 additions & 1 deletion mockserver/data/config/config.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{}
{
"weather": {
"apiUrl": "http://localhost:3000/timeseries",
"useCardinalsForWindDirection": true
}
}
4 changes: 3 additions & 1 deletion src/config/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const ConfigProvider: React.FC<ConfigProviderProps> = ({
const [shouldReload, setShouldReload] = useState<number>(0);
const reloadIntervalRef = useRef<NodeJS.Timeout | null>(null);

Config.setDefaultConfig(defaultConfig);
if (!Config.hasBeenSet) {
Config.setDefaultConfig(defaultConfig);
}

if (timeout) {
Config.setApiTimeout(timeout);
Expand Down
4 changes: 4 additions & 0 deletions src/config/DynamicConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class DynamicConfig {

private updated: number;

public hasBeenSet = false;

constructor() {
this.apiUrl = undefined;
this.updating = false;
Expand All @@ -31,6 +33,8 @@ class DynamicConfig {

public setDefaultConfig(defaultConfig: ConfigType) {
this.config = defaultConfig;
this.hasBeenSet = true;

if (defaultConfig.dynamicConfig?.enabled) {
let apiUrl = defaultConfig.dynamicConfig.apiUrl;

Expand Down

0 comments on commit 308d191

Please sign in to comment.