Skip to content

Commit

Permalink
Include an arm64 shared library in the ruby gem (#1733)
Browse files Browse the repository at this point in the history
* Update nokogiri to version with support for apple silicon

* Update gem dependencies to address spec failures running with Ruby 3

* Require ActiveRecordAdapter from spec that uses it

* Add support for both x86_64 and arm64 linux architectures

* Build both x86 and arm dynamic libraries for ruby

* Use Ruby 2.6 as minimum tested version and 3.2 for all ruby-related tasks

Rationale: 2.6.10 is what ships with macOS 14.0 even though support for it
stopped in March of 2022 and 3.2 is the latest stable version.

* Ensure the ruby libs are copied and available for testing

* Bump solargraph and rubocop

Disable new cops for existing violations

* Update bundler to get rid of SPELL_CHECKERS warning

* Do not suggest extensions

* Simplify YARD docs for query method

Add the host and bindings parameters so calls that contain them don't fail typecheck

* Must use Ruby 2.4 in order to build the docs on main

* Must use Ruby 2.4 in order to build the docs on main

* Use .ruby-version instead of hard-coding the current ruby version in Github actions

The rationale for this is from the way that docs diffing works. Both the base branch and the new branch need to be able to build using the version of Ruby supported by that branch. Without this change, when a PR is introduced that updates the target Ruby version, a followup PR will be required to update the github action for building the 'base' branch's version of the docs. With this change, github actions will choose the version of Ruby targeted by the branch it is trying to build

* Clippy

* Cargo fmt

* Test

* Try building aarch64 first

Seeing if
[this](cross-rs/cross#724 (comment))
is a quick fix so I can avoid any deeper debugging.

* Keep shuffling the deck chairs

* Revert "Test"

This reverts commit 7feebd1.

* Add 0.27.3 changelog

* Bump version

* Let's just release now instead

---------

Co-authored-by: Gabe Jackson <17556281+gj@users.noreply.github.com>
  • Loading branch information
jdeff and gj authored Jan 13, 2024
1 parent 1aa4b0b commit b545cf5
Show file tree
Hide file tree
Showing 35 changed files with 262 additions and 148 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/docs-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
if: steps.cache.outputs.cache-hit != 'true'
- name: Install yard
Expand Down Expand Up @@ -84,7 +83,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.79.1'
hugo-version: "0.79.1"
if: steps.cache.outputs.cache-hit != 'true'
- name: Build Hugo docs
env:
Expand Down Expand Up @@ -136,7 +135,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
ruby-version: "2.7"
working-directory: "languages/ruby"
if: steps.cache.outputs.cache-hit != 'true'
- name: Install yard
Expand Down Expand Up @@ -171,7 +170,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.79.1'
hugo-version: "0.79.1"
if: steps.cache.outputs.cache-hit != 'true'
- name: Build Hugo docs
env:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
- name: Install yard
run: gem install yard
Expand Down Expand Up @@ -61,7 +60,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.79.1'
hugo-version: "0.79.1"
- name: Get branch name (branch)
if: github.event_name != 'pull_request'
shell: bash
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
description: "docs s3 path (docs.oso.dev or docs-preview.oso.dev)"
oso_version:
description: "oso release to build docs for"
default: "0.27.2" # oso_version
default: "0.27.3" # oso_version
flask_oso_version:
description: "flask oso release to build docs for"
default: "0.27.1" # flask_oso_version
Expand Down Expand Up @@ -49,7 +49,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
- name: Install yard
run: gem install yard
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Set up ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
ruby-version: "3.2"
working-directory: "languages/ruby"
- run: gem push oso-oso-${{ github.event.inputs.version }}.gem
working-directory: "oso-ruby-${{ github.event.inputs.version }}"
Expand Down
41 changes: 26 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,42 @@ jobs:
profile: minimal
toolchain: 1.69.0
override: true
- name: Build release libraries
run: cargo build --release -p polar-c-api
- name: Build x86_64 release musl library
run: |
rustup target add x86_64-unknown-linux-musl
RUSTFLAGS="-C target-feature=-crt-static" cargo build --target x86_64-unknown-linux-musl --release -p polar-c-api
- name: Download cross
- name: Install cross
env:
GH_TOKEN: ${{ github.token }}
run: gh release download --repo cross-rs/cross --pattern 'cross-x86_64-unknown-linux-gnu\.tar\.gz'
run: |
gh release download --repo cross-rs/cross --pattern 'cross-x86_64-unknown-linux-gnu\.tar\.gz'
tar -xzvf cross-x86_64-unknown-linux-gnu.tar.gz
- name: Build aarch64 dynamic lib
run: |
rustup target add aarch64-unknown-linux-gnu
RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-gnu --release -p polar-c-api
- name: Build aarch64 release musl library
run: |
rustup target add aarch64-unknown-linux-musl
tar -xzvf cross-x86_64-unknown-linux-gnu.tar.gz
RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-musl --release -p polar-c-api
- name: Build x86_64 release libraries
run: cargo build --release -p polar-c-api
- name: Build x86_64 release musl library
run: |
rustup target add x86_64-unknown-linux-musl
RUSTFLAGS="-C target-feature=-crt-static" cargo build --target x86_64-unknown-linux-musl --release -p polar-c-api
- name: Rename static lib
run: mv target/release/libpolar.a target/libpolar-${{runner.os}}.a
- name: Rename x86_64 static lib
run: mv target/x86_64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-x86_64.a
- name: Rename aarch64 static lib
run: mv target/aarch64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-aarch64.a
- name: Rename x86_64 dynamic lib
run: mv target/release/libpolar.so target/libpolar-x86_64.so
- name: Rename aarch64 dynamic lib
run: mv target/aarch64-unknown-linux-gnu/release/libpolar.so target/libpolar-aarch64.so
- uses: actions/upload-artifact@v2
with:
name: oso_library
path: target/release/libpolar.so
path: |
target/libpolar-x86_64.so
target/libpolar-aarch64.so
- uses: actions/upload-artifact@v2
with:
name: oso_library
Expand Down Expand Up @@ -252,7 +263,7 @@ jobs:
- name: Copy libraries into resources.
run: |
mkdir -p languages/java/oso/src/main/resources/linux
cp -r oso_library/libpolar.so languages/java/oso/src/main/resources/linux/
cp -r oso_library/libpolar-x86_64.so languages/java/oso/src/main/resources/linux/libpolar.so
mkdir -p languages/java/oso/src/main/resources/macos
cp -r oso_library/libpolar-macOS-fat.dylib languages/java/oso/src/main/resources/macos/libpolar.dylib
mkdir -p languages/java/oso/src/main/resources/win
Expand Down Expand Up @@ -280,7 +291,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
- name: Set version env
id: version
Expand All @@ -292,7 +302,8 @@ jobs:
- name: Copy libraries into resources.
run: |
mkdir -p languages/ruby/ext/oso-oso/lib
cp -r oso_library/libpolar.so languages/ruby/ext/oso-oso/lib/
cp -r oso_library/libpolar-x86_64.so languages/ruby/ext/oso-oso/lib/
cp -r oso_library/libpolar-aarch64.so languages/ruby/ext/oso-oso/lib/
cp -r oso_library/libpolar-macOS-fat.dylib languages/ruby/ext/oso-oso/lib/libpolar.dylib
cp -r oso_library/polar.dll languages/ruby/ext/oso-oso/lib/
- name: Test
Expand Down Expand Up @@ -689,7 +700,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"]
steps:
- uses: actions/checkout@v2
- name: Set version env
Expand Down Expand Up @@ -805,7 +816,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
ruby-version: "2.7"
working-directory: "docs/examples/quickstart/ruby"
- name: Use Node.js 12
uses: actions/setup-node@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
- name: Lint Ruby code
working-directory: "languages/ruby"
Expand Down Expand Up @@ -214,7 +213,6 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '2.7'
working-directory: "languages/ruby"
- name: Test ruby
run: make ruby-test
Expand Down Expand Up @@ -350,8 +348,8 @@ jobs:
- name: Install Ruby + gems
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
working-directory: "languages/ruby"
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
Expand All @@ -362,6 +360,8 @@ jobs:
java-version: "11"
- name: Build python lib
run: make python-build
- name: Build ruby lib
run: make ruby-build
- name: Python test deps
run: make -C languages/python/oso test-requirements
- name: Build js lib
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ cython_debug/
# Java class files
*.class

.ruby-version
languages/java/oso/dependency-reduced-pom.xml
languages/java/oso/src/main/resources/*

Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ python-django-test: python-build python-django-build
python-sqlalchemy-test: python-build
$(MAKE) -C languages/python/sqlalchemy-oso test

ruby-build: rust-build
$(MAKE) -C languages/ruby copy_lib

ruby-test:
$(MAKE) -C languages/ruby test

Expand All @@ -55,7 +58,7 @@ java-test:
go-test: rust-build
$(MAKE) -C languages/go test

docs-test: python-build
docs-test: python-build ruby-build
$(MAKE) -C docs test

fmt: fmt-java fmt-rust fmt-python fmt-js fmt-go
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.27.2
0.27.3
21 changes: 21 additions & 0 deletions docs/content/any/project/changelogs/2024-01-12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Release 2024-01-12
menuTitle: 2024-01-12
any: true
description: >-
Changelog for Release 2024-01-12 (0.27.3) containing new features,
bug fixes, and more.
---

## `oso` 0.27.3

### Ruby

#### New features

##### Linux AArch64 support

You can now run the `oso-oso` gem in AArch64 Linux environments, including in
Docker on Apple silicon.

Thanks to [`@jdeff`](https://github.com/jdeff) for the contribution!
2 changes: 1 addition & 1 deletion docs/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ JS_DIR := $(OSO_ROOT)/languages/js
RUBY_DIR := $(OSO_ROOT)/languages/ruby

# Needed for tests
JAVA_PACKAGE_JAR_PATH := $(JAVA_DIR)/oso/target/oso-0.27.2.jar
JAVA_PACKAGE_JAR_PATH := $(JAVA_DIR)/oso/target/oso-0.27.3.jar

# Note: if you are using bundler in a sub-makefile (in a docs test for example),
# you need to add `unexport BUNDLE_GEMFILE` to that makefile. Otherwise this
Expand Down
2 changes: 1 addition & 1 deletion languages/java/oso/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.osohq</groupId>
<artifactId>oso</artifactId>
<!-- oso_version --><version>0.27.2</version>
<!-- oso_version --><version>0.27.3</version>

<distributionManagement>
<snapshotRepository>
Expand Down
2 changes: 1 addition & 1 deletion languages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oso",
"version": "0.27.2",
"version": "0.27.3",
"description": "oso authorization library.",
"bin": "bin/repl.js",
"main": "dist/src/index.js",
Expand Down
4 changes: 2 additions & 2 deletions languages/python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
project = "oso"
copyright = "2020-2021 Oso Security, Inc"
author = "oso"
version = "0.27.2"
release = "0.27.2"
version = "0.27.3"
release = "0.27.3"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion languages/python/oso/oso/oso.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Core oso functionality"""

__version__ = "0.27.2"
__version__ = "0.27.3"

import os
from typing import Any, List, Set, Type
Expand Down
1 change: 1 addition & 0 deletions languages/ruby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ vendor

# rspec failure tracking
.rspec_status
ext
Loading

1 comment on commit b545cf5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: b545cf5 Previous: 1aa4b0b Ratio
rust_get_attribute 28970 ns/iter (± 1932) 29412 ns/iter (± 971) 0.98
n_plus_one/100 1521505 ns/iter (± 25726) 1587993 ns/iter (± 17731) 0.96
n_plus_one/500 7375274 ns/iter (± 149595) 7749856 ns/iter (± 26196) 0.95
n_plus_one/1000 14654173 ns/iter (± 135512) 15342558 ns/iter (± 96574) 0.96
unify_once 619 ns/iter (± 10) 629 ns/iter (± 16) 0.98
unify_twice 1735 ns/iter (± 66) 1751 ns/iter (± 16) 0.99
many_rules 38973 ns/iter (± 898) 39405 ns/iter (± 816) 0.99
fib/5 345177 ns/iter (± 5014) 345576 ns/iter (± 5031) 1.00
prime/3 10413 ns/iter (± 426) 10440 ns/iter (± 397) 1.00
prime/23 10430 ns/iter (± 450) 10449 ns/iter (± 397) 1.00
prime/43 10479 ns/iter (± 550) 10445 ns/iter (± 387) 1.00
prime/83 10414 ns/iter (± 393) 10444 ns/iter (± 380) 1.00
prime/255 9338 ns/iter (± 363) 9351 ns/iter (± 408) 1.00
indexed/100 3402 ns/iter (± 403) 3530 ns/iter (± 462) 0.96
indexed/500 3947 ns/iter (± 1242) 3978 ns/iter (± 1412) 0.99
indexed/1000 4450 ns/iter (± 304) 4520 ns/iter (± 586) 0.98
indexed/10000 8153 ns/iter (± 1932) 9036 ns/iter (± 1232) 0.90
not 3985 ns/iter (± 68) 4021 ns/iter (± 530) 0.99
double_not 8416 ns/iter (± 265) 8541 ns/iter (± 175) 0.99
De_Morgan_not 5458 ns/iter (± 102) 5461 ns/iter (± 80) 1.00
load_policy 659950 ns/iter (± 26231) 712346 ns/iter (± 6628) 0.93
partial_and/1 20764 ns/iter (± 688) 20825 ns/iter (± 671) 1.00
partial_and/5 68750 ns/iter (± 1998) 68790 ns/iter (± 2097) 1.00
partial_and/10 128523 ns/iter (± 3421) 129434 ns/iter (± 5909) 0.99
partial_and/20 267199 ns/iter (± 5217) 270955 ns/iter (± 4789) 0.99
partial_and/40 585692 ns/iter (± 8504) 590838 ns/iter (± 8087) 0.99
partial_and/80 1353513 ns/iter (± 45850) 1370780 ns/iter (± 8510) 0.99
partial_and/100 1805651 ns/iter (± 11852) 1824816 ns/iter (± 10745) 0.99
partial_rule_depth/1 62238 ns/iter (± 2249) 62680 ns/iter (± 2617) 0.99
partial_rule_depth/5 212950 ns/iter (± 6046) 214308 ns/iter (± 6871) 0.99
partial_rule_depth/10 483155 ns/iter (± 22803) 485166 ns/iter (± 9809) 1.00
partial_rule_depth/20 1380034 ns/iter (± 19506) 1380301 ns/iter (± 27794) 1.00
partial_rule_depth/40 4918098 ns/iter (± 33780) 4936449 ns/iter (± 36963) 1.00
partial_rule_depth/80 27809958 ns/iter (± 341458) 27746529 ns/iter (± 367546) 1.00
partial_rule_depth/100 50033237 ns/iter (± 468928) 50033526 ns/iter (± 573682) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.