Skip to content

Commit

Permalink
ci: init
Browse files Browse the repository at this point in the history
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
  • Loading branch information
rissson committed Nov 4, 2024
1 parent 4de41f4 commit c56306c
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 8 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: Rust CI

"on":
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
strategy:
fail-fast: false
matrix:
job:
- clippy
- machete
include:
- job: rustfmt
toolchain: nightly
components: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- if: ${{ matrix.toolchain }}
name: Setup rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: ${{ matrix.components }}
- if: ${{ ! matrix.toolchain }}
name: Setup rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: taiki-e/install-action@v2
with:
tool: just,cargo-machete
- name: Lint
run: just ci-lint-${{ matrix.job }}
test:
strategy:
fail-fast: false
matrix:
job:
- mem
- rust
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry & deps
shell: bash
run: |
pipx install poetry || true
- name: Setup python and restore poetry
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
cache: "poetry"
- name: Install Python dependencies
run: poetry install
- name: Setup rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: taiki-e/install-action@v2
with:
tool: just
- name: Lint
run: just ci-test-${{ matrix.job }}
54 changes: 46 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,57 @@ lint-fix:
cargo fmt
black python-kadmin-rs
ruff check --fix python-kadmin-rs
ci-lint-rustfmt:
cargo fmt --check
ci-lint-black:
black --check python-kadmin-rs
ci-lint-ruff:
ruff check python-kadmin-rs
ci-lint-machete:
cargo machete

# Lint code
lint:
cargo clippy
cd kadmin-sys && cargo clippy --features client
cd kadmin-sys && cargo clippy --features server
cd kadmin && cargo clippy
cd kadmin && cargo clippy --no-default-features --features local
cd python-kadmin-rs && cargo clippy
cd python-kadmin-rs && cargo clippy --no-default-features --features local
ci-lint-clippy:
RUSTFLAGS="-Dwarnings" just lint

alias l := lint-all
# Lint and auto format
lint-all: lint-fix lint
alias l := lint-all

alias b := build-rust
# Build all rust crates
build-rust:
cargo build
alias b := build-rust
cd kadmin-sys && cargo build --features client
cd kadmin-sys && cargo build --features server
cd kadmin && cargo build
cd kadmin && cargo build --no-default-features --features local
cd python-kadmin-rs && cargo build
cd python-kadmin-rs && cargo build --no-default-features --features local
ci-build-deps:
sudo apt-get update
sudo apt-get install -y --no-install-recommends krb5-multidev
ci-build-rust:
RUSTFLAGS="-Dwarnings" just build

# Build python wheel
build-python:
build-python: ci-build-deps
python -m build
ci-build-python: build-python

# Build rust crates and python wheel
build: build-rust build-python

# Build Python wheels for all supported platforms
build-all:
build-wheels:
cibuildwheel
ci-build-wheels: ci-build-deps build-wheels

# Test kadmin-sys crate
test-kadmin-sys:
Expand All @@ -46,21 +73,32 @@ test-python-kadmin-rs:
cd python-kadmin-rs && cargo test
cd python-kadmin-rs && cargo test --no-default-features --features local

alias t := test-rust
# Test all rust crates
test-rust: test-kadmin-sys test-kadmin test-python-kadmin-rs
alias t := test-rust
ci-test-deps:
sudo apt-get update
sudo apt-get install -y --no-install-recommends valgrind libkrb5-dev krb5-kdc krb5-user krb5-admin-server
ci-test-rust: ci-test-deps
RUSTFLAGS="-Dwarnings" just test-rust

alias tm := test-mem
# Test kadmin with valgrind for memory leaks
test-mem:
cd kadmin && \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="valgrind --error-exitcode=1 --suppressions=tests/valgrind.supp -s --leak-check=full" \
cargo test
alias tm := test-mem
cd kadmin && \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="valgrind --error-exitcode=1 --suppressions=tests/valgrind.supp -s --leak-check=full" \
cargo test --no-default-features --features local
ci-test-mem: ci-test-deps
just test-mem

# Test python bindings
test-python: install-python
python -m unittest python-kadmin-rs/tests/test_*.py
stubtest kadmin kadmin_local
ci-test-python: test-python

# Test rust crates and python bindings
test-all: test-rust test-mem test-python
Expand Down

0 comments on commit c56306c

Please sign in to comment.