Skip to content
Open
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
159 changes: 159 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: CI

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

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
fmt:
name: Format Check
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libclang-dev

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
shared-key: "clippy"

- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings

test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libclang-dev

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-${{ matrix.os }}"

- name: Run tests
run: cargo test --workspace --all-features

build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libclang-dev

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
shared-key: "build-${{ matrix.os }}"

- name: Build release
run: cargo build --release --workspace

doc:
name: Documentation
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libclang-dev

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
shared-key: "doc"

- name: Build documentation
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --no-deps --workspace --all-features

# Summary job that depends on all other jobs
ci-success:
name: CI Success
needs: [fmt, clippy, test, build, doc]
runs-on: ubuntu-24.04
if: always()
steps:
- name: Check all jobs passed
run: |
if [[ "${{ needs.fmt.result }}" != "success" ]] || \
[[ "${{ needs.clippy.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]] || \
[[ "${{ needs.build.result }}" != "success" ]] || \
[[ "${{ needs.doc.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI jobs passed!"
200 changes: 200 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: true
type: string

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: linux-x86_64
cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: linux-aarch64
cross: true
- target: x86_64-apple-darwin
os: macos-13
name: macos-x86_64
cross: false
- target: aarch64-apple-darwin
os: macos-14
name: macos-aarch64
cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
name: windows-x86_64
cross: false

steps:
- uses: actions/checkout@v4

- name: Get version
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
fi

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler libclang-dev

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> $GITHUB_ENV

- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install protoc llvm -y

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
shared-key: "release-${{ matrix.name }}"

- name: Build (native)
if: "!matrix.cross"
run: cargo build --release --target ${{ matrix.target }}

- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}

- name: Create archive directory
shell: bash
run: |
VERSION=${{ steps.version.outputs.version }}
ARCHIVE_DIR="memory-daemon-${VERSION}-${{ matrix.name }}"
mkdir -p "dist/${ARCHIVE_DIR}"

# Copy binaries
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp target/${{ matrix.target }}/release/memory-daemon.exe "dist/${ARCHIVE_DIR}/"
cp target/${{ matrix.target }}/release/memory-ingest.exe "dist/${ARCHIVE_DIR}/" || true
else
cp target/${{ matrix.target }}/release/memory-daemon "dist/${ARCHIVE_DIR}/"
cp target/${{ matrix.target }}/release/memory-ingest "dist/${ARCHIVE_DIR}/" || true
fi

# Copy documentation
cp LICENSE "dist/${ARCHIVE_DIR}/" || true
cp README.md "dist/${ARCHIVE_DIR}/" || true

- name: Create archive (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
VERSION=${{ steps.version.outputs.version }}
ARCHIVE_DIR="memory-daemon-${VERSION}-${{ matrix.name }}"
cd dist
tar -czvf "${ARCHIVE_DIR}.tar.gz" "${ARCHIVE_DIR}"
rm -rf "${ARCHIVE_DIR}"

- name: Create archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$VERSION = "${{ steps.version.outputs.version }}"
$ARCHIVE_DIR = "memory-daemon-${VERSION}-${{ matrix.name }}"
cd dist
Compress-Archive -Path $ARCHIVE_DIR -DestinationPath "${ARCHIVE_DIR}.zip"
Remove-Item -Recurse -Force $ARCHIVE_DIR

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.name }}
path: dist/*
retention-days: 1

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Get version
id: version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "tag=v${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
fi

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: release-*
merge-multiple: true

- name: List artifacts
run: ls -laR artifacts/

- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
cat SHA256SUMS.txt

- name: Create tag (workflow_dispatch only)
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag -a ${{ steps.version.outputs.tag }} -m "Release ${{ steps.version.outputs.tag }}"
git push origin ${{ steps.version.outputs.tag }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
generate_release_notes: true
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/SHA256SUMS.txt
Loading
Loading