Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

dev: Add CI test step

Clémence Lesné0e20f426b91c
diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml
index b6f804b..c99bdd1 100644
--- a/.github/workflows/pipeline.yaml
+++ b/.github/workflows/pipeline.yaml
@@ -1,4 +1,4 @@
-name: pipeline
+name: Pipeline
on:
push:
@@ -86,6 +86,68 @@ jobs:
with:
sarif_file: semgrep.sarif
+ test:
+ name: Test
+ permissions:
+ id-token: write
+ runs-on: ubuntu-24.04
+ needs:
+ - init
+ strategy:
+ fail-fast: false
+ matrix:
+ # Run all test suites
+ step:
+ - static
+ # TODO: Enable unit tests (Azure login and config file required)
+ # - unit
+ steps:
+ - name: Checkout
+ uses: actions/[email protected]
+
+ - name: Set up uv
+ uses: astral-sh/[email protected]
+ with:
+ enable-cache: true
+ python-version: "3.12"
+ version: "0.5.x"
+
+ # - name: Login to Azure
+ # uses: Azure/[email protected]
+ # with:
+ # client-id: ${{ secrets.AZURE_CLIENT_ID }}
+ # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
+ # tenant-id: ${{ secrets.AZURE_TENANT_ID }}
+
+ - name: Cache pytest
+ uses: actions/[email protected]
+ with:
+ key: pytest-${{ github.head_ref || github.ref_name }}-${{ hashFiles('requirements-dev.txt') }}
+ path: .pytest_cache
+
+ - name: Cache Ruff
+ uses: actions/[email protected]
+ with:
+ key: ruff-${{ github.head_ref || github.ref_name }}-${{ hashFiles('requirements-dev.txt') }}
+ path: .ruff_cache
+
+ - name: Set up dependencies
+ run: make install-deps
+
+ # - name: Configure environment variables
+ # run: echo "${{ secrets.DOTENV_UNIT_TESTS }}" > .env
+
+ - name: Run tests
+ run: make test-${{ matrix.step }} version_full=${{ needs.init.outputs.VERSION_FULL }}
+
+ - name: Upload artifacts
+ uses: actions/[email protected]
+ if: always()
+ with:
+ compression-level: 9
+ name: test-${{ matrix.step }}
+ path: test-reports/*
+
build-image:
name: Build & publish image
needs:
@@ -168,8 +230,9 @@ jobs:
create-release:
name: Create release
needs:
- - init
- build-image
+ - init
+ - test
permissions:
# Allow to create releases
contents: write
diff --git a/Makefile b/Makefile
index c76d5f6..da855aa 100644
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,9 @@ install:
@echo "➡️ Installing venv..."
uv venv --python 3.12 --allow-existing
+ $(MAKE) install-deps
+
+install-deps:
@echo "➡️ Syncing dependencies..."
uv sync --extra dev
@@ -70,12 +73,17 @@ upgrade:
az bicep upgrade
test:
+ $(MAKE) test-static
+ $(MAKE) test-unit
+
+test-static:
@echo "➡️ Test code smells (Ruff)..."
uv run ruff check --select I,PL,RUF,UP,ASYNC,A,DTZ,T20,ARG,PERF --ignore RUF012
@echo "➡️ Test types (Pyright)..."
uv run pyright .
+test-unit:
@echo "➡️ Unit tests (Pytest)..."
PUBLIC_DOMAIN=dummy uv run pytest \
--junit-xml=test-reports/$(version_full).xml \