From a8bfb5333fbc3db38cdd317348b9511f71e88689 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 5 Mar 2024 00:50:21 +0100 Subject: [PATCH] ci(github): add documentation tests --- .github/workflows/test.yml | 4 ++++ Makefile | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 362dd5b..2713d34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,10 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: 1.76.0 + - name: Run documentation tests + run: make test-doc + env: + MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }} - name: Run tests (with coverage) run: make test-cover env: diff --git a/Makefile b/Makefile index ed2623c..549b650 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,17 @@ SHELL := /bin/bash .PHONY: test +define source_env_if_not_ci + @if [ -z "$${CI}" ]; then \ + if [ -f ./.env ]; then \ + source ./.env; \ + else \ + echo "No .env file found"; \ + exit 1; \ + fi \ + fi +endef + define RELEASE_TEMPLATE conventional-changelog -p conventionalcommits -i ./CHANGELOG.md -s git add . @@ -21,8 +32,10 @@ release-major: $(call RELEASE_TEMPLATE,major) test: - @source ./.env && cargo test --all-targets --no-fail-fast + @$(source_env_if_not_ci) && cargo test --nocapture --no-fail-fast test-cover: - cargo tarpaulin --all-targets --frozen --no-fail-fast --out Xml --skip-clean + @$(source_env_if_not_ci) && cargo tarpaulin --frozen --out Xml +test-doc: + @$(source_env_if_not_ci) && cargo test --doc --nocapture --no-fail-fast test-watch: - cargo watch -x "test -- --all-targets --nocapture" + @$(source_env_if_not_ci) && cargo watch -x "test -- --nocapture"