name: Rust CI/CD Pipeline
on:
push:
branches: '**'
pull_request:
branches: '**'
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Lint, Format & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: ๐ฆ Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy, rustfmt
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: ๐ฆ Install dependencies
run: cargo fetch
- name: ๐ Type check
run: cargo check --all --all-targets
- name: ๐งน Run formatter (cargo fmt)
run: cargo fmt --all --check
- name: ๐ Run Clippy (Linter)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: ๐งช Run unit tests
run: cargo test --lib --verbose
- name: ๐ง Run integration tests
run: cargo test --test integration_tests --verbose
- name: ๐ Run all tests
run: cargo test --verbose
cross-build:
name: Cross Compile Binaries
needs: check
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: ๐ฆ Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy, rustfmt
- name: Install cross (only for Linux)
if: matrix.os == 'ubuntu-latest'
run: cargo install cross --locked
- name: Build (Native)
run: cargo build --release
- name: Save artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}
path: |
target/release/git-editor
target/release/git-editor.exe