diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml new file mode 100644 index 0000000..bc7b9cb --- /dev/null +++ b/.github/workflows/ci-rust.yml @@ -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 }} diff --git a/justfile b/justfile index 29610be..03118ba 100644 --- a/justfile +++ b/justfile @@ -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: @@ -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