Skip to content

Commit 3046388

Browse files
committed
Set up GitHub CI
1 parent 291d9f4 commit 3046388

5 files changed

Lines changed: 305 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Cargo
4+
- package-ecosystem: "cargo"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
open-pull-requests-limit: 10
9+
labels:
10+
- "dependencies"
11+
commit-message:
12+
prefix: "deps"
13+
include: "scope"
14+
15+
# Enable version updates for GitHub Actions
16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "monthly"
20+
open-pull-requests-limit: 5
21+
labels:
22+
- "github-actions"
23+
- "dependencies"
24+
commit-message:
25+
prefix: "ci"
26+
include: "scope"

.github/workflows/ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, feature/pipeline-test ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test Suite
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
rust-version: ['1.90', 'stable']
19+
features:
20+
- ''
21+
- 'scheme'
22+
- 'jsonlogic'
23+
- 'scheme,jsonlogic'
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Install Rust
30+
uses: dtolnay/rust-toolchain@master
31+
with:
32+
toolchain: ${{ matrix.rust-version }}
33+
34+
- name: Cache dependencies
35+
uses: Swatinem/rust-cache@v2
36+
37+
- name: Run tests
38+
run: cargo test --features="${{ matrix.features }}" --verbose
39+
40+
- name: Run doc tests (all features)
41+
run: cargo test --doc --all-features
42+
43+
coverage:
44+
name: Code Coverage
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Install Rust
52+
uses: dtolnay/rust-toolchain@stable
53+
with:
54+
components: llvm-tools-preview
55+
56+
- name: Cache dependencies
57+
uses: Swatinem/rust-cache@v2
58+
59+
- name: Install cargo-llvm-cov
60+
uses: taiki-e/install-action@cargo-llvm-cov
61+
62+
- name: Generate code coverage
63+
run: cargo llvm-cov --all-features --workspace --html --output-dir coverage-html
64+
65+
- name: Upload coverage HTML
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: coverage-report
69+
path: coverage-html/
70+
retention-days: 30
71+
72+
lint:
73+
name: Linting
74+
runs-on: ubuntu-latest
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Install Rust
81+
uses: dtolnay/rust-toolchain@stable
82+
with:
83+
components: rustfmt, clippy
84+
85+
- name: Cache dependencies
86+
uses: Swatinem/rust-cache@v2
87+
88+
- name: Check formatting
89+
run: cargo fmt --all -- --check
90+
91+
- name: Run clippy
92+
run: cargo clippy --all-targets --all-features -- -D warnings
93+
94+
docs:
95+
name: Documentation
96+
runs-on: ubuntu-latest
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
102+
- name: Install Rust
103+
uses: dtolnay/rust-toolchain@stable
104+
105+
- name: Cache dependencies
106+
uses: Swatinem/rust-cache@v2
107+
108+
- name: Build documentation
109+
run: cargo doc --all-features --no-deps
110+
111+
- name: Check for broken links in docs
112+
run: cargo doc --all-features --no-deps 2>&1 | grep -i "warning\|error" && exit 1 || exit 0
113+
114+
security:
115+
name: Security Audit
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- name: Checkout code
120+
uses: actions/checkout@v4
121+
122+
- name: Install cargo-audit
123+
run: cargo install cargo-audit
124+
125+
- name: Run security audit
126+
run: cargo audit
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Cross Platform
2+
3+
on:
4+
push:
5+
branches: [ main, feature/pipeline-test ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# Run weekly to catch regressions
10+
- cron: '0 0 * * 0'
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
test-cross-platform:
17+
name: Test on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [ubuntu-latest, windows-latest, macos-latest]
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Install Rust
28+
uses: dtolnay/rust-toolchain@stable
29+
30+
- name: Cache dependencies
31+
uses: Swatinem/rust-cache@v2
32+
33+
- name: Run tests
34+
run: cargo test --all-features --verbose
35+
36+
- name: Build all targets
37+
run: cargo build --all-targets --all-features
38+
39+
- name: REPL smoke test
40+
run: echo "(+ 1 2 3)" | cargo run --example repl --all-features

.github/workflows/release.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
create-release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Get tag name
23+
id: tag_name
24+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
25+
26+
- name: Create Release
27+
id: create_release
28+
uses: actions/create-release@v1
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }}
33+
release_name: Release ${{ steps.tag_name.outputs.TAG_NAME }}
34+
draft: false
35+
prerelease: false
36+
37+
publish-crate:
38+
name: Publish to crates.io
39+
runs-on: ubuntu-latest
40+
needs: create-release
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Install Rust
47+
uses: dtolnay/rust-toolchain@stable
48+
49+
- name: Cache dependencies
50+
uses: Swatinem/rust-cache@v2
51+
52+
- name: Publish to crates.io
53+
run: cargo publish --all-features --token ${{ secrets.CRATES_IO_TOKEN }}
54+
55+
build-binaries:
56+
name: Build Release Binaries
57+
runs-on: ${{ matrix.os }}
58+
needs: create-release
59+
strategy:
60+
matrix:
61+
include:
62+
- os: ubuntu-latest
63+
target: x86_64-unknown-linux-gnu
64+
dir: linux
65+
name: linux/rulesxp-repl
66+
- os: windows-latest
67+
target: x86_64-pc-windows-msvc
68+
dir: windows
69+
name: windows/rulesxp-repl.exe
70+
- os: macos-latest
71+
target: aarch64-apple-darwin
72+
dir: macos-arm64
73+
name: macos-arm64/rulesxp-repl
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Install Rust
80+
uses: dtolnay/rust-toolchain@stable
81+
with:
82+
targets: ${{ matrix.target }}
83+
84+
- name: Cache dependencies
85+
uses: Swatinem/rust-cache@v2
86+
87+
- name: Build release binary
88+
run: cargo build --release --example repl --all-features --target ${{ matrix.target }}
89+
90+
- name: Create platform directory
91+
run: mkdir -p ${{ matrix.dir }}
92+
93+
- name: Copy binary (Unix)
94+
if: matrix.os != 'windows-latest'
95+
run: cp target/${{ matrix.target }}/release/examples/repl ${{ matrix.name }}
96+
97+
- name: Copy binary (Windows)
98+
if: matrix.os == 'windows-latest'
99+
run: cp target/${{ matrix.target }}/release/examples/repl.exe ${{ matrix.name }}
100+
101+
- name: Upload binary
102+
uses: actions/upload-release-asset@v1
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
with:
106+
upload_url: ${{ needs.create-release.outputs.upload_url }}
107+
asset_path: ./${{ matrix.name }}
108+
asset_name: ${{ matrix.name }}
109+
asset_content_type: application/octet-stream

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# RulesXP
22

3+
[![CI](https://github.com/microsoft/rulesxp/workflows/CI/badge.svg)](https://github.com/microsoft/rulesxp/actions/workflows/ci.yml)
4+
[![Crates.io](https://img.shields.io/crates/v/rulesxp.svg)](https://crates.io/crates/rulesxp)
5+
[![Documentation](https://docs.rs/rulesxp/badge.svg)](https://docs.rs/rulesxp)
6+
37
**Multi-Language Rules Expression Evaluator**
48

59
RulesXP is a minimalistic expression evaluator that supports both JSONLogic and Scheme syntax with strict typing.

0 commit comments

Comments
 (0)