319 lines
8.4 KiB
YAML
319 lines
8.4 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
release:
|
|
types: [ published ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
NODE_VERSION: '20'
|
|
RUST_VERSION: 'stable'
|
|
|
|
jobs:
|
|
test-rust:
|
|
name: Test Rust Components
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: ${{ env.RUST_VERSION }}
|
|
targets: wasm32-unknown-unknown
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache Rust dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
target/
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Run Rust tests
|
|
run: cargo test --verbose
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run Rust linting
|
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Check Rust formatting
|
|
run: cargo fmt --all -- --check
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
build-wasm:
|
|
name: Build WebAssembly
|
|
runs-on: ubuntu-latest
|
|
needs: test-rust
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: ${{ env.RUST_VERSION }}
|
|
targets: wasm32-unknown-unknown
|
|
|
|
- name: Install wasm-pack
|
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
|
|
- name: Cache Rust dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
target/
|
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build WASM packages
|
|
run: |
|
|
wasm-pack build --target nodejs --out-dir ../wasm/pkg graph_reasoner
|
|
wasm-pack build --target nodejs --out-dir ../wasm/extractors extractors
|
|
wasm-pack build --target nodejs --out-dir ../wasm/planner planner
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Upload WASM artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wasm-packages
|
|
path: psycho-symbolic-reasoner/wasm/
|
|
|
|
test-typescript:
|
|
name: Test TypeScript Components
|
|
runs-on: ubuntu-latest
|
|
needs: build-wasm
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'npm'
|
|
cache-dependency-path: psycho-symbolic-reasoner/package-lock.json
|
|
|
|
- name: Download WASM artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: wasm-packages
|
|
path: psycho-symbolic-reasoner/wasm/
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Type checking
|
|
run: npm run typecheck
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run linting
|
|
run: npm run lint
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Check formatting
|
|
run: npm run format:check
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Build TypeScript
|
|
run: npm run build:ts
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run TypeScript tests
|
|
run: npm run test:ts
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run integration tests
|
|
run: npm run test:integration
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
security-audit:
|
|
name: Security Audit
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run npm audit
|
|
run: npm audit --audit-level moderate
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Install cargo-audit
|
|
run: cargo install cargo-audit
|
|
|
|
- name: Run Rust security audit
|
|
run: cargo audit
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
benchmark:
|
|
name: Performance Benchmarks
|
|
runs-on: ubuntu-latest
|
|
needs: [build-wasm, test-typescript]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'npm'
|
|
cache-dependency-path: psycho-symbolic-reasoner/package-lock.json
|
|
|
|
- name: Download WASM artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: wasm-packages
|
|
path: psycho-symbolic-reasoner/wasm/
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run benchmarks
|
|
run: npm run benchmark
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Upload benchmark results
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: benchmark-results
|
|
path: psycho-symbolic-reasoner/benchmark-results.json
|
|
|
|
build-docs:
|
|
name: Build Documentation
|
|
runs-on: ubuntu-latest
|
|
needs: test-typescript
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'npm'
|
|
cache-dependency-path: psycho-symbolic-reasoner/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Build documentation
|
|
run: npm run docs:build
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Upload documentation
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: documentation
|
|
path: psycho-symbolic-reasoner/docs/
|
|
|
|
publish:
|
|
name: Publish to NPM
|
|
runs-on: ubuntu-latest
|
|
needs: [test-rust, test-typescript, security-audit]
|
|
if: github.event_name == 'release' && github.event.action == 'published'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
registry-url: 'https://registry.npmjs.org'
|
|
cache: 'npm'
|
|
cache-dependency-path: psycho-symbolic-reasoner/package-lock.json
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: ${{ env.RUST_VERSION }}
|
|
targets: wasm32-unknown-unknown
|
|
|
|
- name: Install wasm-pack
|
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Run tests
|
|
run: npm test
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
|
|
- name: Publish to NPM
|
|
run: npm publish
|
|
working-directory: ./psycho-symbolic-reasoner
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Create GitHub Release Assets
|
|
run: |
|
|
tar -czf psycho-symbolic-reasoner-${{ github.event.release.tag_name }}.tar.gz -C psycho-symbolic-reasoner dist/ wasm/ docs/ examples/
|
|
|
|
- name: Upload Release Assets
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: ./psycho-symbolic-reasoner-${{ github.event.release.tag_name }}.tar.gz
|
|
asset_name: psycho-symbolic-reasoner-${{ github.event.release.tag_name }}.tar.gz
|
|
asset_content_type: application/gzip
|
|
|
|
deploy-docs:
|
|
name: Deploy Documentation
|
|
runs-on: ubuntu-latest
|
|
needs: build-docs
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download documentation
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: documentation
|
|
path: docs/
|
|
|
|
- name: Deploy to GitHub Pages
|
|
uses: peaceiris/actions-gh-pages@v3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
publish_dir: ./docs |