From 4644ac885a743a45907c9e6547ee23c94acdc4dd Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 9 Sep 2026 17:32:05 +0200 Subject: [PATCH 1/5] ci: publish regtest apk artifact on pr builds Co-Authored-By: Claude Fable 5.1 --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 764252d41b..1ca40744da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,10 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: - name: Checkout uses: actions/checkout@v7 @@ -53,6 +57,45 @@ jobs: CHATWOOT_API: ${{ secrets.CHATWOOT_API }} run: ./gradlew assembleDevDebug + - name: Upload APK + id: upload-apk + uses: actions/upload-artifact@v7 + with: + name: bitkit-dev-debug-apk_${{ github.run_number }} + path: app/build/outputs/bitkit/devDebug/bitkit-dev-debug-*-universal.apk + retention-days: 30 + if-no-files-found: error + + - name: Comment APK link on PR + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false + uses: actions/github-script@v8 + env: + ARTIFACT_URL: ${{ steps.upload-apk.outputs.artifact-url }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + with: + script: | + const marker = ''; + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const body = [ + marker, + '### Regtest APK', + '', + `Built from ${process.env.HEAD_SHA} ([run](${runUrl})).`, + '', + `[Download bitkit-dev-debug universal APK](${process.env.ARTIFACT_URL}) (expires in 30 days).`, + ].join('\n'); + const { data: comments } = await github.rest.issues.listComments({ + ...context.repo, + issue_number: context.issue.number, + per_page: 100, + }); + const existing = comments.find((c) => c.body?.includes(marker)); + if (existing) { + await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body }); + } else { + await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body }); + } + - name: Run tests run: ./gradlew testDevDebugUnitTest From 57a3409f7f2de645dd932e74d04f09ab8bb93ff6 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 9 Sep 2026 18:42:35 +0200 Subject: [PATCH 2/5] ci: isolate apk comment job and paginate lookup Co-Authored-By: Claude Fable 5.1 --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ca40744da..676fc9f52f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ jobs: permissions: contents: read - pull-requests: write + + outputs: + artifact-url: ${{ steps.upload-apk.outputs.artifact-url }} steps: - name: Checkout @@ -66,11 +68,29 @@ jobs: retention-days: 30 if-no-files-found: error + - name: Run tests + run: ./gradlew testDevDebugUnitTest + + - name: Upload test report + uses: actions/upload-artifact@v7 + with: + name: unit_test_report_${{ github.run_number }} + path: app/build/reports/tests/testDevDebugUnitTest/ + retention-days: 30 + + apk-comment: + needs: build + if: always() && needs.build.outputs.artifact-url != '' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false + runs-on: ubuntu-latest + + permissions: + pull-requests: write + + steps: - name: Comment APK link on PR - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false uses: actions/github-script@v8 env: - ARTIFACT_URL: ${{ steps.upload-apk.outputs.artifact-url }} + ARTIFACT_URL: ${{ needs.build.outputs.artifact-url }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} with: script: | @@ -84,7 +104,7 @@ jobs: '', `[Download bitkit-dev-debug universal APK](${process.env.ARTIFACT_URL}) (expires in 30 days).`, ].join('\n'); - const { data: comments } = await github.rest.issues.listComments({ + const comments = await github.paginate(github.rest.issues.listComments, { ...context.repo, issue_number: context.issue.number, per_page: 100, @@ -95,13 +115,3 @@ jobs: } else { await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body }); } - - - name: Run tests - run: ./gradlew testDevDebugUnitTest - - - name: Upload test report - uses: actions/upload-artifact@v7 - with: - name: unit_test_report_${{ github.run_number }} - path: app/build/reports/tests/testDevDebugUnitTest/ - retention-days: 30 From 86882167105ba5a160c0c8ffe3a21fb3b7dcd819 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 10 Sep 2026 00:37:34 +0200 Subject: [PATCH 3/5] ci: keep packages read and upload apk after tests --- .github/workflows/ci.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 676fc9f52f..8cfc939dd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: permissions: contents: read + packages: read outputs: artifact-url: ${{ steps.upload-apk.outputs.artifact-url }} @@ -53,21 +54,13 @@ jobs: GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} - name: Build debug app + id: build env: GITHUB_ACTOR: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CHATWOOT_API: ${{ secrets.CHATWOOT_API }} run: ./gradlew assembleDevDebug - - name: Upload APK - id: upload-apk - uses: actions/upload-artifact@v7 - with: - name: bitkit-dev-debug-apk_${{ github.run_number }} - path: app/build/outputs/bitkit/devDebug/bitkit-dev-debug-*-universal.apk - retention-days: 30 - if-no-files-found: error - - name: Run tests run: ./gradlew testDevDebugUnitTest @@ -78,6 +71,16 @@ jobs: path: app/build/reports/tests/testDevDebugUnitTest/ retention-days: 30 + - name: Upload APK + id: upload-apk + if: always() && steps.build.outcome == 'success' + uses: actions/upload-artifact@v7 + with: + name: bitkit-dev-debug-apk_${{ github.run_number }} + path: app/build/outputs/bitkit/devDebug/bitkit-dev-debug-*-universal.apk + retention-days: 30 + if-no-files-found: error + apk-comment: needs: build if: always() && needs.build.outputs.artifact-url != '' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false From 7e6508df67f03b6bfd44f9425d95b517c5ce8321 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 10 Sep 2026 13:56:52 +0200 Subject: [PATCH 4/5] ci: upload test report when tests fail --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cfc939dd4..2a05681823 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,7 @@ jobs: run: ./gradlew testDevDebugUnitTest - name: Upload test report + if: always() && steps.build.outcome == 'success' uses: actions/upload-artifact@v7 with: name: unit_test_report_${{ github.run_number }} From f85f88f4dec96de06a4d7c5a8b1545d44c006e3c Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 10 Sep 2026 14:17:56 +0200 Subject: [PATCH 5/5] ci: publish apk only when unit tests pass --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a05681823..8d9e3b0465 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,6 @@ jobs: - name: Upload APK id: upload-apk - if: always() && steps.build.outcome == 'success' uses: actions/upload-artifact@v7 with: name: bitkit-dev-debug-apk_${{ github.run_number }} @@ -84,7 +83,7 @@ jobs: apk-comment: needs: build - if: always() && needs.build.outputs.artifact-url != '' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false + if: needs.build.outputs.artifact-url != '' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false runs-on: ubuntu-latest permissions: