Skip to content
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
52 changes: 52 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# EditorConfig - https://editorconfig.org
# Helps maintain consistent coding styles across different editors

root = true

# Default settings for all files
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

# Rust files
[*.rs]
indent_size = 4
max_line_length = 100

# TOML files (Cargo.toml, etc.)
[*.toml]
indent_size = 4

# YAML files
[*.{yml,yaml}]
indent_size = 2

# JSON files
[*.json]
indent_size = 2

# Markdown files
[*.md]
trim_trailing_whitespace = false
max_line_length = off

# Python files
[*.py]
indent_size = 4
max_line_length = 100

# Shell scripts
[*.sh]
indent_size = 2

# Makefiles require tabs
[Makefile]
indent_style = tab

# Git config files
[.git*]
indent_size = 4
247 changes: 247 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Minimum supported Rust version
MSRV: "1.75"

jobs:
# ==========================================================================
# Format check
# ==========================================================================
fmt:
name: Format
runs-on: ubuntu-latest
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 lints
# ==========================================================================
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: Swatinem/rust-cache@v2

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

# ==========================================================================
# Tests
# ==========================================================================
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: Swatinem/rust-cache@v2

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

- name: Run doc tests
run: cargo test --doc

# ==========================================================================
# MSRV check
# ==========================================================================
msrv:
name: MSRV (${{ env.MSRV }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust ${{ env.MSRV }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}

- name: Cache cargo
uses: Swatinem/rust-cache@v2

- name: Check MSRV
run: cargo check --all-features

# ==========================================================================
# Documentation
# ==========================================================================
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Cache cargo
uses: Swatinem/rust-cache@v2

- name: Build docs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings

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

steps:
- uses: actions/checkout@v4

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

- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools

- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: apc-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/apc
target/${{ matrix.target }}/release/apc.exe
if-no-files-found: ignore

# ==========================================================================
# Security audit
# ==========================================================================
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install cargo-audit
run: cargo install cargo-audit

- name: Run audit
run: cargo audit

# ==========================================================================
# Coverage
# ==========================================================================
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Cache cargo
uses: Swatinem/rust-cache@v2

- name: Generate coverage
run: cargo llvm-cov --all-features --lcov --output-path lcov.info

- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: false

# ==========================================================================
# All checks passed
# ==========================================================================
ci-success:
name: CI Success
needs: [fmt, clippy, test, msrv, docs, build, security]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs passed
run: |
if [[ "${{ needs.fmt.result }}" != "success" ]] || \
[[ "${{ needs.clippy.result }}" != "success" ]] || \
[[ "${{ needs.test.result }}" != "success" ]] || \
[[ "${{ needs.msrv.result }}" != "success" ]] || \
[[ "${{ needs.docs.result }}" != "success" ]] || \
[[ "${{ needs.build.result }}" != "success" ]] || \
[[ "${{ needs.security.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI checks passed!"
Loading