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
1 change: 1 addition & 0 deletions .executorch-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.6.0
152 changes: 152 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: CI

on:
push:
branches: [master, main]
pull_request:

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test (${{ matrix.os }}, Ruby ${{ matrix.ruby }})
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
ruby: "3.2"
- os: ubuntu-24.04
ruby: "3.3"
- os: ubuntu-24.04
ruby: "3.4"
- os: ubuntu-24.04-arm
ruby: "3.4"
- os: macos-15
ruby: "3.2"
- os: macos-15
ruby: "3.4"

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "test/fixtures/pyproject.toml"

- name: Cache ExecuTorch C++ SDK
uses: actions/cache@v4
with:
path: ~/.cache/executorch-ruby
key: sdk-${{ matrix.os }}-${{ runner.arch }}-${{ hashFiles('.executorch-version', 'lib/executorch/sdk.rb') }}

- name: Fetch ExecuTorch SDK & compile native extension
run: |
bundle exec rake sdk:fetch
bundle exec rake compile

- name: Export deterministic .pte / .ptd test fixtures
run: |
uv run --project test/fixtures python test/fixtures/export_fixtures.py --out test/fixtures/models

- name: Run full test suite (zero skips allowed)
run: |
set -o pipefail
bundle exec rake test TESTOPTS="-v" | tee test_output.txt
grep -qE "0 failures, 0 errors, 0 skips" test_output.txt

sanitizers:
name: ASan + UBSan (ubuntu-24.04, Ruby 3.4)
runs-on: ubuntu-24.04
timeout-minutes: 25

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "test/fixtures/pyproject.toml"

- name: Cache ExecuTorch C++ SDK
uses: actions/cache@v4
with:
path: ~/.cache/executorch-ruby
key: sdk-ubuntu-24.04-${{ runner.arch }}-${{ hashFiles('.executorch-version', 'lib/executorch/sdk.rb') }}

- name: Compile with ASan + UBSan
env:
EXECUTORCH_SANITIZE: "1"
run: |
bundle exec rake sdk:fetch
bundle exec rake compile

- name: Export fixtures
run: |
uv run --project test/fixtures python test/fixtures/export_fixtures.py --out test/fixtures/models

- name: Run tests under ASan + UBSan
run: |
ASAN_LIB=$(g++ -print-file-name=libasan.so)
UBSAN_LIB=$(g++ -print-file-name=libubsan.so)
LD_PRELOAD="${ASAN_LIB}:${UBSAN_LIB}" \
ASAN_OPTIONS="detect_leaks=0:use_sigaltstack=0:halt_on_error=1" \
UBSAN_OPTIONS="print_stacktrace=1:halt_on_error=1" \
bundle exec rake test TESTOPTS="-v"

package-smoke:
name: Platform Gem Smoke (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15]

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- name: Build platform fat gem & source gem
run: |
bundle exec rake sdk:fetch
bundle exec rake package_platform
gem build executorch.gemspec -o pkg/executorch-source.gem

- name: Smoke-test isolated platform gem install (no SDK cache required)
run: |
rm -rf ~/.cache/executorch-ruby
GEM_HOME=$(mktemp -d)
export GEM_HOME
export PATH="$GEM_HOME/bin:$PATH"
gem install --local --no-document pkg/executorch-*-*.gem
ruby -rexecutorch -e '
raise "missing XNNPACK" unless Executorch.backends.include?("XnnpackBackend")
t = Executorch::Tensor.new([[1.0, 2.0], [3.0, 4.0]])
raise "bad roundtrip" unless t.to_a == [[1.0, 2.0], [3.0, 4.0]]
puts "OK: #{Executorch::VERSION} / SDK #{Executorch.executorch_version} / #{Executorch.backends.inspect}"
'
197 changes: 197 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "Build & verify all gems without pushing to RubyGems"
type: boolean
default: true

permissions:
contents: read

jobs:
verify-metadata:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.ver.outputs.version }}
publish: ${{ steps.ver.outputs.publish }}
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"

- name: Verify version and CHANGELOG consistency
id: ver
run: |
VERSION=$(ruby -Ilib -rexecutorch/version -e 'puts Executorch::VERSION')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
grep -Fq "## [$VERSION]" CHANGELOG.md || {
echo "CHANGELOG.md is missing heading: ## [$VERSION]"
exit 1
}
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG_VER="${GITHUB_REF#refs/tags/v}"
if [[ "$TAG_VER" != "$VERSION" ]]; then
echo "Tag v$TAG_VER does not match Executorch::VERSION ($VERSION)"
exit 1
fi
echo "publish=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.dry_run }}" == "false" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi

build-platform-gems:
needs: verify-metadata
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
platform: x86_64-linux
- os: ubuntu-24.04-arm
platform: aarch64-linux
- os: macos-15
platform: arm64-darwin

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Export fixtures for pre-release verification
run: |
uv run --project test/fixtures python test/fixtures/export_fixtures.py --out test/fixtures/models

- name: Build fat extension for Ruby 3.2, 3.3, 3.4
run: |
mkdir -p staged_lib
echo "matrix=${{ matrix.platform }}"

- name: Compile Ruby 3.2 extension
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- run: |
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake sdk:fetch compile
bundle exec rake test
mkdir -p staged/3.2
cp lib/executorch/executorch.* staged/3.2/

- name: Compile Ruby 3.3 extension
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- run: |
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake clean compile
bundle exec rake test
mkdir -p staged/3.3
cp lib/executorch/executorch.* staged/3.3/

- name: Compile Ruby 3.4 extension & assemble fat gem
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- run: |
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake clean compile
bundle exec rake test
mkdir -p lib/executorch/3.2 lib/executorch/3.3 lib/executorch/3.4
cp staged/3.2/executorch.* lib/executorch/3.2/
cp staged/3.3/executorch.* lib/executorch/3.3/
mv lib/executorch/executorch.* lib/executorch/3.4/
ruby -e '
require "rubygems/package"
spec = Gem::Specification.load("executorch.gemspec")
spec.platform = Gem::Platform.new("${{ matrix.platform }}")
spec.extensions = []
spec.files = (
spec.files.reject { |f| f.start_with?("ext/") } +
Dir["lib/executorch/3.*/*"] +
Dir["lib/executorch/vendor/*"]
).uniq.sort
FileUtils.mkdir_p("pkg")
out = Gem::Package.build(spec)
FileUtils.mv(out, File.join("pkg", File.basename(out)))
'
# Isolated smoke test without SDK cache
rm -rf ~/.cache/executorch-ruby
GEM_HOME=$(mktemp -d)
GEM_HOME="$GEM_HOME" gem install --local --no-document pkg/executorch-*-${{ matrix.platform }}.gem
GEM_HOME="$GEM_HOME" ruby -rexecutorch -e '
raise "missing XNNPACK" unless Executorch.backends.include?("XnnpackBackend")
puts "Verified fat gem: #{Executorch::VERSION} (#{Executorch.backends.inspect})"
'

- uses: actions/upload-artifact@v4
with:
name: gem-${{ matrix.platform }}
path: pkg/*.gem

build-source-gem:
needs: verify-metadata
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- run: |
mkdir -p pkg
gem build executorch.gemspec -o "pkg/executorch-${{ needs.verify-metadata.outputs.version }}.gem"
- uses: actions/upload-artifact@v4
with:
name: gem-source
path: pkg/*.gem

publish:
needs: [verify-metadata, build-platform-gems, build-source-gem]
if: needs.verify-metadata.outputs.publish == 'true'
runs-on: ubuntu-24.04
environment: release
permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"

- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Configure RubyGems Trusted Publishing (OIDC)
uses: rubygems/configure-rubygems-credentials@v1

- name: Push verified gems to RubyGems
run: |
for g in dist/*.gem; do
echo "Pushing $g"
gem push "$g"
done

- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${GITHUB_REF_NAME}" dist/*.gem \
--title "v${{ needs.verify-metadata.outputs.version }}" \
--generate-notes
Loading
Loading