kanidm/Makefile

316 lines
9.4 KiB
Makefile
Raw Permalink Normal View History

IMAGE_BASE ?= kanidm
2020-08-06 08:05:33 +02:00
IMAGE_VERSION ?= devel
IMAGE_EXT_VERSION ?= 1.2.1
CONTAINER_TOOL_ARGS ?=
2020-12-30 03:29:01 +01:00
IMAGE_ARCH ?= "linux/amd64,linux/arm64"
2022-05-26 13:13:07 +02:00
CONTAINER_BUILD_ARGS ?=
MARKDOWN_FORMAT_ARGS ?= --options-line-width=100
CONTAINER_TOOL ?= docker
2023-02-17 08:02:01 +01:00
BUILDKIT_PROGRESS ?= plain
Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
TESTS ?=
BOOK_VERSION ?= master
GIT_COMMIT := $(shell git rev-parse HEAD)
.DEFAULT: help
.PHONY: help
help:
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
.PHONY: run
run: ## Run the test/dev server
run:
cd server/daemon && ./run_insecure_dev_server.sh
.PHONY: buildx/kanidmd
buildx/kanidmd: ## Build multiarch kanidm server images and push to docker hub
2023-02-17 08:02:01 +01:00
buildx/kanidmd:
@echo $(IMAGE_EXT_VERSION)
@$(CONTAINER_TOOL) buildx build $(CONTAINER_TOOL_ARGS) \
--pull --push --platform $(IMAGE_ARCH) \
-f server/Dockerfile \
-t $(IMAGE_BASE)/server:$(IMAGE_VERSION) \
-t $(IMAGE_BASE)/server:$(IMAGE_EXT_VERSION) \
2023-02-17 08:02:01 +01:00
--progress $(BUILDKIT_PROGRESS) \
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
--build-arg "KANIDM_FEATURES=" \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
$(CONTAINER_BUILD_ARGS) .
.PHONY: buildx/kanidm_tools
2022-11-09 22:42:03 +01:00
buildx/kanidm_tools: ## Build multiarch kanidm tool images and push to docker hub
2023-02-17 08:02:01 +01:00
buildx/kanidm_tools:
2022-11-09 22:42:03 +01:00
@$(CONTAINER_TOOL) buildx build $(CONTAINER_TOOL_ARGS) \
--pull --push --platform $(IMAGE_ARCH) \
-f tools/Dockerfile \
2022-11-09 22:42:03 +01:00
-t $(IMAGE_BASE)/tools:$(IMAGE_VERSION) \
-t $(IMAGE_BASE)/tools:$(IMAGE_EXT_VERSION) \
2023-02-17 08:02:01 +01:00
--progress $(BUILDKIT_PROGRESS) \
2022-11-09 22:42:03 +01:00
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
--build-arg "KANIDM_FEATURES=" \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
2022-11-09 22:42:03 +01:00
$(CONTAINER_BUILD_ARGS) .
.PHONY: buildx/radiusd
buildx/radiusd: ## Build multi-arch radius docker images and push to docker hub
2020-08-17 09:16:33 +02:00
buildx/radiusd:
@$(CONTAINER_TOOL) buildx build $(CONTAINER_TOOL_ARGS) \
--pull --push --platform $(IMAGE_ARCH) \
-f rlm_python/Dockerfile \
2023-02-17 08:02:01 +01:00
--progress $(BUILDKIT_PROGRESS) \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
-t $(IMAGE_BASE)/radius:$(IMAGE_VERSION) \
-t $(IMAGE_BASE)/radius:$(IMAGE_EXT_VERSION) .
2020-08-17 09:16:33 +02:00
.PHONY: buildx
buildx: buildx/kanidmd buildx/kanidm_tools buildx/radiusd
2020-08-17 09:16:33 +02:00
.PHONY: build/kanidmd
build/kanidmd: ## Build the kanidmd docker image locally
build/kanidmd:
@$(CONTAINER_TOOL) build $(CONTAINER_TOOL_ARGS) -f server/Dockerfile \
-t $(IMAGE_BASE)/server:$(IMAGE_VERSION) \
--build-arg "KANIDM_BUILD_PROFILE=container_generic" \
--build-arg "KANIDM_FEATURES=" \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
$(CONTAINER_BUILD_ARGS) .
.PHONY: build/radiusd
build/radiusd: ## Build the radiusd docker image locally
build/radiusd:
@$(CONTAINER_TOOL) build $(CONTAINER_TOOL_ARGS) \
-f rlm_python/Dockerfile \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
-t $(IMAGE_BASE)/radius:$(IMAGE_VERSION) .
.PHONY: build
2020-06-30 06:21:59 +02:00
build: build/kanidmd build/radiusd
.PHONY: test/kanidmd
test/kanidmd: ## Run cargo test in docker
2020-06-30 06:21:59 +02:00
test/kanidmd:
@$(CONTAINER_TOOL) build \
$(CONTAINER_TOOL_ARGS) -f server/Dockerfile \
2020-06-30 06:21:59 +02:00
--target builder \
-t $(IMAGE_BASE)/server:$(IMAGE_VERSION)-builder \
--label "com.kanidm.git-commit=$(GIT_COMMIT)" \
--label "com.kanidm.version=$(IMAGE_EXT_VERSION)" \
$(CONTAINER_BUILD_ARGS) .
@$(CONTAINER_TOOL) run --rm $(IMAGE_BASE)/server:$(IMAGE_VERSION)-builder cargo test
2020-06-30 06:21:59 +02:00
.PHONY: test/radiusd
test/radiusd: ## Run a test radius server
test/radiusd: build/radiusd
cd rlm_python && \
./run_radius_container.sh
.PHONY: test
test:
cargo test
2020-06-30 06:21:59 +02:00
.PHONY: precommit
precommit: ## all the usual test things
precommit: test codespell test/pykanidm doc/format
.PHONY: vendor
vendor: ## Vendor required crates
vendor:
2023-02-06 00:50:10 +01:00
cargo vendor > cargo_vendor_config
.PHONY: vendor-prep
vendor-prep: vendor
tar -cJf vendor.tar.xz vendor
.PHONY: install-tools
2023-01-23 10:56:49 +01:00
install-tools: ## install kanidm_tools in your local environment
install-tools:
cargo install --path tools/cli --force
.PHONY: codespell
2023-05-11 00:30:13 +02:00
codespell: ## spell-check things.
codespell:
codespell -c \
-D .codespell_dictionary \
--ignore-words .codespell_ignore \
--skip='./target,./pykanidm/.venv,./pykanidm/.mypy_cache,./.mypy_cache,./pykanidm/poetry.lock' \
2023-10-24 06:00:37 +02:00
--skip='./book/*.js' \
2023-03-07 02:50:45 +01:00
--skip='./book/book/*' \
2023-07-07 10:53:31 +02:00
--skip='./book/src/images/*' \
--skip='./docs/*,./.git' \
--skip='*.svg' \
--skip='*.br' \
--skip='./rlm_python/mods-available/eap' \
--skip='./server/web_ui/static/external' \
--skip='./server/web_ui/pkg/external' \
--skip='./server/web_ui/shared/static/external' \
--skip='./server/web_ui/admin/static/external,./server/web_ui/admin/pkg/external' \
--skip='./server/lib/src/constants/system_config.rs,./pykanidm/site,./server/lib/src/constants/*.json'
.PHONY: test/pykanidm/pytest
2023-01-23 10:56:49 +01:00
test/pykanidm/pytest: ## python library testing
cd pykanidm && \
poetry install && \
poetry run pytest -vv
2023-01-23 10:56:49 +01:00
.PHONY: test/pykanidm/lint
test/pykanidm/lint: ## python library linting
cd pykanidm && \
poetry install && \
2023-01-23 10:56:49 +01:00
poetry run ruff tests kanidm
.PHONY: test/pykanidm/mypy
2023-01-23 10:56:49 +01:00
test/pykanidm/mypy: ## python library type checking
cd pykanidm && \
poetry install && \
echo "Running mypy" && \
poetry run mypy --strict tests kanidm
.PHONY: test/pykanidm
2023-01-23 10:56:49 +01:00
test/pykanidm: ## run the kanidm python module test suite (mypy/lint/pytest)
test/pykanidm: test/pykanidm/pytest test/pykanidm/mypy test/pykanidm/lint
########################################################################
.PHONY: doc
doc: ## Build the rust documentation locally
doc:
cargo doc --document-private-items
.PHONY: doc/format
doc/format: ## Format docs and the Kanidm book
2023-10-24 06:00:37 +02:00
find . -type f \
-not -path './target/*' \
-not -path './docs/*' \
-not -path '*/.venv/*' -not -path './vendor/*'\
-not -path '*/.*/*' \
-name \*.md \
-exec deno fmt --check $(MARKDOWN_FORMAT_ARGS) "{}" +
.PHONY: doc/format/fix
doc/format/fix: ## Fix docs and the Kanidm book
find . -type f -not -path './target/*' -not -path '*/.venv/*' -not -path './vendor/*'\
-name \*.md \
-exec deno fmt $(MARKDOWN_FORMAT_ARGS) "{}" +
.PHONY: book
book: ## Build the Kanidm book
book:
2023-10-24 06:00:37 +02:00
echo "Building rust docs"
cargo doc --no-deps --quiet
mdbook build book
rm -rf ./docs/
mv ./book/book/ ./docs/
2023-10-24 06:00:37 +02:00
mkdir -p $(PWD)/docs/rustdoc/${BOOK_VERSION}/
rsync -a --delete $(PWD)/target/doc/ $(PWD)/docs/rustdoc/${BOOK_VERSION}/
.PHONY: book_versioned
book_versioned:
echo "Book version: ${BOOK_VERSION}"
rm -rf ./target/doc
git switch -c "${BOOK_VERSION}"
git pull origin "${BOOK_VERSION}"
cargo doc --no-deps --quiet
mdbook build book
rm -rf ./docs/
mkdir -p ./docs
mv ./book/book/ ./docs/${BOOK_VERSION}/
mkdir -p ./docs/${BOOK_VERSION}/rustdoc/
mv ./target/doc/* ./docs/${BOOK_VERSION}/rustdoc/
git switch master
.PHONY: clean_book
clean_book:
rm -rf ./docs
.PHONY: docs/pykanidm/build
docs/pykanidm/build: ## Build the mkdocs
docs/pykanidm/build:
cd pykanidm && \
poetry install && \
poetry run mkdocs build
.PHONY: docs/pykanidm/serve
docs/pykanidm/serve: ## Run the local mkdocs server
docs/pykanidm/serve:
cd pykanidm && \
poetry install && \
poetry run mkdocs serve
########################################################################
2023-02-17 08:02:01 +01:00
.PHONY: release/prep
prep:
cargo outdated -R
cargo audit
.PHONY: release/kanidm
release/kanidm: ## Build the Kanidm CLI - ensure you include the environment variable KANIDM_BUILD_PROFILE
cargo build -p kanidm_tools --bin kanidm --release
.PHONY: release/kanidmd
release/kanidmd: ## Build the Kanidm daemon - ensure you include the environment variable KANIDM_BUILD_PROFILE
cargo build -p daemon --bin kanidmd --release
.PHONY: release/kanidm-ssh
release/kanidm-ssh: ## Build the Kanidm SSH tools - ensure you include the environment variable KANIDM_BUILD_PROFILE
cargo build --release \
--bin kanidm_ssh_authorizedkeys \
--bin kanidm_ssh_authorizedkeys_direct
.PHONY: release/kanidm-unixd
release/kanidm-unixd: ## Build the Kanidm UNIX tools - ensure you include the environment variable KANIDM_BUILD_PROFILE
release/kanidm-unixd:
cargo build -p pam_kanidm --release
cargo build -p nss_kanidm --release
cargo build --features unix -p kanidm_unix_int --release \
--bin kanidm_unixd \
--bin kanidm_unixd_tasks \
--bin kanidm-unix
# cert things
.PHONY: cert/clean
cert/clean: ## clean out the insecure cert bits
cert/clean:
rm -f /tmp/kanidm/*.pem
rm -f /tmp/kanidm/*.cnf
rm -f /tmp/kanidm/*.csr
rm -f /tmp/kanidm/ca.txt*
rm -f /tmp/kanidm/ca.{cnf,srl,srl.old}
2023-02-28 02:39:39 +01:00
.PHONY: webui
webui: ## Build the WASM web frontend
cd server/web_ui && ./build_wasm.sh
.PHONY: webui/test
webui/test: ## Run wasm-pack test
cd server/web_ui/shared/ && wasm-pack test --headless --chrome --mode no-install
Converting from tide to axum (#1797) * Starting to chase down testing * commenting out unused/inactive endpoints, adding more tests * clippyism * making clippy happy v2 * testing when things are not right * moar checkpoint * splitting up testkit things a bit * moving https -> tide * mad lad be crabbin * spawning like a frog * something something different spawning * woot it works ish * more server things * adding version header to requests * adding kopid_middleware * well that was supposed to be an hour... four later * more nonsense * carrying on with the conversion * first pass through the conversion is DONE! * less pub more better * session storage works better, fixed some paths * axum-csp version thing * try a typedheader * better openssl config things * updating lockfile * http2 * actually sending JSON when we say we will! * just about to do something dumb * flargl * more yak shaving * So many clippy-isms, fixing up a query handler bleep bloop * So many clippy-isms, fixing up a query handler bleep bloop * fmt * all tests pass including basic web logins and nav * so much clippyism * stripping out old comments * fmt * commenty things * stripping out tide * updates * de-tiding things * fmt * adding optional header matching ,thanks @cuberoot74088 * oauth2 stuff to match #1807 but in axum * CLIPPY IS FINALLY SATED * moving scim from /v1/scim to /scim * one day clippy will make sense * cleanups * removing sketching middleware * cleanup, strip a broken test endpoint (routemap), more clippy * docs fmt * pulling axum-csp from the wrong cargo.toml * docs fmt * fmt fixes
2023-07-05 14:26:39 +02:00
.PHONY: rust/coverage
coverage/test: ## Run coverage tests
coverage/test:
LLVM_PROFILE_FILE="$(PWD)/target/profile/coverage-%p-%m.profraw" RUSTFLAGS="-C instrument-coverage" cargo test $(TESTS)
.PHONY: coverage/grcov
coverage/grcov: ## Run grcov
coverage/grcov:
rm -rf ./target/coverage/html
grcov . --binary-path ./target/debug/deps/ \
-s . \
-t html \
--branch \
--ignore-not-existing \
--ignore '../*' \
--ignore "/*" \
--ignore "target/*" \
-o target/coverage/html
.PHONY: coverage
coverage: ## Run all the coverage tests
coverage: coverage/test coverage/grcov
echo "Coverage report is in ./target/coverage/html/index.html"