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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 14 additions & 14 deletions .agents/skills/testing-ios-simulator/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: testing-ios-simulator
description: Build and launch the Logseq Chat iOS app in an iOS simulator on macOS arm64 (Xcode + cross OCaml toolchain), including the iOS SDK function-detection pitfalls in bootstrap-ios-ocaml.sh.
description: Build and launch the Logseq iOS app in an iOS simulator on macOS arm64 (Xcode + cross OCaml toolchain), including the iOS SDK function-detection pitfalls in bootstrap-ios-ocaml.sh.
---

# Logseq Chat iOS Simulator Build & Launch
# Logseq iOS Simulator Build & Launch

## Prerequisites
- macOS arm64 with Xcode installed (`xcodebuild -version` works).
Expand All @@ -14,14 +14,14 @@ description: Build and launch the Logseq Chat iOS app in an iOS simulator on mac
## Build steps
1. `scripts/bootstrap-ios-ocaml.sh simulator` — builds host + cross OCaml 5.5.0 under
`_build/apple-toolchains/ios/` (long first run; stamps skip rebuilds).
2. `scripts/build-mobile-ios-simulator.sh` — builds `shared/native/logseq_chat_mobile_entry.exe.o`
via dune context `ios_simulator`, then `swift build` (product `LogseqChatShell`),
2. `scripts/build-mobile-ios-simulator.sh` — builds `shared/native/logseq_mobile_entry.exe.o`
via dune context `ios_simulator`, then `swift build` (product `LogseqShell`),
xcodebuild for the share/widget extensions, and assembles+codesigns
`.build/LogseqChat.app`. Note: the script can exit non-zero at the end even when all
`.build/Logseq.app`. Note: the script can exit non-zero at the end even when all
artifacts are produced correctly — re-running it (incremental) and checking for
`.build/LogseqChat.app/LogseqChat` is the practical check.
3. `xcrun simctl install booted .build/LogseqChat.app`
4. `xcrun simctl launch booted com.logseq.chat` → prints `com.logseq.chat: <pid>`;
`.build/Logseq.app/Logseq` is the practical check.
3. `xcrun simctl install booted .build/Logseq.app`
4. `xcrun simctl launch booted com.logseq.logseq` → prints `com.logseq.logseq: <pid>`;
verify the process stays alive via
`xcrun simctl spawn booted launchctl list | grep logseq`.
5. Screenshot: `xcrun simctl io booted screenshot out.png`.
Expand All @@ -37,15 +37,15 @@ description: Build and launch the Logseq Chat iOS app in an iOS simulator on mac
`xcrun --sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -isysroot <sdk> -c t.c`
where t.c calls the function after including the SDK headers.
- First launch may show a local-network permission alert; dismiss it via Simulator UI.
- The app opens to a "Logseq Chat / Sign in" screen (Cognito hosted UI); going past it
- The app opens to a "Logseq / Sign in" screen (Cognito hosted UI); going past it
requires credentials.
- `duniverse/` pulls only the lockfile dirs (129). The `logseq/*` pins NOT vendored
(`datascript-ocaml`, `lg`, `lui`, `mldoc`, `persistent-sorted-set-ocaml`,
`signal-lg`) must be cloned manually into `duniverse/` at the SHAs listed in
`logseq_chat.opam` — same loop as `.github/workflows/e2e.yml`. A fresh
`logseq.opam` — same loop as `.github/workflows/e2e.yml`. A fresh
`opam-monorepo pull` wipes these dirs, so re-clone them after each pull.
- `scripts/build-mobile-ocaml.sh` regenerates `_build/dune-workspace.mobile` from
`dune-workspace.mobile`; set `LOGSEQ_CHAT_OPAM_SWITCH=5.5.0` when running outside
`dune-workspace.mobile`; set `LOGSEQ_OPAM_SWITCH=5.5.0` when running outside
`opam exec`.

## Maestro e2e (test-ios-e2e-suite.sh)
Expand All @@ -60,11 +60,11 @@ description: Build and launch the Logseq Chat iOS app in an iOS simulator on mac
(needs `JAVA_HOME=$(/usr/libexec/java_home -v 21)`), then
`DB_SYNC_PORT=8787 DB_SYNC_DATA_DIR=~/db-sync-data ./start.sh`;
health check `curl http://127.0.0.1:8787/health`.
- Run: `LOGSEQ_CHAT_IOS_SKIP_BUILD=1 LOGSEQ_CHAT_E2E_USERNAME=<u> LOGSEQ_CHAT_E2E_PASSWORD=<p> ./scripts/test-ios-e2e-suite.sh smoke`
- Run: `LOGSEQ_IOS_SKIP_BUILD=1 LOGSEQ_E2E_USERNAME=<u> LOGSEQ_E2E_PASSWORD=<p> ./scripts/test-ios-e2e-suite.sh smoke`
(4 flows: capture-responsive, cold-start-composer, search-status-regression, sidebar).
- `scripts/test-ios-e2e.sh` wipes the app data container between flows; `<container>/tmp`
must be recreated (the script does `mkdir -p`) or the OCaml core crashes writing the
initial graph snapshot via `Filename.temp_file` (`Sys_error ...tmp/logseq-chat-initial-*.snapshot`).
initial graph snapshot via `Filename.temp_file` (`Sys_error ...tmp/logseq-initial-*.snapshot`).

## Devin Secrets Needed
- `LOGSEQ_CHAT_TEST_USERNAME` / `LOGSEQ_CHAT_TEST_PASSWORD` for hosted sign-in and e2e.
- `LOGSEQ_TEST_USERNAME` / `LOGSEQ_TEST_PASSWORD` for hosted sign-in and e2e.
24 changes: 12 additions & 12 deletions .agents/skills/testing-ocaml-core-linux/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: testing-ocaml-core-linux
description: Build and run the OCaml core test gate on Linux (opam deps, duniverse restore, lg prefix cache + dune shared cache, parallel test-chunk layout in shared/test/dune).
---

# Logseq Chat OCaml core testing on Linux
# Logseq OCaml core testing on Linux

The only Linux-runnable surface is the OCaml core in `shared/`. The gate is:

Expand All @@ -18,9 +18,9 @@ Never `swift test` — it hangs on Linux.

Two layered caches make `rm -rf _build` rebuilds fast; keep both warm:

- `chat/.lg-cache/` — lg's content-addressed compile cache, outside `_build`,
- `Logseq/.lg-cache/` — lg's content-addressed compile cache, outside `_build`,
survives clean builds. Prefix keys are recorded in each `*.state` artifact
(provenance key, lg >= the cache-fix revision pinned in `logseq_chat.opam`);
(provenance key, lg >= the cache-fix revision pinned in `logseq.opam`);
do not digest state bytes.
- Dune shared cache — off by default. Enable per machine in
`~/.config/dune/config`:
Expand All @@ -43,24 +43,24 @@ A cold build where `.lg-cache` is ALSO empty recompiles every cljc (~4min).
- `lg-native-cmi-deps` alias (also in `shared/native/dune`) forces vendored
duniverse cmis to exist before lg runs; without it lg falls back to
same-named opam cmis and fails with "inconsistent assumptions".
- `logseq_chat_lui_test_base` — chunk compiled off
`../native/logseq_chat_lg_core_native.state` (emitted by the core rule's
`--emit-state`), emits `include Logseq_chat_lg_core_native` + literal/lui/
- `logseq_lui_test_base` — chunk compiled off
`../native/logseq_lg_core_native.state` (emitted by the core rule's
`--emit-state`), emits `include Logseq_lg_core_native` + literal/lui/
app/lg-test framework.
- `logseq_chat_lui_test_p1..p8` — 41 test namespaces as independent chunks
off `logseq_chat_lui_test_base.state` (`--compile-files-chunk-from` +
- `logseq_lui_test_p1..p8` — 41 test namespaces as independent chunks
off `logseq_lui_test_base.state` (`--compile-files-chunk-from` +
`--prefix-interface` pointing at the base cmi). Add new test files to a
chunk (or a new chunk) — they compile in parallel.
- Generated chunk modules must be listed on a LIBRARY (`logseq_chat_lui_test_parts`,
- Generated chunk modules must be listed on a LIBRARY (`logseq_lui_test_parts`,
`wrapped false`): dune does not emit compile rules for generated modules on
an executable. The runner exe needs `(link_flags -linkall)` — test
registration is initializer side-effects that dead-stripping drops.
- `logseq_chat_lui_test_z` is the last module alphabetically: it carries
- `logseq_lui_test_z` is the last module alphabetically: it carries
`run.cljc`, which must run after all chunk registrations.

## Environment restore (if duniverse/ is missing)

`duniverse/` is gitignored. Restore per `logseq_chat.opam.locked`: clone the
`duniverse/` is gitignored. Restore per `logseq.opam.locked`: clone the
opam source trees for each vendored package at the locked commit (private
repos lg/lui/signal-lg need `LOGSEQ_GITHUB_PAT`). `duniverse/lg` must match the
lg pin in `logseq_chat.opam` — `%{bin:lg}` resolves to the vendored copy.
lg pin in `logseq.opam` — `%{bin:lg}` resolves to the vendored copy.
210 changes: 210 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# Builds the Logseq Android app as a signed release APK and uploads it as a
# workflow artifact for download. Modeled on logseq/logseq's build-android.yml;
# the Play upload steps are intentionally left out for now.

name: Build-Android

on:
workflow_dispatch:
inputs:
git-ref:
description: "Release Git Ref (Which branch or tag to build?)"
required: true
default: "main"

env:
JAVA_VERSION: '21'
LOGSEQ_ANDROID_ABI: arm64-v8a

jobs:
build-apk:
runs-on: ubuntu-latest
timeout-minutes: 120
env:
LOGSEQ_OPAM_SWITCH: ${{ github.workspace }}
GIT_TERMINAL_PROMPT: "0"
GIT_CONFIG_COUNT: 3
GIT_CONFIG_KEY_0: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_0: "git@github.com:"
GIT_CONFIG_KEY_1: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_1: "ssh://git@github.com/"
GIT_CONFIG_KEY_2: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_2: "git+ssh://git@github.com/"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git-ref }}

- name: System dependencies
run: sudo apt-get install -y libsqlite3-dev libffi-dev pkg-config

- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}

- name: Restore opam root
id: opam-root
uses: actions/cache/restore@v4
with:
path: ~/.opam
key: opam-root-${{ runner.os }}-ocaml-5.5

- name: Restore opam switch
id: opam-switch
uses: actions/cache/restore@v4
with:
path: _opam
key: opam-switch-${{ runner.os }}-ocaml-5.5-${{ hashFiles('logseq.opam.locked', 'logseq.opam', '.github/workflows/ci.yml') }}

# See ci.yml: on a dual cache hit only the opam binary is needed.
- name: Install opam binary
if: steps.opam-root.outputs.cache-hit == 'true' && steps.opam-switch.outputs.cache-hit == 'true'
run: |
mkdir -p ~/.local/bin
curl -fsSL https://github.com/ocaml/opam/releases/download/2.6.0/opam-2.6.0-x86_64-linux -o ~/.local/bin/opam
chmod +x ~/.local/bin/opam
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
eval $(opam env)
opam --version && ocaml -version

- uses: ocaml/setup-ocaml@v3
if: steps.opam-root.outputs.cache-hit != 'true' || steps.opam-switch.outputs.cache-hit != 'true'
with:
ocaml-compiler: "5.5"
opam-pin: false

- name: Save opam root
if: steps.opam-root.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.opam
key: opam-root-${{ runner.os }}-ocaml-5.5

- name: Install opam dependencies
if: steps.opam-switch.outputs.cache-hit != 'true'
run: |
eval $(opam env)
opam pin add -n -y melange-edn-core git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-edn-native git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-transit-core git+https://github.com/logseq/melange-transit.git#main
opam pin add -n -y melange-transit-native git+https://github.com/logseq/melange-transit.git#main
opam install . --deps-only --yes --with-test --assume-depexts
# Drop installed copies of lockfile-vendored packages (see ci.yml).
comm -12 \
<(grep -oE '"[a-zA-Z0-9_.-]+" \{= "[^"]*" & \?vendor\}' logseq.opam.locked | cut -d'"' -f2 | sort) \
<(opam list --installed --short | sort) \
| xargs -r opam remove -y
opam install -y melange.7.0.1-55
opam install -y opam-monorepo.0.3.6

- name: Save opam switch
if: steps.opam-switch.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: _opam
key: opam-switch-${{ runner.os }}-ocaml-5.5-${{ hashFiles('logseq.opam.locked', 'logseq.opam', '.github/workflows/ci.yml') }}

# Share ci.yml's duniverse cache key so a CI-populated cache is reused.
- name: Restore duniverse
id: duniverse
uses: actions/cache/restore@v4
with:
path: duniverse
key: duniverse-${{ hashFiles('logseq.opam.locked', 'logseq.opam', '.github/workflows/ci.yml') }}

- name: Pull vendored dependencies
if: steps.duniverse.outputs.cache-hit != 'true'
run: |
set -e
eval $(opam env)
git config --global url."https://github.com/".insteadOf "git@github.com:"
git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://github.com/".insteadOf "git+ssh://git@github.com/"
for attempt in 1 2 3; do
opam exec -- opam-monorepo pull && break
[ "$attempt" -lt 3 ] || exit 1
echo "opam-monorepo pull failed (attempt $attempt); retrying" >&2
sleep 10
done
for pin in $(grep -oE 'logseq/[A-Za-z0-9_-]+\.git#[A-Za-z0-9._/-]+' logseq.opam | sort -u); do
url="${pin%%#*}"; sha="${pin##*#}"; name="$(basename "$url" .git)"
if [ -d "duniverse/$name" ]; then
continue
fi
git clone --quiet "https://github.com/$url" "duniverse/$name"
if ! git -C "duniverse/$name" checkout --quiet "$sha"; then
git -C "duniverse/$name" fetch --quiet "https://github.com/$url" "$sha"
git -C "duniverse/$name" checkout --quiet FETCH_HEAD
fi
done

- name: Save duniverse
if: steps.duniverse.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: duniverse
key: duniverse-${{ hashFiles('logseq.opam.locked', 'logseq.opam', '.github/workflows/ci.yml') }}

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Setup Android SDK
uses: android-actions/setup-android@v3.2.2
with:
packages: platform-tools

- name: Accept Android SDK licenses
run: yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses || true

- name: Restore Android OCaml toolchain
id: android-toolchain
uses: actions/cache/restore@v4
with:
path: |
_build/android-toolchain
_build/android-dependency-sources
_build/android-sqlite-host
key: android-toolchain-${{ runner.os }}-arm64-v8a-5.5.0-${{ hashFiles('scripts/bootstrap-android-ocaml.sh', 'scripts/build-mobile-libffi.sh') }}

- name: Build Android release APK
# assembleRelease depends on buildAndroidNativeCore, which runs
# scripts/build-android-native.sh for $LOGSEQ_ANDROID_ABI; the Kotlin
# :lui module resolves to duniverse/lui/platform/android/lui.
run: |
eval $(opam env)
export LOGSEQ_OPAM_SWITCH="$(opam switch show)"
export DUNE="$(command -v dune)"
./gradlew :app:assembleRelease
working-directory: android

- name: Save Android OCaml toolchain
if: always() && steps.android-toolchain.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
_build/android-toolchain
_build/android-dependency-sources
_build/android-sqlite-host
key: android-toolchain-${{ runner.os }}-arm64-v8a-5.5.0-${{ hashFiles('scripts/bootstrap-android-ocaml.sh', 'scripts/build-mobile-libffi.sh') }}

- name: Sign Android APK
run: |
echo ${{ secrets.ANDROID_KEYSTORE }} | base64 -d > keystore.jks
$ANDROID_SDK_ROOT/build-tools/34.0.0/apksigner sign \
--ks keystore.jks --ks-pass "pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" \
--in app/build/outputs/apk/release/app-release-unsigned.apk \
--out app-signed.apk
Comment thread
tiensonqin marked this conversation as resolved.
working-directory: android

- name: Rename APK
run: |
mkdir builds
mv android/app-signed.apk "./builds/Logseq-android-${GITHUB_SHA::7}.apk"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: logseq-android-builds
path: builds
Loading