fix(ci): réduire artifact build + corriger URL YOLO ONNX (#181)
This commit is contained in:
1 parent
bf2ccad537
commit
acf3a4304c
15 files changed
+3141
-219
No files matched your search
+58
-171
@@ -40,6 +40,9 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
web_changed: ${{ steps.filter.outputs.web }}
|
web_changed: ${{ steps.filter.outputs.web }}
|
||||||
db_changed: ${{ steps.filter.outputs.db }}
|
db_changed: ${{ steps.filter.outputs.db }}
|
||||||
|
unit_changed: ${{ steps.filter.outputs.unit }}
|
||||||
|
docker_changed: ${{ steps.filter.outputs.docker }}
|
||||||
|
sonar_changed: ${{ steps.filter.outputs.sonar }}
|
||||||
deps_changed: ${{ steps.filter.outputs.deps }}
|
deps_changed: ${{ steps.filter.outputs.deps }}
|
||||||
steps:
|
steps:
|
||||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||||
@@ -98,6 +101,24 @@ jobs:
|
|||||||
echo "db=false" >> "$GITHUB_OUTPUT"
|
echo "db=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED" | grep -qE '^src/Heimdall\.Domain/|^src/Heimdall\.Application/|^tests/Heimdall\.Domain\.Tests/|^tests/Heimdall\.Application\.Tests/|^tests/Heimdall\.Agent\.Tests/|^tests/Heimdall\.Api\.Tests/'; then
|
||||||
|
echo "unit=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "unit=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED" | grep -qE '^docker/|^Dockerfile|^\.dockerignore'; then
|
||||||
|
echo "docker=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "docker=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED" | grep -qE 'sonar|SonarQube|sonarqube'; then
|
||||||
|
echo "sonar=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "sonar=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
if echo "$CHANGED" | grep -qE '\.csproj$|\.slnx$|Directory\.Build\.props$'; then
|
if echo "$CHANGED" | grep -qE '\.csproj$|\.slnx$|Directory\.Build\.props$'; then
|
||||||
echo "deps=true" >> "$GITHUB_OUTPUT"
|
echo "deps=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -110,7 +131,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build + Format
|
name: Build + Format
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
timeout-minutes: 15
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -139,9 +160,9 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: dotnet format Heimdall.slnx whitespace --verify-no-changes --no-restore
|
run: dotnet format Heimdall.slnx whitespace --verify-no-changes --no-restore
|
||||||
|
|
||||||
# Réduire l'artifact : ne garder que le runtime linux-x64 (seul utilisé en CI).
|
# Réduire l'artifact : ne garder que bin/Release (pas obj/Release) et le
|
||||||
# Sans RID, bin/ contient ~520 MB de runtimes multi-plateforme inutiles → artifact
|
# runtime linux-x64. Sans ces optimisations, l'artifact dépasse 700 MB et
|
||||||
# de 809 MB qui sature les runners (flaky 'context deadline exceeded').
|
# le daemon Docker/runner timeout pendant l'upload (context deadline exceeded).
|
||||||
- name: Réduire build (garder runtime linux-x64)
|
- name: Réduire build (garder runtime linux-x64)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -160,9 +181,7 @@ jobs:
|
|||||||
name: build-output
|
name: build-output
|
||||||
path: |
|
path: |
|
||||||
src/**/bin/Release/
|
src/**/bin/Release/
|
||||||
src/**/obj/Release/
|
|
||||||
tests/**/bin/Release/
|
tests/**/bin/Release/
|
||||||
tests/**/obj/Release/
|
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
@@ -170,7 +189,8 @@ jobs:
|
|||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
test-unit:
|
test-unit:
|
||||||
name: Tests unitaires
|
name: Tests unitaires
|
||||||
needs: [build]
|
needs: [build, changes]
|
||||||
|
if: needs.changes.outputs.unit_changed == 'true' || needs.changes.outputs.deps_changed == 'true'
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
outputs:
|
outputs:
|
||||||
@@ -279,155 +299,13 @@ jobs:
|
|||||||
echo "EOF"
|
echo "EOF"
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
|
||||||
# TESTS DB — Infrastructure (parallèle avec Integration)
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
|
||||||
test-db-infra:
|
|
||||||
name: Tests DB (Infrastructure)
|
|
||||||
needs: [build, changes]
|
|
||||||
if: needs.changes.outputs.db_changed == 'true'
|
|
||||||
runs-on: debian-12
|
|
||||||
timeout-minutes: 15
|
|
||||||
outputs:
|
|
||||||
summary: ${{ steps.gen-summary.outputs.summary }}
|
|
||||||
steps:
|
|
||||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: '10.0'
|
|
||||||
|
|
||||||
- name: Download build artifacts
|
|
||||||
uses: https://forgejo.tordais.cc/actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: build-output
|
|
||||||
|
|
||||||
- name: Start PostgreSQL
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
apt-get -qq update
|
|
||||||
apt-get install -y -qq --no-install-recommends postgresql-15 postgresql-client-15
|
|
||||||
PGDATA=/tmp/pgdata
|
|
||||||
rm -rf "$PGDATA"
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/initdb -D $PGDATA --auth=trust --no-locale --encoding=UTF8"
|
|
||||||
su - postgres -c "echo -e 'host all all 127.0.0.1/32 md5\nhost all all ::1/128 md5' >> $PGDATA/pg_hba.conf"
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/pg_ctl -D $PGDATA -l /tmp/pgdata.log start"
|
|
||||||
for i in $(seq 1 15); do
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/pg_isready -h localhost" > /dev/null 2>&1 && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
su - postgres -c "psql -c \"CREATE USER app WITH PASSWORD 'password';\"" 2>/dev/null || true
|
|
||||||
su - postgres -c "psql -c \"CREATE DATABASE heimdall_infra_$\$ OWNER app;\"" 2>/dev/null || true
|
|
||||||
PGPASSWORD=password psql -U app -d heimdall_infra_$\$ -h localhost -c "SELECT 1" > /dev/null
|
|
||||||
echo "PostgreSQL prêt (infra)"
|
|
||||||
|
|
||||||
- name: Run Infrastructure tests
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
DATABASE_URL: Host=localhost;Port=5432;Database=heimdall_infra_$\$;Username=app;Password=password
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
mkdir -p /tmp/coverage
|
|
||||||
LOG=/tmp/Heimdall.Infrastructure.Tests.log
|
|
||||||
dotnet test tests/Heimdall.Infrastructure.Tests/Heimdall.Infrastructure.Tests.csproj --no-build -c Release --nologo --blame-hang-timeout 180s \
|
|
||||||
-p:CollectCoverage=true -p:CoverletOutputFormat=cobertura \
|
|
||||||
-p:CoverletOutput=/tmp/coverage/Infrastructure/ > "$LOG" 2>&1 || {
|
|
||||||
tail -40 "$LOG" | sed 's/^/ /'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
grep -h -E "(Passed!|Failed!|Failed:|error CS)" "$LOG" 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Générer le résumé
|
|
||||||
id: gen-summary
|
|
||||||
if: always()
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
SUMMARY=$(python3 scripts/ci/parse_test_log.py /tmp/*.log --coverage-dir /tmp/coverage 2>/dev/null || true)
|
|
||||||
{
|
|
||||||
echo "summary<<EOF"
|
|
||||||
printf '%s\n' "$SUMMARY"
|
|
||||||
echo "EOF"
|
|
||||||
} >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
|
||||||
# TESTS DB — Integration (parallèle avec Infrastructure)
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
|
||||||
test-db-integration:
|
|
||||||
name: Tests DB (Integration)
|
|
||||||
needs: [build, changes]
|
|
||||||
if: needs.changes.outputs.db_changed == 'true'
|
|
||||||
runs-on: debian-12
|
|
||||||
timeout-minutes: 20
|
|
||||||
outputs:
|
|
||||||
summary: ${{ steps.gen-summary.outputs.summary }}
|
|
||||||
steps:
|
|
||||||
- uses: https://forgejo.tordais.cc/actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: https://forgejo.tordais.cc/actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: '10.0'
|
|
||||||
|
|
||||||
- name: Download build artifacts
|
|
||||||
uses: https://forgejo.tordais.cc/actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: build-output
|
|
||||||
|
|
||||||
- name: Start PostgreSQL
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
apt-get -qq update
|
|
||||||
apt-get install -y -qq --no-install-recommends postgresql-15 postgresql-client-15
|
|
||||||
PGDATA=/tmp/pgdata
|
|
||||||
rm -rf "$PGDATA"
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/initdb -D $PGDATA --auth=trust --no-locale --encoding=UTF8"
|
|
||||||
su - postgres -c "echo -e 'host all all 127.0.0.1/32 md5\nhost all all ::1/128 md5' >> $PGDATA/pg_hba.conf"
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/pg_ctl -D $PGDATA -l /tmp/pgdata.log start"
|
|
||||||
for i in $(seq 1 15); do
|
|
||||||
su - postgres -c "/usr/lib/postgresql/15/bin/pg_isready -h localhost" > /dev/null 2>&1 && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
su - postgres -c "psql -c \"CREATE USER app WITH PASSWORD 'password';\"" 2>/dev/null || true
|
|
||||||
su - postgres -c "psql -c \"CREATE DATABASE heimdall_integ_$\$ OWNER app;\"" 2>/dev/null || true
|
|
||||||
PGPASSWORD=password psql -U app -d heimdall_integ_$\$ -h localhost -c "SELECT 1" > /dev/null
|
|
||||||
echo "PostgreSQL prêt (integration)"
|
|
||||||
|
|
||||||
- name: Run Integration tests
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
DATABASE_URL: Host=localhost;Port=5432;Database=heimdall_integ_$\$;Username=app;Password=password
|
|
||||||
ASPNETCORE_ENVIRONMENT: Testing
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
mkdir -p /tmp/coverage
|
|
||||||
LOG=/tmp/Heimdall.IntegrationTests.log
|
|
||||||
dotnet test tests/Heimdall.IntegrationTests/Heimdall.IntegrationTests.csproj --no-build -c Release --nologo --blame-hang-timeout 180s \
|
|
||||||
-p:CollectCoverage=true -p:CoverletOutputFormat=cobertura \
|
|
||||||
-p:CoverletOutput=/tmp/coverage/Integration/ > "$LOG" 2>&1 || {
|
|
||||||
tail -40 "$LOG" | sed 's/^/ /'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
grep -h -E "(Passed!|Failed!|Failed:|error CS)" "$LOG" 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Générer le résumé
|
|
||||||
id: gen-summary
|
|
||||||
if: always()
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
SUMMARY=$(python3 scripts/ci/parse_test_log.py /tmp/*.log --coverage-dir /tmp/coverage 2>/dev/null || true)
|
|
||||||
{
|
|
||||||
echo "summary<<EOF"
|
|
||||||
printf '%s\n' "$SUMMARY"
|
|
||||||
echo "EOF"
|
|
||||||
} >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
# SONARQUBE — analyse (non bloquant, gate en warning)
|
# SONARQUBE — analyse (non bloquant, gate en warning)
|
||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
sonar:
|
sonar:
|
||||||
name: SonarQube
|
name: SonarQube
|
||||||
needs: [build]
|
needs: [build, changes]
|
||||||
|
if: needs.changes.outputs.sonar_changed == 'true' || needs.changes.outputs.deps_changed == 'true' || needs.changes.outputs.db_changed == 'true' || needs.changes.outputs.unit_changed == 'true' || needs.changes.outputs.web_changed == 'true'
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
timeout-minutes: 40
|
timeout-minutes: 40
|
||||||
steps:
|
steps:
|
||||||
@@ -647,7 +525,8 @@ jobs:
|
|||||||
# ─────────────────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────────────────
|
||||||
docker-pr:
|
docker-pr:
|
||||||
name: Docker PR
|
name: Docker PR
|
||||||
if: github.event_name == 'pull_request'
|
needs: [build, changes]
|
||||||
|
if: needs.changes.outputs.docker_changed == 'true' || needs.changes.outputs.deps_changed == 'true'
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
@@ -762,7 +641,7 @@ jobs:
|
|||||||
post-summary:
|
post-summary:
|
||||||
name: Résumé tests (PR)
|
name: Résumé tests (PR)
|
||||||
if: always() && github.event_name == 'pull_request'
|
if: always() && github.event_name == 'pull_request'
|
||||||
needs: [changes, test-unit, test-web, test-db-infra, test-db-integration]
|
needs: [changes, build, test-unit, test-web]
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
@@ -774,19 +653,34 @@ jobs:
|
|||||||
FORGEJO_TOKEN: ${{ github.token }}
|
FORGEJO_TOKEN: ${{ github.token }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
R_BUILD: ${{ needs.build.result }}
|
||||||
|
R_UNIT: ${{ needs.test-unit.result }}
|
||||||
|
R_WEB: ${{ needs.test-web.result }}
|
||||||
S_UNIT: ${{ needs.test-unit.outputs.summary }}
|
S_UNIT: ${{ needs.test-unit.outputs.summary }}
|
||||||
S_WEB: ${{ needs.test-web.outputs.summary }}
|
S_WEB: ${{ needs.test-web.outputs.summary }}
|
||||||
S_DB: ${{ needs.test-db-infra.outputs.summary }}
|
|
||||||
WEB_SKIPPED: ${{ needs.changes.outputs.web_changed }}
|
WEB_SKIPPED: ${{ needs.changes.outputs.web_changed }}
|
||||||
DB_SKIPPED: ${{ needs.changes.outputs.db_changed }}
|
DB_SKIPPED: ${{ needs.changes.outputs.db_changed }}
|
||||||
run: |
|
run: |
|
||||||
|
# Petit helper : convertit un result (success/failure/skipped) en émoji
|
||||||
|
emoji() {
|
||||||
|
case "$1" in
|
||||||
|
success) echo "✅" ;;
|
||||||
|
failure|cancelled) echo "❌" ;;
|
||||||
|
skipped) echo "⏭️ " ;;
|
||||||
|
*) echo "❔" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
{
|
{
|
||||||
echo "## Tests unitaires"
|
echo "## Tests unitaires"
|
||||||
echo ""
|
echo ""
|
||||||
if [ -n "$S_UNIT" ]; then
|
if [ "$R_UNIT" = "failure" ]; then
|
||||||
echo "$S_UNIT"
|
echo "$(emoji "$R_UNIT") **Job en échec**"
|
||||||
|
printf '%s\n' "$S_UNIT"
|
||||||
|
elif [ -n "$S_UNIT" ]; then
|
||||||
|
echo "$(emoji "$R_UNIT")$S_UNIT"
|
||||||
else
|
else
|
||||||
echo "_Pas de résultats (job skippé)_"
|
echo "_Pas de résultats_"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "---"
|
echo "---"
|
||||||
@@ -794,24 +688,18 @@ jobs:
|
|||||||
echo "## Tests Web (bUnit)"
|
echo "## Tests Web (bUnit)"
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$WEB_SKIPPED" = "false" ]; then
|
if [ "$WEB_SKIPPED" = "false" ]; then
|
||||||
echo "_Skippé (aucun changement IHM)_"
|
echo "⏭️ _Skippé (aucun changement IHM)_"
|
||||||
elif [ -n "$S_WEB" ]; then
|
elif [ "$R_WEB" = "failure" ]; then
|
||||||
|
echo "$(emoji "$R_WEB") **Job en échec**"
|
||||||
echo "$S_WEB"
|
echo "$S_WEB"
|
||||||
|
elif [ -n "$S_WEB" ]; then
|
||||||
|
echo "$(emoji "$R_WEB")$S_WEB"
|
||||||
else
|
else
|
||||||
echo "_Pas de résultats_"
|
echo "_Pas de résultats_"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "---"
|
echo "---"
|
||||||
echo ""
|
echo ""
|
||||||
echo "## Tests DB (Infrastructure)"
|
|
||||||
echo ""
|
|
||||||
if [ "$DB_SKIPPED" = "false" ]; then
|
|
||||||
echo "_Skippé (aucun changement DB/Domain)_"
|
|
||||||
elif [ -n "$S_DB" ]; then
|
|
||||||
echo "$S_DB"
|
|
||||||
else
|
|
||||||
echo "_Pas de résultats_"
|
|
||||||
fi
|
|
||||||
} > /tmp/full-summary.md
|
} > /tmp/full-summary.md
|
||||||
python3 scripts/ci/post_comment.py "$(cat /tmp/full-summary.md)" "Résumé des tests"
|
python3 scripts/ci/post_comment.py "$(cat /tmp/full-summary.md)" "Résumé des tests"
|
||||||
|
|
||||||
@@ -822,7 +710,7 @@ jobs:
|
|||||||
name: ci
|
name: ci
|
||||||
runs-on: debian-12
|
runs-on: debian-12
|
||||||
if: always()
|
if: always()
|
||||||
needs: [build, test-unit, test-web, test-db-infra, test-db-integration, sonar, docker, dependency-check, post-summary]
|
needs: [build, test-unit, test-web, sonar, docker, dependency-check, post-summary]
|
||||||
steps:
|
steps:
|
||||||
- name: Vérifier les résultats
|
- name: Vérifier les résultats
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -831,7 +719,6 @@ jobs:
|
|||||||
echo " build: ${{ needs.build.result }}"
|
echo " build: ${{ needs.build.result }}"
|
||||||
echo " test-unit: ${{ needs.test-unit.result }}"
|
echo " test-unit: ${{ needs.test-unit.result }}"
|
||||||
echo " test-web: ${{ needs.test-web.result }}"
|
echo " test-web: ${{ needs.test-web.result }}"
|
||||||
echo " test-db: ${{ needs.test-db.result }}"
|
|
||||||
echo " sonar: ${{ needs.sonar.result }}"
|
echo " sonar: ${{ needs.sonar.result }}"
|
||||||
echo " docker: ${{ needs.docker.result }}"
|
echo " docker: ${{ needs.docker.result }}"
|
||||||
echo " dependency-check: ${{ needs.dependency-check.result }}"
|
echo " dependency-check: ${{ needs.dependency-check.result }}"
|
||||||
@@ -839,7 +726,7 @@ jobs:
|
|||||||
# Échouer si un job critique a échoué (sonar et dependency-check sont non-bloquants)
|
# Échouer si un job critique a échoué (sonar et dependency-check sont non-bloquants)
|
||||||
if [[ "${{ needs.build.result }}" == "failure" ]] || \
|
if [[ "${{ needs.build.result }}" == "failure" ]] || \
|
||||||
[[ "${{ needs.test-unit.result }}" == "failure" ]] || \
|
[[ "${{ needs.test-unit.result }}" == "failure" ]] || \
|
||||||
[[ "${{ needs.test-web.result }}" == "failure" ]]; then
|
[[ "${{ needs.test-web.result }}" == "failure" ]] || \
|
||||||
echo "❌ Un job critique a échoué"
|
echo "❌ Un job critique a échoué"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ COPY src/ src/
|
|||||||
|
|
||||||
RUN dotnet publish src/Heimdall.Agent/Heimdall.Agent.csproj -c Release -o /app -p:Version=$VERSION
|
RUN dotnet publish src/Heimdall.Agent/Heimdall.Agent.csproj -c Release -o /app -p:Version=$VERSION
|
||||||
|
|
||||||
|
# Modèle YOLOv8n pré-converti en ONNX et committé dans le repo (voir models/)
|
||||||
|
# (ultralytics ne distribue plus d'.onnx prêt ; torch/OpenCV s'installent mal en
|
||||||
|
# CI — trop lent + deps libGL/libxcb absentes. On committe le .onnx une fois.)
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -27,12 +30,8 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
|||||||
ENV ASPNETCORE_URLS=http://+:8080
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
|
|
||||||
COPY --from=build /app .
|
COPY --from=build /app .
|
||||||
|
# Modèle YOLOv8n ONNX committé dans le repo (contexte de build = racine repo)
|
||||||
# Download YOLOv8n ONNX model (spec §16: yolov8n, ~6MB)
|
COPY models/yolov8n.onnx models/yolov8n.onnx
|
||||||
ARG YOLO_MODEL_URL=https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.onnx
|
|
||||||
RUN mkdir -p models && \
|
|
||||||
wget -q -O models/yolov8n.onnx "$YOLO_MODEL_URL" && \
|
|
||||||
echo "YOLOv8n model downloaded: $(du -sh models/yolov8n.onnx | cut -f1)"
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/healthz || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/healthz || exit 1
|
||||||
|
|||||||
Binary file not shown.
@@ -5,7 +5,14 @@ Usage:
|
|||||||
parse_test_log.py <log1> <log2> ... [--coverage-dir <dir>]
|
parse_test_log.py <log1> <log2> ... [--coverage-dir <dir>]
|
||||||
|
|
||||||
Lit les fichiers de log (générés par les jobs CI) et les rapports coverage
|
Lit les fichiers de log (générés par les jobs CI) et les rapports coverage
|
||||||
cobertura (optionnel) ; sort le markdown sur stdout. Vide si rien trouvé.
|
cobertura (optionnel) ; sort le markdown sur stdout.
|
||||||
|
|
||||||
|
Comportement :
|
||||||
|
- Si des tests ont tourné : tableau agrégé (Passed/Failed/Skipped/Total)
|
||||||
|
+ liste des tests échoués nommément (si l'info est dans le log).
|
||||||
|
- Si AUCUN test n'a tourné : message explicite signalant un échec avant
|
||||||
|
l'exécution (et non plus une sortie vide silencieuse qui faisait afficher
|
||||||
|
« Pas de résultats » au récap PR).
|
||||||
"""
|
"""
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
@@ -20,53 +27,60 @@ if "--coverage-dir" in args:
|
|||||||
del args[i:i + 2]
|
del args[i:i + 2]
|
||||||
logs = [a for a in args if os.path.isfile(a)]
|
logs = [a for a in args if os.path.isfile(a)]
|
||||||
|
|
||||||
results = [] # (projet, passed, failed, skipped, total, status)
|
results = [] # (projet, failed, passed, skipped, total, status)
|
||||||
error_lines = []
|
error_lines = [] # erreurs de compilation
|
||||||
|
failed_tests = [] # noms des tests échoués
|
||||||
|
|
||||||
for f in sorted(logs):
|
for f in sorted(logs):
|
||||||
try:
|
try:
|
||||||
with open(f, errors="replace") as fh:
|
with open(f, errors="replace") as fh:
|
||||||
content = fh.read()
|
content = fh.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
# Pattern 1: "Passed! - Failed: 0, Passed: 225, Skipped: 0, Total: 225, ... - X.dll (net10.0)"
|
|
||||||
|
# --- Comptes agrégés (Pattern 1 : avec nom de DLL) ---
|
||||||
for m in re.finditer(
|
for m in re.finditer(
|
||||||
r"(Passed!|Failed!)\s+-\s+Failed:\s*(\d+),\s+Passed:\s*(\d+),\s+Skipped:\s*(\d+),\s+Total:\s*(\d+)[^:]*-\s*([\w.]+)\.dll",
|
r"(Passed!|Failed!)\s+-\s+Failed:\s*(\d+),\s+Passed:\s*(\d+),\s+Skipped:\s*(\d+),\s+Total:\s*(\d+)[^:]*-[^:]*\[?\s*([\w.]+)\.dll",
|
||||||
content,
|
content,
|
||||||
):
|
):
|
||||||
results.append((m.group(6), m.group(2), m.group(3), m.group(4), m.group(5), m.group(1)))
|
results.append((m.group(6), m.group(2), m.group(3), m.group(4), m.group(5), m.group(1)))
|
||||||
# Pattern 2: "Passed! - Failed: 0, Passed: 225, Skipped: 0, Total: 225" (without dll name)
|
|
||||||
if not results:
|
# --- Comptes agrégés (Pattern 2 : sans nom de DLL) ---
|
||||||
for m in re.finditer(
|
|
||||||
r"(Passed!|Failed!)\s+-\s+Failed:\s*(\d+),\s+Passed:\s*(\d+),\s+Skipped:\s*(\d+),\s+Total:\s*(\d+)",
|
|
||||||
content,
|
|
||||||
):
|
|
||||||
# Try to find the DLL name on the same line
|
|
||||||
line_start = content.rfind("\n", 0, m.start()) + 1
|
|
||||||
line_end = content.find("\n", m.end())
|
|
||||||
line = content[line_start:line_end] if line_end > 0 else content[line_start:]
|
|
||||||
dll_match = re.search(r"-\s*([\w.]+)\.dll", line)
|
|
||||||
proj = dll_match.group(1) if dll_match else "unknown"
|
|
||||||
results.append((proj, m.group(2), m.group(3), m.group(4), m.group(5), m.group(1)))
|
|
||||||
# Pattern 3: look for "Passed!" lines with test counts (alternative format)
|
|
||||||
for m in re.finditer(
|
for m in re.finditer(
|
||||||
r"Passed!\s*-\s*Failed:\s*(\d+),\s*Passed:\s*(\d+),\s*Skipped:\s*(\d+),\s*Total:\s*(\d+)",
|
r"(Passed!|Failed!)\s+-\s+Failed:\s*(\d+),\s+Passed:\s*(\d+),\s+Skipped:\s*(\d+),\s+Total:\s*(\d+)",
|
||||||
content,
|
content,
|
||||||
):
|
):
|
||||||
# Check if we already have this result
|
tot, passed = m.group(5), m.group(3)
|
||||||
total = m.group(4)
|
if any(r[4] == tot and r[2] == passed for r in results):
|
||||||
passed = m.group(2)
|
continue
|
||||||
if not any(r[4] == total and r[2] == passed for r in results):
|
line_start = content.rfind("\n", 0, m.start()) + 1
|
||||||
proj_match = re.search(r"-\s*([\w.]+)\.dll", content[m.end():m.end()+200])
|
line_end = content.find("\n", m.end())
|
||||||
proj = proj_match.group(1) if proj_match else "unknown"
|
line = content[line_start:line_end] if line_end > 0 else content[line_start:]
|
||||||
results.append((proj, m.group(1), m.group(2), m.group(3), m.group(4), "Passed!" if m.group(1) == "0" else "Failed!"))
|
dll_match = re.search(r"-\s*([\w.]+)\.dll", line)
|
||||||
|
proj = dll_match.group(1) if dll_match else "unknown"
|
||||||
|
results.append((proj, m.group(2), m.group(3), m.group(4), m.group(5), m.group(1)))
|
||||||
|
|
||||||
|
# --- Erreurs de compilation ---
|
||||||
for m in re.finditer(r"error CS\d+:\s*(.+)", content):
|
for m in re.finditer(r"error CS\d+:\s*(.+)", content):
|
||||||
error_lines.append(m.group(1).strip()[:120])
|
error_lines.append(m.group(1).strip()[:120])
|
||||||
|
|
||||||
if not results and not error_lines:
|
# --- Noms des tests échoués : lignes commençant par "Failed <nom qualifié>" ---
|
||||||
print("")
|
# (le compteur « Failed! » porte un '!' collé, donc pas de collision avec ce pattern)
|
||||||
|
for m in re.finditer(r"^\s*Failed\s+([A-Za-z_][\w.]*\.\w[\w.]*)\s", content, re.MULTILINE):
|
||||||
|
name = m.group(1).strip()
|
||||||
|
if name not in failed_tests:
|
||||||
|
failed_tests.append(name)
|
||||||
|
|
||||||
|
if not results and not error_lines and not failed_tests:
|
||||||
|
# Aucune exécution de test détectée : le job a échoué AVANT de lancer dotnet test,
|
||||||
|
# ou il a été skippé. On le dit explicitement plutôt que de sortir vide.
|
||||||
|
if logs:
|
||||||
|
print("_⚠️ Le job n'a produit aucun résultat de test (échec avant l'exécution ou build/DB en amont). Voir le log du job CI._")
|
||||||
|
else:
|
||||||
|
print("_⚠️ Aucun log de test produit par ce job._")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Deduplicate results by project name
|
# Dédupliquer par projet
|
||||||
seen = set()
|
seen = set()
|
||||||
unique_results = []
|
unique_results = []
|
||||||
for r in results:
|
for r in results:
|
||||||
@@ -85,9 +99,18 @@ if results:
|
|||||||
failed_total = sum(int(r[1]) for r in results)
|
failed_total = sum(int(r[1]) for r in results)
|
||||||
passed_total = sum(int(r[2]) for r in results)
|
passed_total = sum(int(r[2]) for r in results)
|
||||||
if failed_total:
|
if failed_total:
|
||||||
out.append(f"\n**⚠️ {failed_total} test(s) en échec** — voir le détail dans le job CI.")
|
out.append(f"\n**❌ {failed_total} test(s) en échec** — {passed_total} passent.")
|
||||||
else:
|
else:
|
||||||
out.append(f"\n**✅ {passed_total} tests passent.**")
|
out.append(f"\n**✅ {passed_total} tests passent.**")
|
||||||
|
|
||||||
|
# Liste nominative des tests échoués
|
||||||
|
if failed_tests:
|
||||||
|
out.append("\n**Tests en échec :**")
|
||||||
|
for name in failed_tests[:40]:
|
||||||
|
out.append(f"- ❌ `{name}`")
|
||||||
|
if len(failed_tests) > 40:
|
||||||
|
out.append(f"\n_… et {len(failed_tests) - 40} autre(s) (voir log)_")
|
||||||
|
|
||||||
if error_lines:
|
if error_lines:
|
||||||
out.append("\n**Erreurs de compilation détectées :**")
|
out.append("\n**Erreurs de compilation détectées :**")
|
||||||
for e in error_lines[:10]:
|
for e in error_lines[:10]:
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ public class UpdateCameraCommandHandler : IRequestHandler<UpdateCameraCommand, S
|
|||||||
if (request.Status.HasValue)
|
if (request.Status.HasValue)
|
||||||
camera.SetStatus(request.Status.Value);
|
camera.SetStatus(request.Status.Value);
|
||||||
|
|
||||||
await _db.SaveChangesWithRetryAsync(ct: ct).ConfigureAwait(false);
|
|
||||||
|
|
||||||
_db.AuditLogs.Add(new AuditLog(null, "Camera.Updated", "Camera", request.Id.ToString(),
|
_db.AuditLogs.Add(new AuditLog(null, "Camera.Updated", "Camera", request.Id.ToString(),
|
||||||
oldValue: JsonSerializer.Serialize(new { Name = oldName, RtspUrl = oldRtspUrl, Manufacturer = oldManufacturer, Model = oldModel }),
|
oldValue: JsonSerializer.Serialize(new { Name = oldName, RtspUrl = oldRtspUrl, Manufacturer = oldManufacturer, Model = oldModel }),
|
||||||
newValue: JsonSerializer.Serialize(new { camera.Name, camera.RtspUrl, camera.Manufacturer, camera.Model })));
|
newValue: JsonSerializer.Serialize(new { camera.Name, camera.RtspUrl, camera.Manufacturer, camera.Model })));
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public class DeleteSiteHandler : IRequestHandler<DeleteSiteCommand, ServiceResul
|
|||||||
return ServiceResult.NotFound("Site not found");
|
return ServiceResult.NotFound("Site not found");
|
||||||
|
|
||||||
site.SoftDelete();
|
site.SoftDelete();
|
||||||
await _context.SaveChangesWithRetryAsync(ct: cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
_context.AuditLogs.Add(new AuditLog(null, "Site.Deleted", "Site", request.Id.ToString()));
|
_context.AuditLogs.Add(new AuditLog(null, "Site.Deleted", "Site", request.Id.ToString()));
|
||||||
await _context.SaveChangesWithRetryAsync(ct: cancellationToken).ConfigureAwait(false);
|
await _context.SaveChangesWithRetryAsync(ct: cancellationToken).ConfigureAwait(false);
|
||||||
|
|||||||
Generated
+2448
File diff suppressed because it is too large.
Load diff
+145
@@ -0,0 +1,145 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Heimdall.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddAnalysisJobsAndUserCameras : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "AutoUpdateEnabled",
|
||||||
|
table: "sites",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "analysis_jobs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
CameraId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
AssignedAgentId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
|
JobType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||||
|
Status = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
||||||
|
Priority = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
SiteId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
RequiresGpu = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
RequiredCpuCores = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
|
||||||
|
RequiredMemoryMb = table.Column<long>(type: "bigint", nullable: false, defaultValue: 0L),
|
||||||
|
MaxExecutionTime = table.Column<long>(type: "bigint", nullable: false, defaultValue: 3000000000L),
|
||||||
|
RetryCount = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
|
||||||
|
MaxRetries = table.Column<int>(type: "integer", nullable: false, defaultValue: 3),
|
||||||
|
ParametersJson = table.Column<string>(type: "jsonb", nullable: true),
|
||||||
|
ResultJson = table.Column<string>(type: "jsonb", nullable: true),
|
||||||
|
ErrorMessage = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
DispatchedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||||
|
StartedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||||
|
CompletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_analysis_jobs", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_analysis_jobs_agents_AssignedAgentId",
|
||||||
|
column: x => x.AssignedAgentId,
|
||||||
|
principalTable: "agents",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_analysis_jobs_cameras_CameraId",
|
||||||
|
column: x => x.CameraId,
|
||||||
|
principalTable: "cameras",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_cameras",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
CameraId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_user_cameras", x => new { x.UserId, x.CameraId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_user_cameras_cameras_CameraId",
|
||||||
|
column: x => x.CameraId,
|
||||||
|
principalTable: "cameras",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_user_cameras_users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_camera_events_MetadataJson",
|
||||||
|
table: "camera_events",
|
||||||
|
column: "MetadataJson")
|
||||||
|
.Annotation("Npgsql:IndexMethod", "gin")
|
||||||
|
.Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_analysis_jobs_agent_workload",
|
||||||
|
table: "analysis_jobs",
|
||||||
|
columns: new[] { "AssignedAgentId", "Status" },
|
||||||
|
filter: "\"AssignedAgentId\" IS NOT NULL");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_analysis_jobs_camera",
|
||||||
|
table: "analysis_jobs",
|
||||||
|
column: "CameraId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_analysis_jobs_pending",
|
||||||
|
table: "analysis_jobs",
|
||||||
|
columns: new[] { "Status", "Priority", "CreatedAt" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_analysis_jobs_timeout",
|
||||||
|
table: "analysis_jobs",
|
||||||
|
columns: new[] { "Status", "DispatchedAt" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_user_cameras_CameraId",
|
||||||
|
table: "user_cameras",
|
||||||
|
column: "CameraId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_user_cameras_UserId",
|
||||||
|
table: "user_cameras",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "analysis_jobs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_cameras");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_camera_events_MetadataJson",
|
||||||
|
table: "camera_events");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AutoUpdateEnabled",
|
||||||
|
table: "sites");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "10.0.11")
|
.HasAnnotation("ProductVersion", "10.0.8")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@@ -291,6 +291,105 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
b.ToTable("agent_settings", (string)null);
|
b.ToTable("agent_settings", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Heimdall.Domain.Entities.AnalysisJob", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AssignedAgentId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("CameraId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("CompletedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DispatchedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("ErrorMessage")
|
||||||
|
.HasMaxLength(2000)
|
||||||
|
.HasColumnType("character varying(2000)");
|
||||||
|
|
||||||
|
b.Property<string>("JobType")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("character varying(50)");
|
||||||
|
|
||||||
|
b.Property<long>("MaxExecutionTime")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasDefaultValue(3000000000L);
|
||||||
|
|
||||||
|
b.Property<int>("MaxRetries")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasDefaultValue(3);
|
||||||
|
|
||||||
|
b.Property<string>("ParametersJson")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b.Property<int>("Priority")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("RequiredCpuCores")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasDefaultValue(0);
|
||||||
|
|
||||||
|
b.Property<long>("RequiredMemoryMb")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasDefaultValue(0L);
|
||||||
|
|
||||||
|
b.Property<bool>("RequiresGpu")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("ResultJson")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b.Property<int>("RetryCount")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasDefaultValue(0);
|
||||||
|
|
||||||
|
b.Property<Guid>("SiteId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("StartedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(30)
|
||||||
|
.HasColumnType("character varying(30)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CameraId")
|
||||||
|
.HasDatabaseName("ix_analysis_jobs_camera");
|
||||||
|
|
||||||
|
b.HasIndex("AssignedAgentId", "Status")
|
||||||
|
.HasDatabaseName("ix_analysis_jobs_agent_workload")
|
||||||
|
.HasFilter("\"AssignedAgentId\" IS NOT NULL");
|
||||||
|
|
||||||
|
b.HasIndex("Status", "DispatchedAt")
|
||||||
|
.HasDatabaseName("ix_analysis_jobs_timeout");
|
||||||
|
|
||||||
|
b.HasIndex("Status", "Priority", "CreatedAt")
|
||||||
|
.HasDatabaseName("ix_analysis_jobs_pending");
|
||||||
|
|
||||||
|
b.ToTable("analysis_jobs", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
@@ -992,9 +1091,11 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
modelBuilder.Entity("Heimdall.Domain.Entities.CameraEvent", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.CameraEvent", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OccurredAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<Guid?>("AgentId")
|
b.Property<Guid?>("AgentId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
@@ -1029,9 +1130,6 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
b.Property<string>("MetadataJson")
|
b.Property<string>("MetadataJson")
|
||||||
.HasColumnType("jsonb");
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
b.Property<DateTime>("OccurredAt")
|
|
||||||
.HasColumnType("timestamp with time zone");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ParentEventId")
|
b.Property<Guid?>("ParentEventId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
@@ -1068,6 +1166,11 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasIndex("DetectionHash");
|
b.HasIndex("DetectionHash");
|
||||||
|
|
||||||
|
b.HasIndex("MetadataJson");
|
||||||
|
|
||||||
|
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("MetadataJson"), "gin");
|
||||||
|
NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("MetadataJson"), new[] { "jsonb_path_ops" });
|
||||||
|
|
||||||
b.HasIndex("OccurredAt");
|
b.HasIndex("OccurredAt");
|
||||||
|
|
||||||
b.HasIndex("ParentEventId");
|
b.HasIndex("ParentEventId");
|
||||||
@@ -1083,7 +1186,7 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CameraId", "Type");
|
b.HasIndex("CameraId", "Type");
|
||||||
|
|
||||||
b.ToTable("camera_events");
|
b.ToTable("camera_events", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Heimdall.Domain.Entities.DiscoveredStreamUrl", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.DiscoveredStreamUrl", b =>
|
||||||
@@ -1523,6 +1626,9 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
.HasColumnType("character varying(500)");
|
.HasColumnType("character varying(500)");
|
||||||
|
|
||||||
|
b.Property<bool>("AutoUpdateEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
@@ -1654,6 +1760,23 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
b.ToTable("storage_policies", (string)null);
|
b.ToTable("storage_policies", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Heimdall.Domain.Entities.UserCamera", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("UserId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("CameraId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "CameraId");
|
||||||
|
|
||||||
|
b.HasIndex("CameraId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("user_cameras", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Heimdall.Domain.Entities.UserGroup", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.UserGroup", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("UserId")
|
b.Property<Guid>("UserId")
|
||||||
@@ -1962,6 +2085,24 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
b.Navigation("Agent");
|
b.Navigation("Agent");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Heimdall.Domain.Entities.AnalysisJob", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Heimdall.Domain.Entities.Agent", "AssignedAgent")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AssignedAgentId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("Heimdall.Domain.Entities.Camera", "Camera")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CameraId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AssignedAgent");
|
||||||
|
|
||||||
|
b.Navigation("Camera");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Heimdall.Domain.Entities.Site", "Site")
|
b.HasOne("Heimdall.Domain.Entities.Site", "Site")
|
||||||
@@ -2138,6 +2279,25 @@ namespace Heimdall.Infrastructure.Migrations
|
|||||||
b.Navigation("Site");
|
b.Navigation("Site");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Heimdall.Domain.Entities.UserCamera", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Heimdall.Domain.Entities.Camera", "Camera")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CameraId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Heimdall.Domain.Entities.AppUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Camera");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Heimdall.Domain.Entities.UserGroup", b =>
|
modelBuilder.Entity("Heimdall.Domain.Entities.UserGroup", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Heimdall.Domain.Entities.Group", "Group")
|
b.HasOne("Heimdall.Domain.Entities.Group", "Group")
|
||||||
|
|||||||
@@ -64,7 +64,16 @@ else
|
|||||||
@foreach (var agent in _agents)
|
@foreach (var agent in _agents)
|
||||||
{
|
{
|
||||||
<MudItem xs="12" sm="6" md="4" xl="3" @key="agent.Id">
|
<MudItem xs="12" sm="6" md="4" xl="3" @key="agent.Id">
|
||||||
<AgentCard Agent="@agent" />
|
<div class="position-relative">
|
||||||
|
<AgentCard Agent="@agent" />
|
||||||
|
<div class="d-flex justify-end pa-1" style="margin-top:-8px;">
|
||||||
|
<MudTooltip Text="Supprimer cet agent">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small"
|
||||||
|
Color="Color.Error" aria-label="Supprimer l'agent"
|
||||||
|
OnClick="@(() => ConfirmDeleteAgent(agent.Id, agent.Name))" />
|
||||||
|
</MudTooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
}
|
}
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
@@ -79,6 +88,30 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@* ─── Delete Confirmation Dialog ─── *@
|
||||||
|
<MudOverlay Visible="@_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
||||||
|
<MudDialog @bind-Visible="_confirmDeleteShow">
|
||||||
|
<TitleContent>
|
||||||
|
<MudText Typo="Typo.h6">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Warning" Class="mr-2" />
|
||||||
|
Confirmer la suppression
|
||||||
|
</MudText>
|
||||||
|
</TitleContent>
|
||||||
|
<DialogContent>
|
||||||
|
<MudText>Supprimer l'agent <strong>@_confirmDeleteName</strong> ?</MudText>
|
||||||
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||||
|
Les caméras associées seront désassignées mais pas supprimées.
|
||||||
|
</MudText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Error"
|
||||||
|
OnClick="@ExecuteDeleteAgentAsync" Loading="@_deleting" Disabled="@_deleting">
|
||||||
|
Supprimer
|
||||||
|
</MudButton>
|
||||||
|
</DialogActions>
|
||||||
|
</MudDialog>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private IReadOnlyList<AgentItem>? _agents;
|
private IReadOnlyList<AgentItem>? _agents;
|
||||||
private List<AgentStatItem> _agentStats = [];
|
private List<AgentStatItem> _agentStats = [];
|
||||||
@@ -89,6 +122,12 @@ else
|
|||||||
private int _total;
|
private int _total;
|
||||||
private string _search = "";
|
private string _search = "";
|
||||||
|
|
||||||
|
// Delete agent
|
||||||
|
private bool _confirmDeleteShow;
|
||||||
|
private Guid _confirmDeleteId;
|
||||||
|
private string _confirmDeleteName = "";
|
||||||
|
private bool _deleting;
|
||||||
|
|
||||||
[Inject] private NavigationManager Nav { get; set; } = null!;
|
[Inject] private NavigationManager Nav { get; set; } = null!;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
@@ -187,4 +226,34 @@ else
|
|||||||
_refreshCts?.Cancel();
|
_refreshCts?.Cancel();
|
||||||
_refreshCts?.Dispose();
|
_refreshCts?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Delete Agent ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
private void ConfirmDeleteAgent(Guid id, string name)
|
||||||
|
{
|
||||||
|
_confirmDeleteId = id;
|
||||||
|
_confirmDeleteName = name;
|
||||||
|
_confirmDeleteShow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteDeleteAgentAsync()
|
||||||
|
{
|
||||||
|
_deleting = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_confirmDeleteShow = false;
|
||||||
|
var error = await Api.DeleteAgentAsync(_confirmDeleteId);
|
||||||
|
if (error is null)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"Agent \"{_confirmDeleteName}\" supprimé", Severity.Success);
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Snackbar.Add(error, Severity.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||||
|
finally { _deleting = false; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -712,6 +712,14 @@ else
|
|||||||
OnClick="@(() => Nav.NavigateTo("/admin/agents"))">
|
OnClick="@(() => Nav.NavigateTo("/admin/agents"))">
|
||||||
← Tous les agents
|
← Tous les agents
|
||||||
</MudButton>
|
</MudButton>
|
||||||
|
<MudSpacer />
|
||||||
|
<MudTooltip Text="Supprimer cet agent">
|
||||||
|
<MudButton Variant="Variant.Outlined" Color="Color.Error"
|
||||||
|
StartIcon="@Icons.Material.Filled.Delete"
|
||||||
|
OnClick="@(() => _confirmDeleteAgentVisible = true)">
|
||||||
|
Supprimer
|
||||||
|
</MudButton>
|
||||||
|
</MudTooltip>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,6 +746,29 @@ else
|
|||||||
</DialogActions>
|
</DialogActions>
|
||||||
</MudDialog>
|
</MudDialog>
|
||||||
|
|
||||||
|
@* ─── Delete Agent Confirmation Dialog ─── *@
|
||||||
|
<MudDialog @bind-Visible="_confirmDeleteAgentVisible">
|
||||||
|
<TitleContent>
|
||||||
|
<MudText Typo="Typo.h6">
|
||||||
|
<MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Warning" Class="mr-2" />
|
||||||
|
Confirmer la suppression
|
||||||
|
</MudText>
|
||||||
|
</TitleContent>
|
||||||
|
<DialogContent>
|
||||||
|
<MudText>Supprimer l'agent <strong>@_agent?.Name</strong> ?</MudText>
|
||||||
|
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||||
|
Les caméras associées seront désassignées mais pas supprimées.
|
||||||
|
</MudText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteAgentVisible = false)">Annuler</MudButton>
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Error"
|
||||||
|
OnClick="@ExecuteDeleteAgentAsync" Loading="@_deletingAgent" Disabled="@_deletingAgent">
|
||||||
|
Supprimer
|
||||||
|
</MudButton>
|
||||||
|
</DialogActions>
|
||||||
|
</MudDialog>
|
||||||
|
|
||||||
@* ─── Add / Edit Dialog ─── *@
|
@* ─── Add / Edit Dialog ─── *@
|
||||||
<MudDialog @bind-Visible="_showEditDialog" Options="_dialogOptions">
|
<MudDialog @bind-Visible="_showEditDialog" Options="_dialogOptions">
|
||||||
<TitleContent>
|
<TitleContent>
|
||||||
@@ -795,6 +826,10 @@ else
|
|||||||
private string _deletingKey = string.Empty;
|
private string _deletingKey = string.Empty;
|
||||||
private bool _deleting;
|
private bool _deleting;
|
||||||
|
|
||||||
|
// Delete agent
|
||||||
|
private bool _confirmDeleteAgentVisible;
|
||||||
|
private bool _deletingAgent;
|
||||||
|
|
||||||
// Logs
|
// Logs
|
||||||
private IReadOnlyList<AgentLogItem>? _logs;
|
private IReadOnlyList<AgentLogItem>? _logs;
|
||||||
private bool _logsLoading;
|
private bool _logsLoading;
|
||||||
@@ -872,6 +907,27 @@ else
|
|||||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ExecuteDeleteAgentAsync()
|
||||||
|
{
|
||||||
|
_deletingAgent = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_confirmDeleteAgentVisible = false;
|
||||||
|
var error = await Api.DeleteAgentAsync(Id);
|
||||||
|
if (error is null)
|
||||||
|
{
|
||||||
|
Snackbar.Add($"Agent \"{_agent?.Name}\" supprimé", Severity.Success);
|
||||||
|
Nav.NavigateTo("/admin/agents");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Snackbar.Add(error, Severity.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||||
|
finally { _deletingAgent = false; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Returns the effective value for a global setting key (override wins).</summary>
|
/// <summary>Returns the effective value for a global setting key (override wins).</summary>
|
||||||
private string EffectiveValue(string key, string globalValue)
|
private string EffectiveValue(string key, string globalValue)
|
||||||
=> _settings.FirstOrDefault(s => s.Key == key)?.Value ?? globalValue;
|
=> _settings.FirstOrDefault(s => s.Key == key)?.Value ?? globalValue;
|
||||||
|
|||||||
@@ -573,6 +573,18 @@ public class HeimdallApiClient
|
|||||||
$"api/agents?page={page}&pageSize={pageSize}", Json);
|
$"api/agents?page={page}&pageSize={pageSize}", Json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Supprime un agent par son identifiant (soft-delete + désassignation des caméras).
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>null en cas de succès, sinon le message d'erreur du serveur.</returns>
|
||||||
|
public async Task<string?> DeleteAgentAsync(Guid id)
|
||||||
|
{
|
||||||
|
var client = CreateClient();
|
||||||
|
var response = await client.DeleteAsync($"api/agents/{id}");
|
||||||
|
if (response.IsSuccessStatusCode) return null;
|
||||||
|
return await ReadErrorMessageAsync(response);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Get agent-specific KPIs for the dashboard.</summary>
|
/// <summary>Get agent-specific KPIs for the dashboard.</summary>
|
||||||
public async Task<List<AgentStatItem>> GetAgentStatsAsync()
|
public async Task<List<AgentStatItem>> GetAgentStatsAsync()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
|
using Heimdall.Application.Services;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
|
||||||
namespace Heimdall.IntegrationTests.Factories;
|
namespace Heimdall.IntegrationTests.Factories;
|
||||||
|
|
||||||
@@ -30,5 +33,23 @@ public class HeimdallWebApplicationFactory : WebApplicationFactory<Program>
|
|||||||
builder.UseSetting("Jwt:RefreshKey", "ThisIsATestRefreshKeyThatIsAlso32Bytes!");
|
builder.UseSetting("Jwt:RefreshKey", "ThisIsATestRefreshKeyThatIsAlso32Bytes!");
|
||||||
builder.UseSetting("Jwt:Issuer", "heimdall-test");
|
builder.UseSetting("Jwt:Issuer", "heimdall-test");
|
||||||
builder.UseSetting("Jwt:Audience", "heimdall-test");
|
builder.UseSetting("Jwt:Audience", "heimdall-test");
|
||||||
|
|
||||||
|
// Stub HIBP: integration tests must never depend on an external breach-check
|
||||||
|
// API nor on a test password that happens not to be in the HIBP database
|
||||||
|
// (that made `api/auth/register` return 400: "password has appeared in a
|
||||||
|
// data breach"). Force "not breached" in tests only — production code path
|
||||||
|
// (HaveIBeenPwnedBreachChecker) is untouched.
|
||||||
|
builder.ConfigureServices(services =>
|
||||||
|
{
|
||||||
|
services.RemoveAll<IPasswordBreachChecker>();
|
||||||
|
services.AddScoped<IPasswordBreachChecker, NoopPasswordBreachChecker>();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Test-only stub: never flags a password as breached. Avoids network + HIBP flakiness.</summary>
|
||||||
|
internal sealed class NoopPasswordBreachChecker : IPasswordBreachChecker
|
||||||
|
{
|
||||||
|
public Task<bool> IsPasswordBreachedAsync(string password, CancellationToken ct = default)
|
||||||
|
=> Task.FromResult(false);
|
||||||
|
}
|
||||||
@@ -120,6 +120,43 @@ public class AgentDetailTests : PageTestBase
|
|||||||
|
|
||||||
cut.WaitForAssertion(() =>
|
cut.WaitForAssertion(() =>
|
||||||
Handler.Requests.Any(r => r.Method == HttpMethod.Delete
|
Handler.Requests.Any(r => r.Method == HttpMethod.Delete
|
||||||
&& r.RequestUri!.AbsolutePath.Contains($"api/settings/agent/{AgentId}/overrides")).ShouldBeTrue());
|
&& r.RequestUri!.AbsolutePath.Contains($"/api/settings/agent/{AgentId}/overrides")).ShouldBeTrue());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AgentDetail_BoutonSupprimer_Present()
|
||||||
|
{
|
||||||
|
Handler.OnGet($"/api/settings/agent/{AgentId}/overrides", new List<AgentSettingItem>());
|
||||||
|
Handler.OnGet("api/settings", new List<AppSettingItem>());
|
||||||
|
Handler.OnGet($"/api/agents/{AgentId}", Agent());
|
||||||
|
LoginAs();
|
||||||
|
|
||||||
|
var cut = RenderPage<AgentDetail>(p => p.Add(x => x.Id, AgentId));
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("agent-01"));
|
||||||
|
|
||||||
|
// Le bouton Supprimer est présent dans la zone d'actions du bas
|
||||||
|
cut.Markup.ShouldContain("Supprimer");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AgentDetail_Supprimer_OuvreDialogConfirmation()
|
||||||
|
{
|
||||||
|
Handler.OnGet($"/api/settings/agent/{AgentId}/overrides", new List<AgentSettingItem>());
|
||||||
|
Handler.OnGet("api/settings", new List<AppSettingItem>());
|
||||||
|
Handler.OnGet($"/api/agents/{AgentId}", Agent());
|
||||||
|
LoginAs();
|
||||||
|
|
||||||
|
var cut = RenderPage<AgentDetail>(p => p.Add(x => x.Id, AgentId));
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("agent-01"));
|
||||||
|
|
||||||
|
// Cliquer sur "Supprimer" ouvre le dialog de confirmation
|
||||||
|
cut.FindAll("button").Single(b => b.TextContent.Contains("Supprimer")
|
||||||
|
&& b.TextContent.Trim() != "Supprimer le réglage").Click();
|
||||||
|
|
||||||
|
cut.WaitForAssertion(() =>
|
||||||
|
{
|
||||||
|
cut.Markup.ShouldContain("Confirmer la suppression");
|
||||||
|
cut.Markup.ShouldContain("désassignées");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,4 +140,72 @@ public class AllAgentsPageTests : PageTestBase
|
|||||||
&& r.RequestUri!.PathAndQuery.Contains("api/agents")
|
&& r.RequestUri!.PathAndQuery.Contains("api/agents")
|
||||||
&& r.RequestUri.Query.Contains("page=2")).ShouldBeTrue());
|
&& r.RequestUri.Query.Contains("page=2")).ShouldBeTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AllAgentsPage_Supprimer_BoutonPresent()
|
||||||
|
{
|
||||||
|
Handler.OnGet("api/agents", new PagedData<AgentItem>(
|
||||||
|
[Agent("Agent-1"), Agent("Agent-2", "Site Beta")], 2, 1, 20));
|
||||||
|
Handler.OnGet("api/stats/agent-stats", Stats());
|
||||||
|
LoginAs();
|
||||||
|
|
||||||
|
var cut = RenderPage<AllAgentsPage>();
|
||||||
|
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Agent-1"));
|
||||||
|
// Les boutons supprimer sont présents (2 agents = 2 boutons)
|
||||||
|
var deleteButtons = cut.FindAll("[aria-label=\"Supprimer l'agent\"]");
|
||||||
|
deleteButtons.Count.ShouldBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AllAgentsPage_Supprimer_OuvreDialogConfirmation()
|
||||||
|
{
|
||||||
|
var agent = Agent("Agent-Test");
|
||||||
|
Handler.OnGet("api/agents", new PagedData<AgentItem>([agent], 1, 1, 20));
|
||||||
|
Handler.OnGet("api/stats/agent-stats", Stats());
|
||||||
|
LoginAs();
|
||||||
|
|
||||||
|
var cut = RenderPage<AllAgentsPage>();
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Agent-Test"));
|
||||||
|
|
||||||
|
// Cliquer sur le bouton supprimer ouvre le dialog
|
||||||
|
cut.Find("[aria-label=\"Supprimer l'agent\"]").Click();
|
||||||
|
|
||||||
|
cut.WaitForAssertion(() =>
|
||||||
|
{
|
||||||
|
cut.Markup.ShouldContain("Confirmer la suppression");
|
||||||
|
cut.Markup.ShouldContain("Agent-Test");
|
||||||
|
cut.Markup.ShouldContain("désassignées");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void AllAgentsPage_Supprimer_ConfirmationEnvoieDeleteEtRecharge()
|
||||||
|
{
|
||||||
|
var agent = Agent("Agent-Del");
|
||||||
|
Handler.OnGet("api/agents", new PagedData<AgentItem>([agent], 1, 1, 20));
|
||||||
|
Handler.OnGet("api/stats/agent-stats", Stats());
|
||||||
|
Handler.On(HttpMethod.Delete, "api/agents", System.Net.HttpStatusCode.OK);
|
||||||
|
// Après suppression, la liste est rechargée vide
|
||||||
|
Handler.OnGet("api/agents", new PagedData<AgentItem>([], 0, 1, 20));
|
||||||
|
LoginAs();
|
||||||
|
|
||||||
|
var cut = RenderPage<AllAgentsPage>();
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Agent-Del"));
|
||||||
|
|
||||||
|
// Ouvrir le dialog
|
||||||
|
cut.Find("[aria-label=\"Supprimer l'agent\"]").Click();
|
||||||
|
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Confirmer la suppression"));
|
||||||
|
|
||||||
|
// Cliquer "Supprimer" dans le dialog (dernier bouton avec ce texte)
|
||||||
|
var dialogButtons = cut.FindAll("button");
|
||||||
|
dialogButtons.Where(b => b.TextContent.Trim() == "Supprimer").Last().Click();
|
||||||
|
|
||||||
|
cut.WaitForAssertion(() =>
|
||||||
|
{
|
||||||
|
// Le DELETE a bien été envoyé
|
||||||
|
Handler.Requests.Any(r => r.Method == HttpMethod.Delete
|
||||||
|
&& r.RequestUri!.PathAndQuery.Contains("api/agents")).ShouldBeTrue();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user