From 229e6553752e0fcc1d0d07905edd548d5294a2e0 Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Tue, 27 Feb 2024 22:09:38 +0100 Subject: [PATCH 1/6] Add caching + fix `buildCode` --- .github/workflows/apk_debug.yml | 5 ++++- .github/workflows/apk_pr.yml | 4 +++- .github/workflows/check.yml | 9 +++++---- app/build.gradle | 9 +++++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/apk_debug.yml b/.github/workflows/apk_debug.yml index 30512534a..f089df030 100644 --- a/.github/workflows/apk_debug.yml +++ b/.github/workflows/apk_debug.yml @@ -12,14 +12,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: ./.github/actions/checkout_submodules - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' + cache: 'gradle' - name: Build debug APK run: ./gradlew assembleDebug diff --git a/.github/workflows/apk_pr.yml b/.github/workflows/apk_pr.yml index cbae6b8a4..d5b4f85a1 100644 --- a/.github/workflows/apk_pr.yml +++ b/.github/workflows/apk_pr.yml @@ -14,14 +14,16 @@ jobs: uses: actions/checkout@v3 with: ref: refs/pull/${{github.event.pull_request.number}}/merge + fetch-depth: 0 - uses: ./.github/actions/checkout_submodules - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' + cache: 'gradle' - name: Build release APK run: | diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 53cbdfa83..3fa9579ed 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -16,20 +16,21 @@ jobs: - uses: ./.github/actions/checkout_submodules - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' + cache: 'gradle' # TODO: Without this step, the Gradle check task fails with the following error: # Execution failed for task ':common:verifyDebugDatabaseMigration'. # > A failure occurred while executing app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction # > No suitable driver found for jdbc:sqlite: - - name: Run verifyDebugDatabase - run: bash ./gradlew verifyDebugDatabaseMigration + # - name: Run verifyDebugDatabase + # run: ./gradlew verifyDebugDatabaseMigration --no-daemon - name: Run check - run: bash ./gradlew check + run: ./gradlew check --no-daemon - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 diff --git a/app/build.gradle b/app/build.gradle index 58b6157c8..dfdc0c5e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,13 @@ ktlint { // Generate a version code from git commit count static def generateVersionCode() { - return "git rev-list HEAD --count".execute().text.trim().toInteger() + // Unix + def result = "git rev-list HEAD --count".execute().text.trim() + // Windows + if (result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() + if (result.empty) throw new RuntimeException("Could not generate versioncode: ${result.text}") + println("Generated the following version code: " + result.toInteger()) + return result.toInteger() } @@ -46,7 +52,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - signingConfigs { release { keyAlias "trustchain" From cad9985c135c5bed38f46ff442775eba4a275dd9 Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Tue, 27 Feb 2024 22:19:28 +0100 Subject: [PATCH 2/6] Disable daemons + upgrade `actions/checkout` --- .github/workflows/apk_debug.yml | 4 ++-- .github/workflows/apk_pr.yml | 5 +++-- .github/workflows/check.yml | 7 ------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/apk_debug.yml b/.github/workflows/apk_debug.yml index f089df030..a26fb1dc5 100644 --- a/.github/workflows/apk_debug.yml +++ b/.github/workflows/apk_debug.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -25,7 +25,7 @@ jobs: cache: 'gradle' - name: Build debug APK - run: ./gradlew assembleDebug + run: ./gradlew assembleDebug --no-daemon - name: Upload APK uses: actions/upload-artifact@v1 diff --git a/.github/workflows/apk_pr.yml b/.github/workflows/apk_pr.yml index d5b4f85a1..5c33b05d3 100644 --- a/.github/workflows/apk_pr.yml +++ b/.github/workflows/apk_pr.yml @@ -11,10 +11,10 @@ jobs: name: apk_build steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - ref: refs/pull/${{github.event.pull_request.number}}/merge fetch-depth: 0 + ref: refs/pull/${{github.event.pull_request.number}}/merge - uses: ./.github/actions/checkout_submodules @@ -29,6 +29,7 @@ jobs: run: | echo $KEYSTORE_FILE | base64 -d > app/build.keystore ./gradlew assembleRelease \ + --no-daemon \ -Pandroid.injected.signing.store.file=$(pwd)/app/build.keystore \ -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \ -Pandroid.injected.signing.key.alias=$KEY_ALIAS \ diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3fa9579ed..b5a22278d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -22,13 +22,6 @@ jobs: java-version: '17' cache: 'gradle' - # TODO: Without this step, the Gradle check task fails with the following error: - # Execution failed for task ':common:verifyDebugDatabaseMigration'. - # > A failure occurred while executing app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction - # > No suitable driver found for jdbc:sqlite: - # - name: Run verifyDebugDatabase - # run: ./gradlew verifyDebugDatabaseMigration --no-daemon - - name: Run check run: ./gradlew check --no-daemon From 6742de466474904f7371bc657a968242cac33540 Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Tue, 27 Feb 2024 22:23:11 +0100 Subject: [PATCH 3/6] Remove depth from action --- .github/actions/checkout_submodules/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/checkout_submodules/action.yml b/.github/actions/checkout_submodules/action.yml index e26330902..f8c27bc7f 100644 --- a/.github/actions/checkout_submodules/action.yml +++ b/.github/actions/checkout_submodules/action.yml @@ -8,4 +8,4 @@ runs: git config --global url."https://github.com/".insteadOf "git@github.com:" auth_header="$(git config --local --get http.https://github.com/.extraheader)" git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive From 3ab67e5e29fbddb7a6bce68ceb14cb0cbe4f0e74 Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Wed, 28 Feb 2024 09:09:54 +0100 Subject: [PATCH 4/6] Update fetch depth in apk main --- .github/actions/checkout_submodules/action.yml | 2 +- .github/workflows/apk_main.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/checkout_submodules/action.yml b/.github/actions/checkout_submodules/action.yml index f8c27bc7f..e26330902 100644 --- a/.github/actions/checkout_submodules/action.yml +++ b/.github/actions/checkout_submodules/action.yml @@ -8,4 +8,4 @@ runs: git config --global url."https://github.com/".insteadOf "git@github.com:" auth_header="$(git config --local --get http.https://github.com/.extraheader)" git submodule sync --recursive - git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 diff --git a/.github/workflows/apk_main.yml b/.github/workflows/apk_main.yml index ad66c23b8..ebc2bb324 100644 --- a/.github/workflows/apk_main.yml +++ b/.github/workflows/apk_main.yml @@ -10,7 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: ./.github/actions/checkout_submodules From ee9d5bc39cbdcdbacfe0e33b29ed882c87c8ab00 Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Wed, 28 Feb 2024 09:14:49 +0100 Subject: [PATCH 5/6] Add caching to apk main --- .github/workflows/apk_main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apk_main.yml b/.github/workflows/apk_main.yml index ebc2bb324..869d3b6ae 100644 --- a/.github/workflows/apk_main.yml +++ b/.github/workflows/apk_main.yml @@ -17,10 +17,11 @@ jobs: - uses: ./.github/actions/checkout_submodules - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' + cache: 'gradle' - name: Build release APK run: | From e9d11a3ac44fb77c75b15b06ff8bcdd4589d37cc Mon Sep 17 00:00:00 2001 From: Rowdy Mitchell Chotkan Date: Wed, 28 Feb 2024 09:18:18 +0100 Subject: [PATCH 6/6] Remove daemon in apk main --- .github/workflows/apk_main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/apk_main.yml b/.github/workflows/apk_main.yml index 869d3b6ae..ea986ceb3 100644 --- a/.github/workflows/apk_main.yml +++ b/.github/workflows/apk_main.yml @@ -27,6 +27,7 @@ jobs: run: | echo $KEYSTORE_FILE | base64 -d > app/build.keystore ./gradlew assembleRelease \ + --no-daemon \ -Pandroid.injected.signing.store.file=$(pwd)/app/build.keystore \ -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \ -Pandroid.injected.signing.key.alias=$KEY_ALIAS \