From fd5235dd0ae6b9c9b40b5dc65427bb61146f17bf Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Thu, 20 Nov 2025 04:22:37 +0100 Subject: [PATCH] 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. --- .devcontainer/Dockerfile | 4 ++-- .github/workflows/code_checks.yml | 23 +++++-------------- .../entrypoint.d/20-first-run-db.sh | 1 + run_docker_tests.sh | 2 +- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 66b9fa98..137e8c8a 100755 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -153,9 +153,9 @@ COPY --from=builder --chown=20212:20212 ${VIRTUAL_ENV} ${VIRTUAL_ENV} RUN if [ -f .VERSION ]; then \ cp .VERSION ${NETALERTX_APP}/.VERSION; \ 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 && \ - chown ${READ_ONLY_USER}:${READ_ONLY_GROUP} ${NETALERTX_APP}/.VERSION && \ + chown 20212:20212 ${NETALERTX_APP}/.VERSION && \ apk add libcap && \ setcap cap_net_raw+ep /bin/busybox && \ setcap cap_net_raw,cap_net_admin+eip /usr/bin/nmap && \ diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 48db0534..72aa0223 100755 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -21,7 +21,7 @@ jobs: run: | 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 echo "$MATCHES" @@ -85,25 +85,14 @@ jobs: echo "๐Ÿ” Linting Dockerfiles..." /tmp/hadolint Dockerfile* || true - test: + docker-tests: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Install dependencies + - name: Run Docker-based tests run: | - pip install -r requirements.txt - pip install pytest pyyaml - - - name: Run unit tests - run: | - echo "๐Ÿงช Running unit tests..." - export PYTHONPATH=$PYTHONPATH:./server - pytest -m "not (docker or compose or feature_complete)" - + echo "๐Ÿณ Running Docker-based tests..." + chmod +x ./run_docker_tests.sh + ./run_docker_tests.sh \ No newline at end of file diff --git a/install/production-filesystem/entrypoint.d/20-first-run-db.sh b/install/production-filesystem/entrypoint.d/20-first-run-db.sh index e7d04df4..9f4e735d 100755 --- a/install/production-filesystem/entrypoint.d/20-first-run-db.sh +++ b/install/production-filesystem/entrypoint.d/20-first-run-db.sh @@ -66,6 +66,7 @@ CREATE TABLE Devices ( devIsArchived BOOLEAN NOT NULL DEFAULT (0) CHECK (devIsArchived IN (0, 1)), devParentMAC TEXT, devParentPort INTEGER, + devParentRelType TEXT, devIcon TEXT, devGUID TEXT, devSite TEXT, diff --git a/run_docker_tests.sh b/run_docker_tests.sh index 721bce26..93a91ba9 100755 --- a/run_docker_tests.sh +++ b/run_docker_tests.sh @@ -76,7 +76,7 @@ docker exec netalertx-test-container /bin/bash -c " \ # --- 9. Execute Tests --- echo "--- Executing tests inside the container ---" 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 ---