Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bindings and add CI tests #247

Merged
merged 1 commit into from
May 22, 2024
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
31 changes: 6 additions & 25 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: tests/release

on:
push:
Expand All @@ -10,49 +10,30 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Add musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Add no_std target
run: rustup target add thumbv7m-none-eabi
- name: Install musl-gcc
run: sudo apt update && sudo apt install -y musl-tools
- uses: actions/checkout@v4
- name: Format Check
run: cargo fmt --check
- name: Build (all features)
run: cargo build -r --all-features --verbose
run: cargo build -r --all-features
- name: Build
run: cargo build -r --verbose
- name: Build no_std
run: cd tests/ensure_no_std && cargo build -r --target thumbv7m-none-eabi
run: cargo build -r
- name: Test no_std
run: cargo test -r --no-default-features
- name: Build only std
run: cargo build -r --example regorus --no-default-features --features "std"
- name: Doc Tests
run: cargo test -r --doc
- name: Run tests
run: cargo test -r --verbose
run: cargo test -r
- name: Run tests (ACI)
run: cargo test -r --test aci
- name: Run tests (KATA)
run: cargo test -r --test kata
- name: Run tests (OPA Conformance)
run: >-
cargo test -r --test opa --features opa-testutil,serde_json/arbitrary_precision -- $(tr '\n' ' ' < tests/opa.passing)
- name: Build (MUSL)
run: cargo build --verbose --all-targets --target x86_64-unknown-linux-musl
- name: Run tests (MUSL)
run: cargo test -r --verbose --target x86_64-unknown-linux-musl
- name: Run tests (MUSL ACI)
run: cargo test -r --test aci --target x86_64-unknown-linux-musl
- name: Run tests (KATA ACI)
run: cargo test -r --test kata --target x86_64-unknown-linux-musl
- name: Run tests (MUSL OPA Conformance)
run: >-
cargo test -r --test opa --features opa-testutil,serde_json/arbitrary_precision --target x86_64-unknown-linux-musl -- $(tr '\n' ' ' < tests/opa.passing)
10 changes: 5 additions & 5 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
Expand All @@ -47,7 +47,7 @@ jobs:
python-version: '3.10'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
Expand All @@ -69,7 +69,7 @@ jobs:
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
Expand All @@ -85,7 +85,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build sdist
uses: PyO3/maturin-action@v1
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
with:
command: sdist
args: --out dist --manifest-path bindings/python/Cargo.toml
Expand All @@ -106,7 +106,7 @@ jobs:
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
uses: MarcoIeni/release-plz-action@a10be9933e46ab5005d79ce8b1eafca2ecdcd844 #v0.3.68
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/test-c-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: bindings/c-cpp

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup gcc, g++, cmake, ninja
run: sudo apt update && sudo apt install -y gcc g++ cmake ninja-build

- name: Test c binding
run: |
mkdir bindings/c/build
cd bindings/c/build
cmake -G Ninja ..
ninja
./regorus_test

- name: Test c-nostd binding
run: |
mkdir bindings/c-nostd/build
cd bindings/c-nostd/build
cmake -G Ninja ..
ninja
./regorus_test

- name: Test cpp binding
run: |
mkdir bindings/cpp/build
cd bindings/cpp/build
cmake -G Ninja ..
ninja
./regorus_test
26 changes: 26 additions & 0 deletions .github/workflows/test-csharp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: bindings/csharp

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v4

- name: Build
run: dotnet build
working-directory: ./bindings/csharp

- name: Run
run: LD_LIBRARY_PATH=. dotnet run
working-directory: ./bindings/csharp
33 changes: 33 additions & 0 deletions .github/workflows/test-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: bindings/go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0


- uses: actions/setup-go@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64

- name: Build ffi
run: cargo build -r
working-directory: ./bindings/ffi

- name: Test go
run: |
go mod tidy
go build
LD_LIBRARY_PATH=../../target/release ./regorus_test
working-directory: ./bindings/go
35 changes: 35 additions & 0 deletions .github/workflows/test-java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: bindings/java

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
java-version: 8
distribution: "corretto"
- uses: dtolnay/rust-toolchain@stable

- name: Building binding
run: cargo build --release --manifest-path bindings/java/Cargo.toml

- name: Build jar
run: mvn package
working-directory: ./bindings/java

- name: Test jar
run: |
javac -cp target/regorus-java-0.1.5.jar Test.java
java -Djava.library.path=../../target/release -cp target/regorus-java-0.1.5.jar:. Test
working-directory: ./bindings/java
33 changes: 33 additions & 0 deletions .github/workflows/test-musl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: musl

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Add musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Install musl-gcc
run: sudo apt update && sudo apt install -y musl-tools
- name: Build (MUSL)
run: cargo build --verbose --all-targets --target x86_64-unknown-linux-musl
- name: Run tests (MUSL)
run: cargo test -r --verbose --target x86_64-unknown-linux-musl
- name: Run tests (MUSL ACI)
run: cargo test -r --test aci --target x86_64-unknown-linux-musl
- name: Run tests (KATA ACI)
run: cargo test -r --test kata --target x86_64-unknown-linux-musl
- name: Run tests (MUSL OPA Conformance)
run: >-
cargo test -r --test opa --features opa-testutil,serde_json/arbitrary_precision --target x86_64-unknown-linux-musl -- $(tr '\n' ' ' < tests/opa.passing)
24 changes: 24 additions & 0 deletions .github/workflows/test-no-std.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: bindings/no-std

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Add no_std target
run: rustup target add thumbv7m-none-eabi
- name: Build
run: cargo build -r --target thumbv7m-none-eabi
working-directory: ./tests/ensure_no_std

37 changes: 37 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: bindings/python

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
PYTHON_VERSION: "3.10"

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64

- name: Build wheels
uses: PyO3/maturin-action@63b75c597b83e247fbf4fb7719801cc4220ae9f3 # v1.43.0
with:
target: x86_64
args: --release --out dist --manifest-path bindings/python/Cargo.toml
sccache: 'true'

- name: Test wheel
run: |
pip3 install dist/regorus-*.whl
cd bindings/python
python3 test.py
6 changes: 3 additions & 3 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-ruby
name: bindings/ruby

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
setup:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0

- name: Setup Ruby and Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
uses: oxidize-rb/actions/setup-ruby-and-rust@7ca44a16e287e5ff7dd72ab53f4bd41cbf34a571 #v1.26
with:
ruby-version: "3.3.1"
rustup-toolchain: "stable"
Expand Down
Loading
Loading