Skip to content
Open
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
228 changes: 121 additions & 107 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: CI
on:
push:
branches: [master, beta]
branches: [master, beta, ci2]
pull_request:
branches: [master, beta]
workflow_dispatch:
jobs:
cancel_previous:
if: ${{ github.event_name != 'push' }}
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.12.1
Expand All @@ -15,144 +16,157 @@ jobs:
build-and-test:
needs: cancel_previous
runs-on: 'ubuntu-latest'
env:
YARN_ENABLE_HARDENED_MODE: 0
steps:
- uses: actions/checkout@v4
# Workaround for corepack enable in node
# Source: (https://github.com/actions/setup-node/issues/899#issuecomment-1828798029)
- uses: actions/setup-node@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
- name: devbox installer
uses: jetify-com/devbox-install-action@v0.14.0
with:
node-version: 20
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
# End workaround

- name: Install
run: yarn install --immutable
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Test
run: yarn test --coverage
enable-cache: 'true'
- name: Nix GC (pre-build)
run: |
nix-collect-garbage -d || true
du -sh /nix/store || true
- name: build
run: devbox run build

run-e2e-ios:
runs-on: 'macos-13'
runs-on: ['macos-15' ]
env:
YARN_ENABLE_HARDENED_MODE: 0
XCODE_VERSION: '26.1.1'
strategy:
matrix:
include:
- name: ios-min
ios-device: "iPhone 14"
ios-runtime: "18.5"
- name: ios-latest
ios-device: "iPhone 17"
ios-runtime: "26.1"
steps:
- uses: actions/checkout@v4
- name: Free Disk Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Install applesimutils
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null

- uses: actions/checkout@v4
# Workaround for corepack enable in node
# Source: (https://github.com/actions/setup-node/issues/899#issuecomment-1828798029)
- uses: actions/setup-node@v4
xcode-version: '26.1.1'
- name: CocoaPods cache
uses: actions/cache@v4
with:
node-version: 20
- run: corepack enable
- uses: actions/setup-node@v4
path: |
~/Library/Caches/CocoaPods
key: cocoapods-${{ runner.os }}-${{ env.XCODE_VERSION }}-${{ hashFiles('examples/E2E/ios/Podfile.lock') }}
restore-keys: |
cocoapods-${{ runner.os }}-${{ env.XCODE_VERSION }}-
cocoapods-${{ runner.os }}-
- name: DerivedData cache
uses: actions/cache@v4
with:
node-version: 20
cache: yarn
# End workaround

- name: Bootstrap
run: yarn install && yarn e2e install && yarn e2e pods

- name: Bundle Build
run: yarn build

- name: Detox - Build
run: RCT_NO_LAUNCH_PACKAGER=1 yarn e2e build:ios

- name: Detox - Test
run: yarn e2e test:ios
path: |
~/Library/Developer/Xcode/DerivedData
key: derived-${{ runner.os }}-${{ env.XCODE_VERSION }}-${{ hashFiles('examples/E2E/ios/Podfile.lock') }}
restore-keys: |
derived-${{ runner.os }}-${{ env.XCODE_VERSION }}-
derived-${{ runner.os }}-
- name: devbox installer
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
# --omit-nix-env is important to use the macos system c toolchain instead of the nix toolchain
- name: iOS setup (simulators, pods)
env:
IOS_DEVICE_NAMES: ${{ matrix.ios-device }}
IOS_RUNTIME: ${{ matrix.ios-runtime }}
run: |
set -euo pipefail
devbox shell --omit-nix-env --command "devbox run setup-ios && yarn install && yarn e2e install && yarn e2e pods"
- name: iOS build
run: |
set -euo pipefail
devbox shell --omit-nix-env --command "yarn build && yarn e2e build:ios"
- name: iOS E2E Tests
env:
DETOX_IOS_DEVICE: ${{ matrix.ios-device }}
run: |
set -euo pipefail
devbox shell --omit-nix-env --command "DETOX_IOS_DEVICE='${{ matrix.ios-device }}' yarn e2e test:ios"

run-e2e-android:
runs-on: 'macos-13' # This is important, linux cannot run the emulator graphically for e2e tests
runs-on: 'ubuntu-22.04'
strategy:
matrix:
api-level: [21]
profile: ['pixel_xl']
env:
YARN_ENABLE_HARDENED_MODE: 0
include:
- name: android-min
avd-name: pixel_API21_x86_64
start-script: start-android-minsdk
- name: android-latest
avd-name: medium_phone_API33_x86_64
start-script: start-android-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
- name: Yarn cache
uses: actions/cache@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'

path: |
~/.cache/yarn
.yarn/cache
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
- name: devbox installer
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'
- name: Nix GC (pre-build)
run: |
nix-collect-garbage -d || true
du -sh /nix/store || true
- name: Disk space (start)
run: |
df -h
df -h /nix/store || true
- name: Gradle cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{matrix.profile}}
key: avd-${{ matrix.avd-name }}

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
profile: ${{matrix.profile}}
avd-name: Pixel_API_21_AOSP
target: default
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

# Workaround for corepack enable in node
# Source: (https://github.com/actions/setup-node/issues/899#issuecomment-1828798029)
- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
# End workaround

- name: Bootstrap
run: yarn install && yarn e2e install # No need to run bootstrap here since we don't need cocoapods

- name: Bundle build
run: yarn build

- name: Detox - Build
run: RCT_NO_LAUNCH_PACKAGER=1 yarn e2e build:android
- name: Android setup (AVD + deps)
env:
DETOX_AVD: ${{ matrix.avd-name }}
EMU_HEADLESS: "1"
AVD_FLAVOR: ${{ startsWith(matrix.avd-name, 'pixel') && 'minsdk' || 'latest' }}
run: |
set -euo pipefail
devbox run ${{ matrix.start-script }}
devbox run setup-android
yarn install
yarn e2e install

- name: Detox - Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
profile: ${{matrix.profile}}
avd-name: Pixel_API_21_AOSP
target: default
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: yarn e2e test:android
- name: Android build
run: |
set -euo pipefail
devbox run setup-android
yarn build
yarn e2e build:android

- name: Android E2E Tests
env:
DETOX_AVD: ${{ matrix.avd-name }}
run: devbox run test-android
41 changes: 0 additions & 41 deletions .github/workflows/create_jira.yml

This file was deleted.

17 changes: 7 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ jobs:
cache: yarn
# End workaround

- name: Config and Build
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
yarn install --immutable
yarn build
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: devbox installer
uses: jetify-com/devbox-install-action@v0.14.0
with:
enable-cache: 'true'

- name: Publish (All)
if: github.event.inputs.workspace == ''
run: yarn release
- name: Config, Build, Release
run: devbox run release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
29 changes: 29 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Repository Guidelines

## Project Structure & Module Organization
- Yarn workspaces live under `packages`: `core` (SDK runtime), `sovran` (state store), `shared` (cross-package utilities), and `plugins/*` (destination and helper plugins). Native iOS/Android sources reside in each package’s `ios` and `android` folders.
- Example apps sit in `examples/AnalyticsReactNativeExample` (manual QA) and `examples/E2E` (Detox). Scripts are in `scripts/`; configuration lives alongside packages (e.g., `tsconfig.json`, `babel.config.js`, `jest.config.js`).

## Build, Test, and Development Commands
- `yarn bootstrap`: install root + workspace deps and pod install for example/e2e apps.
- `yarn build`: run workspace builds in topo order.
- `yarn testAll` / `yarn test`: workspace Jest suite or root Jest run.
- `yarn lint`; `yarn lint --fix`: ESLint across the monorepo.
- `yarn typescript`: type-check without emitting.
- Example app: `yarn example start | ios | android`. Detox: `yarn e2e start:e2e` then platform builds/tests (e.g., `yarn e2e e2e:build:ios` + `yarn e2e e2e:test:ios`).

## Coding Style & Naming Conventions
- TypeScript-first; native code should mirror existing Swift/Obj-C/Kotlin style. Two-space indentation and Prettier formatting via ESLint rules.
- Prefer camelCase for variables/functions, PascalCase for React components/classes, and UPPER_SNAKE for constants. Plugin packages follow `plugin-*` folder naming and publish as scoped `@segment/*`.
- Keep public APIs typed and documented; colocate utilities with their feature module (e.g., `src/plugins`, `src/__tests__`).

## Testing Guidelines
- Unit tests use Jest with tests under `__tests__` near source; snapshots live in `__tests__/__snapshots__`.
- End-to-end coverage uses Detox in `examples/E2E`; build and run per platform before pushing. Add regression tests for new behaviors and keep existing snapshots updated only when intentional.

## Commit & Pull Request Guidelines
- Commit messages follow Conventional Commits (`feat`, `fix`, `chore`, etc.); enforced by commitlint and release automation.
- For PRs, keep scope narrow, link issues when relevant, and note user-facing changes. Ensure `yarn lint`, `yarn typescript`, and the relevant `yarn test*`/Detox flows pass. Include screenshots only when UI changes affect the example app.

## Security & Configuration Tips
- Do not commit real Segment write keys or private endpoints; use placeholder values in examples and tests. Keep secrets out of `examples/` and CI config. When testing proxies/CDN settings, prefer environment-driven config rather than hardcoding.
Loading
Loading