CI Checks

Uses the new run_docker_tests.sh script which is self-contained and handles all dependencies and test execution within a Docker container. This ensures that the CI environment is consistent with the local devcontainer environment.

Fixes an issue where the job name 'test' was considered invalid. Renamed to 'docker-tests'.
Ensures that tests marked as 'feature_complete' are also excluded from the test run.
This commit is contained in:
Adam Outler
2025-11-20 04:22:37 +01:00
parent f3de66a287
commit fd5235dd0a
4 changed files with 10 additions and 20 deletions

View File

@@ -153,9 +153,9 @@ COPY --from=builder --chown=20212:20212 ${VIRTUAL_ENV} ${VIRTUAL_ENV}
RUN if [ -f .VERSION ]; then \ RUN if [ -f .VERSION ]; then \
cp .VERSION ${NETALERTX_APP}/.VERSION; \ cp .VERSION ${NETALERTX_APP}/.VERSION; \
else \ else \
echo "DEVELOPMENT $(cd /app && git rev-parse --short HEAD 2>/dev/null || echo '00000000')" > ${NETALERTX_APP}/.VERSION; \ echo "DEVELOPMENT 00000000" > ${NETALERTX_APP}/.VERSION; \
fi && \ fi && \
chown ${READ_ONLY_USER}:${READ_ONLY_GROUP} ${NETALERTX_APP}/.VERSION && \ chown 20212:20212 ${NETALERTX_APP}/.VERSION && \
apk add libcap && \ apk add libcap && \
setcap cap_net_raw+ep /bin/busybox && \ setcap cap_net_raw+ep /bin/busybox && \
setcap cap_net_raw,cap_net_admin+eip /usr/bin/nmap && \ setcap cap_net_raw,cap_net_admin+eip /usr/bin/nmap && \

View File

@@ -21,7 +21,7 @@ jobs:
run: | run: |
echo "🔍 Checking for incorrect absolute '/php/' URLs (should be 'php/' or './php/')..." echo "🔍 Checking for incorrect absolute '/php/' URLs (should be 'php/' or './php/')..."
MATCHES=$(grep -rE "['\"]\/php\/" --include=\*.{js,php,html} ./front | grep -E "\.get|\.post|\.ajax|fetch|url\s*:") || true MATCHES=$(grep -rE "['"]\/php\/" --include=*.{js,php,html} ./front | grep -E "\.get|\.post|\.ajax|fetch|url\s*:") || true
if [ -n "$MATCHES" ]; then if [ -n "$MATCHES" ]; then
echo "$MATCHES" echo "$MATCHES"
@@ -85,25 +85,14 @@ jobs:
echo "🔍 Linting Dockerfiles..." echo "🔍 Linting Dockerfiles..."
/tmp/hadolint Dockerfile* || true /tmp/hadolint Dockerfile* || true
test: docker-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Python - name: Run Docker-based tests
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: | run: |
pip install -r requirements.txt echo "🐳 Running Docker-based tests..."
pip install pytest pyyaml chmod +x ./run_docker_tests.sh
./run_docker_tests.sh
- name: Run unit tests
run: |
echo "🧪 Running unit tests..."
export PYTHONPATH=$PYTHONPATH:./server
pytest -m "not (docker or compose or feature_complete)"

View File

@@ -66,6 +66,7 @@ CREATE TABLE Devices (
devIsArchived BOOLEAN NOT NULL DEFAULT (0) CHECK (devIsArchived IN (0, 1)), devIsArchived BOOLEAN NOT NULL DEFAULT (0) CHECK (devIsArchived IN (0, 1)),
devParentMAC TEXT, devParentMAC TEXT,
devParentPort INTEGER, devParentPort INTEGER,
devParentRelType TEXT,
devIcon TEXT, devIcon TEXT,
devGUID TEXT, devGUID TEXT,
devSite TEXT, devSite TEXT,

View File

@@ -76,7 +76,7 @@ docker exec netalertx-test-container /bin/bash -c " \
# --- 9. Execute Tests --- # --- 9. Execute Tests ---
echo "--- Executing tests inside the container ---" echo "--- Executing tests inside the container ---"
docker exec netalertx-test-container /bin/bash -c " \ docker exec netalertx-test-container /bin/bash -c " \
cd /workspaces/NetAlertX && /opt/venv/bin/pytest -m 'not (docker or compose)' --cache-clear -o cache_dir=/tmp/.pytest_cache; \ cd /workspaces/NetAlertX && /opt/venv/bin/pytest -m 'not (docker or compose or feature_complete)' --cache-clear -o cache_dir=/tmp/.pytest_cache; \
" "
# --- 10. Final Teardown --- # --- 10. Final Teardown ---