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
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,86 @@ jobs:

- name: Build all packages
run: yarn workspaces foreach --all --exclude react-native-executorch-bare-resource-fetcher --exclude react-native-executorch-expo-resource-fetcher --exclude react-native-executorch-webrtc --topological-dev run prepare

native-tests:
name: C++ unit tests
runs-on: ubuntu-latest
# Well clear of a cold run (dependency build ~2 min) but far below the 6 h
# default, so a stalled download fails with logs instead of hanging.
timeout-minutes: 30
defaults:
run:
working-directory: packages/react-native-executorch
env:
# The package version on this branch is 0.0.0, which has no GitHub Release,
# so point the header download at the libs release that carries a
# headers.tar.gz. Keep this in sync with the ExecuTorch version pinned in
# scripts/build-native-test-deps.sh — the tests compile against these
# headers and link libraries built from that pin.
RNET_BASE_URL: https://github.com/software-mansion/react-native-executorch/releases/download/v0.10.0-libs
steps:
- name: Checkout
uses: actions/checkout@v6

# Only googletest is needed; the other submodules are unrelated to the
# host test build.
- name: Check out googletest
run: git submodule update --init --depth 1 third-party/googletest
working-directory: ${{ github.workspace }}

# download-libs.js is dependency-free, so this job needs node but not a
# yarn install.
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc

# Only the two OpenCV modules the cv extension uses. The `libopencv-dev`
# meta-package hard-depends on the viz and contrib modules, which pull VTK,
# OpenMPI and ~220 packages — over 50 minutes on a throttled mirror.
# OpenCVConfig.cmake ships only in that meta-package, so cpp/tests
# falls back to locating the libraries directly.
- name: Install build tooling
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
ninja-build libopencv-core-dev libopencv-imgproc-dev
working-directory: ${{ github.workspace }}
env:
DEBIAN_FRONTEND: noninteractive

- name: Provision third-party headers
run: RNET_HEADERS_ONLY=1 node scripts/download-libs.js

# Hermes and ExecuTorch are pinned to exact tags, so the cache only misses
# when scripts/build-native-test-deps.sh changes those pins.
#
# Split restore/save rather than actions/cache: the combined action only
# saves in a post step when the job succeeds, so a failing test would throw
# away the ~9 min dependency build and rebuild it on every retry.
- name: Restore native test dependencies
id: deps-cache
uses: actions/cache/restore@v5
with:
path: packages/react-native-executorch/.native-test-deps
key: ${{ runner.os }}-native-test-deps-${{ hashFiles('packages/react-native-executorch/scripts/build-native-test-deps.sh') }}

- name: Build native test dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: scripts/build-native-test-deps.sh

- name: Save native test dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: packages/react-native-executorch/.native-test-deps
key: ${{ steps.deps-cache.outputs.cache-primary-key }}

# ~486 KB, pinned to an exact HF revision and checksum-verified. Fetched
# as its own step so a Hugging Face outage is an obvious failure rather
# than a confusing one inside the test run.
- name: Fetch .pte test fixtures
run: scripts/fetch-test-fixtures.sh

- name: Run C++ unit tests
run: scripts/run-native-tests.sh
5 changes: 3 additions & 2 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ jobs:
# TODO(#1291, @msluszniak): drop this override once a real versioned
# release exists. download-libs.js resolves the tag from the package
# version (v${PACKAGE_VERSION} == v0.0.0), but the placeholder 0.0.0 has
# no release; headers.tar.gz currently lives only on the test pre-release.
RNET_BASE_URL: https://github.com/software-mansion/react-native-executorch/releases/download/v0.0.0-rewrite-libs-test
# no release, so point at a libs release that ships headers.tar.gz.
# Keep in sync with the same override in ci.yml's native-tests job.
RNET_BASE_URL: https://github.com/software-mansion/react-native-executorch/releases/download/v0.10.0-libs
run: node scripts/download-libs.js

- name: Run clang-tidy
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native-executorch/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ rne-build-config.json

# Generated by scripts/package-release-artifacts.sh
dist-artifacts/

# Hermes + ExecuTorch host builds for the C++ tests, produced by
# scripts/build-native-test-deps.sh
.native-test-deps

# C++ test build output (scripts/run-native-tests.sh)
cpp/tests/build/

# .pte fixtures downloaded by scripts/fetch-test-fixtures.sh
cpp/tests/fixtures/
6 changes: 6 additions & 0 deletions packages/react-native-executorch/compile_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
-isystemthird-party/include/executorch/extension/llm/tokenizers/third-party/json/include
-isystemthird-party/include/executorch/extension/llm/tokenizers/third-party/re2
-isystemthird-party/include/executorch/extension/llm/tokenizers/third-party/abseil-cpp
-Icpp/tests
-isystem../../third-party/googletest/googletest/include
-isystem../../third-party/googletest/googlemock/include
-isystem.native-test-deps/hermes/src/API
-isystem.native-test-deps/hermes/src/API/jsi
-isystem.native-test-deps/hermes/src/public
Loading