Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions .github/workflows/android-app-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
branches:
- main
workflow_dispatch:
inputs:
source_ref:
description: "Optional branch, tag, or SHA to check out. Leave empty to distribute the selected workflow branch."
required: false
type: string

permissions:
contents: read
Expand All @@ -14,8 +20,8 @@ concurrency:

jobs:
distribute:
if: github.ref == 'refs/heads/main'
runs-on: blacksmith-4vcpu-ubuntu-2404
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: [self-hosted, Linux, X64, android]
environment: android-release
defaults:
run:
Expand All @@ -25,10 +31,33 @@ jobs:
FIREBASE_TESTER_GROUP: android-internal
FIREBASE_TOOLS_VERSION: 15.24.0
EXPECTED_UPLOAD_CERT_SHA256: 9E:FB:99:19:6B:2D:F6:56:FD:FA:1D:88:3D:33:00:7E:0F:E0:DA:28:AB:FF:A6:F8:BC:C3:3D:42:0F:CA:E1:37
SOURCE_REF: ${{ github.event.inputs.source_ref }}

steps:
- name: Checkout merged commit
- name: Validate source ref
working-directory: .
shell: bash
run: |
set -euo pipefail
if [[ -z "${SOURCE_REF:-}" ]]; then
exit 0
fi
if [[ ! "$SOURCE_REF" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "source_ref must be a branch, tag, or SHA (letters, digits, '.', '_', '/', '-')." >&2
exit 1
fi

- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.source_ref || github.sha }}

- name: Record distributed commit
working-directory: .
shell: bash
run: |
set -euo pipefail
echo "DISTRIBUTED_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"

- name: Set distribution version
shell: bash
Expand Down Expand Up @@ -103,7 +132,7 @@ jobs:
- name: Upload signed APK artifact
uses: actions/upload-artifact@v4
with:
name: android-app-distribution-${{ github.sha }}-${{ github.run_number }}
name: android-app-distribution-${{ env.DISTRIBUTED_SHA }}-${{ github.run_number }}
path: android/app/build/outputs/apk/release/app-release.apk
if-no-files-found: error
retention-days: 7
Expand All @@ -112,9 +141,14 @@ jobs:
shell: bash
run: |
set -euo pipefail
distributed_sha="$(git rev-parse HEAD)"
short_sha="$(git rev-parse --short=12 HEAD)"
subject="$(git log -1 --pretty=%s)"
release_notes="Merge $short_sha: $subject"
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
release_notes="Dispatch $short_sha: $subject"
else
release_notes="Merge $short_sha: $subject"
fi
if ! distribution_output="$(
npx --yes "firebase-tools@$FIREBASE_TOOLS_VERSION" \
appdistribution:distribute \
Expand All @@ -140,7 +174,10 @@ jobs:
{
echo "## Android App Distribution"
echo
echo "- Commit: \`$GITHUB_SHA\`"
echo "- Commit: \`$distributed_sha\`"
if [[ -n "${SOURCE_REF:-}" ]]; then
echo "- Source ref: \`$SOURCE_REF\`"
fi
echo "- Version: \`$ANDROID_VERSION_NAME\` (\`$ANDROID_VERSION_CODE\`)"
echo "- Tester group: \`$FIREBASE_TESTER_GROUP\`"
echo "- [Firebase release]($firebase_console_uri)"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
jobs:
android-checks:
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: [self-hosted, Linux, X64, android]
defaults:
run:
working-directory: android
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ concurrency:
jobs:
release:
if: github.ref == 'refs/heads/main'
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: [self-hosted, Linux, X64, android]
environment: android-release
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-test-lab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
jobs:
robo:
if: github.ref == 'refs/heads/main'
runs-on: blacksmith-4vcpu-ubuntu-2404
runs-on: [self-hosted, Linux, X64, android]
environment: android-release
env:
GCP_PROJECT_ID: opencode-mobile-release
Expand Down
47 changes: 42 additions & 5 deletions .github/workflows/ios-app-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
branches:
- main
workflow_dispatch:
inputs:
source_ref:
description: "Optional branch, tag, or SHA to check out. Leave empty to distribute the selected workflow branch."
required: false
type: string

permissions:
contents: read
Expand All @@ -14,7 +20,7 @@ concurrency:

jobs:
distribute:
if: github.ref == 'refs/heads/main'
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
runs-on: [self-hosted, macOS, mac-mini]
environment: ios-release
defaults:
Expand All @@ -29,10 +35,33 @@ jobs:
FIREBASE_APP_ID: 1:569439646238:ios:2ffd276bbaf8a1528df40f
FIREBASE_TESTER_GROUP: ios-internal
FIREBASE_TOOLS_VERSION: 15.24.0
SOURCE_REF: ${{ github.event.inputs.source_ref }}

steps:
- name: Checkout merged commit
- name: Validate source ref
working-directory: .
shell: bash
run: |
set -euo pipefail
if [[ -z "${SOURCE_REF:-}" ]]; then
exit 0
fi
if [[ ! "$SOURCE_REF" =~ ^[A-Za-z0-9._/-]+$ ]]; then
echo "source_ref must be a branch, tag, or SHA (letters, digits, '.', '_', '/', '-')." >&2
exit 1
fi

- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.source_ref || github.sha }}

- name: Record distributed commit
working-directory: .
shell: bash
run: |
set -euo pipefail
echo "DISTRIBUTED_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"

- name: Set distribution build number
shell: bash
Expand Down Expand Up @@ -193,7 +222,7 @@ jobs:
- name: Upload signed Ad Hoc IPA artifact
uses: actions/upload-artifact@v4
with:
name: ios-app-distribution-${{ github.sha }}-${{ github.run_number }}
name: ios-app-distribution-${{ env.DISTRIBUTED_SHA }}-${{ github.run_number }}
path: ${{ env.IOS_IPA_PATH }}
if-no-files-found: error
retention-days: 7
Expand All @@ -202,9 +231,14 @@ jobs:
shell: bash
run: |
set -euo pipefail
distributed_sha="$(git rev-parse HEAD)"
short_sha="$(git rev-parse --short=12 HEAD)"
subject="$(git log -1 --pretty=%s)"
release_notes="Merge $short_sha: $subject"
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
release_notes="Dispatch $short_sha: $subject"
else
release_notes="Merge $short_sha: $subject"
fi
if ! distribution_output="$(
npx --yes "firebase-tools@$FIREBASE_TOOLS_VERSION" \
appdistribution:distribute \
Expand All @@ -231,7 +265,10 @@ jobs:
{
echo "## iOS App Distribution"
echo
echo "- Commit: \`$GITHUB_SHA\`"
echo "- Commit: \`$distributed_sha\`"
if [[ -n "${SOURCE_REF:-}" ]]; then
echo "- Source ref: \`$SOURCE_REF\`"
fi
echo "- Marketing version: \`$IOS_MARKETING_VERSION\`"
echo "- Build number: \`$IOS_BUILD_NUMBER\`"
echo "- Tester group: \`$FIREBASE_TESTER_GROUP\`"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/smoke-mac-mini.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Smoke Mac mini

# OPE-114 — proves the private Mac mini self-hosted runner can pick up
# a job via outbound polling (no inbound ports, no Blacksmith).
# Android / Blacksmith runners are untouched. Delete after OPE-115 if desired.
# a job via outbound polling (no inbound ports). Android stays on fedora-box.
# Delete after OPE-115 if desired.

on:
workflow_dispatch:
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ npm run api:sync # fetch OpenAPI spec and generate clients
## CI

Checks run for every **ready-for-review** pull request (drafts are skipped).
Android stays on Blacksmith Linux; iOS runs on the private Mac mini
self-hosted runner. Android Build and iOS Build stay manual.
Android runs on the private Fedora box (`self-hosted, Linux, X64, android`);
iOS runs on the private Mac mini (`self-hosted, macOS, mac-mini`). Android
Build and iOS Build stay manual.

| Workflow | Trigger | Runner | What it does |
|---|---|---|---|
| Android Checks | PR (non-draft) + dispatch | Blacksmith Linux | ktlint/lint (soft-fail) + unit tests |
| Android Checks | PR (non-draft) + dispatch | Fedora box (`self-hosted, Linux, X64, android`) | ktlint/lint (soft-fail) + unit tests |
| iOS Checks | PR (non-draft) + dispatch | Mac mini (`self-hosted, macOS, mac-mini`) | Build, analyzer, unit tests |
| Android Build | `workflow_dispatch` | Blacksmith Linux | Assemble debug APK |
| Android Release | `workflow_dispatch` on `main` | Blacksmith Linux | Build and verify signed AAB + APK, then publish to Play internal |
| Android App Distribution | `push` to `main` | Blacksmith Linux | Build and verify a signed APK, then distribute it to the private Firebase tester group |
| Android Test Lab | `workflow_dispatch` on `main` | Blacksmith Linux | Run bounded Robo tests against a signed release APK |
| Android Build | `workflow_dispatch` | Fedora box (`self-hosted, Linux, X64, android`) | Assemble debug APK |
| Android Release | `workflow_dispatch` on `main` | Fedora box (`self-hosted, Linux, X64, android`) | Build and verify signed AAB + APK, then publish to Play internal |
| Android App Distribution | `push` to `main`, or `workflow_dispatch` | Fedora box (`self-hosted, Linux, X64, android`) | Build and verify a signed APK, then distribute it to the private Firebase tester group |
| Android Test Lab | `workflow_dispatch` on `main` | Fedora box (`self-hosted, Linux, X64, android`) | Run bounded Robo tests against a signed release APK |
| iOS Build | `workflow_dispatch` | Mac mini (`self-hosted, macOS, mac-mini`) | Simulator build |
| iOS App Distribution | `push` to `main`, or `workflow_dispatch` | Mac mini (`self-hosted, macOS, mac-mini`) | Build and verify a signed Ad Hoc IPA, then distribute it to the private Firebase tester group |

To block merges, require status checks `android-checks` and `ios-checks` on
`main` (repository ruleset or branch protection, strict up-to-date). See
Expand All @@ -83,13 +85,20 @@ Manual runs:
gh workflow run "Android Checks" --ref main
gh workflow run "Android Release" --ref main -f version_name=0.1.0
gh workflow run "Android Test Lab" --ref main -f release_run_id=<android-release-run-id>
gh workflow run "Android App Distribution" --ref main
gh workflow run "Android App Distribution" --ref feature/ope-146-server-api-v2
gh workflow run "iOS App Distribution" --ref main
gh workflow run "iOS App Distribution" --ref feature/ope-146-server-api-v2
```

Android Release, Android App Distribution, and Android Test Lab use the
protected `android-release` environment. See the
protected `android-release` environment. iOS App Distribution uses the
protected `ios-release` environment. See the
[Android release operator runbook](docs/features/android-release-distribution/operator-runbook.md)
for secrets, artifacts, Play internal testing, Test Lab, and recovery
instructions. iOS runner setup, reboot recovery, and fallback are in
and
[iOS release operator runbook](docs/features/ios-release-distribution/operator-runbook.md)
for secrets, artifacts, and recovery instructions. iOS runner setup, reboot
recovery, and fallback are in
[docs/mac-mini-runner.md](docs/mac-mini-runner.md).

After cloning, run `./scripts/sync-agent-links.sh` if agent symlinks are missing.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
package dev.opencode.mobile.data.remote

import dev.opencode.mobile.data.remote.dto.AgentDto
import dev.opencode.mobile.data.remote.dto.ApiListEnvelope
import dev.opencode.mobile.data.remote.dto.V2AgentDto
import dev.opencode.mobile.network.OpencodeHttpClient
import dev.opencode.mobile.network.applyDirectory
import dev.opencode.mobile.network.applyLocationDirectory
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get

class AgentsApi(
private val httpClient: OpencodeHttpClient,
class AgentsApi private constructor(
private val httpClient: ClientProvider,
) {
constructor(httpClient: OpencodeHttpClient) : this(ClientProvider(httpClient::get))

internal constructor(httpClient: HttpClient) : this(ClientProvider { httpClient })

suspend fun listAgents(directory: String? = null): List<AgentDto> =
httpClient
.get()
.get("agent") {
applyDirectory(directory)
}.body()

suspend fun listAgentsV2(directory: String? = null): List<V2AgentDto> =
httpClient
.get()
.get("api/agent") {
applyLocationDirectory(directory)
}.body<ApiListEnvelope<V2AgentDto>>()
.data

private fun interface ClientProvider {
fun get(): HttpClient
}
}
Loading
Loading