From 8a86d662944d1d3968c9ed51376b648d68a085de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 12:14:19 +0200 Subject: [PATCH 1/8] use latest requests module instead of a pinned version --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index b56771f..31f7732 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ changelog-cli flake8 flake8-colors flake8-docstrings -requests >=2.31,<3.0 +requests inflection twine setuptools From 1a2cfae0d0484ff79b098aa7e972de2dc8459e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 12:14:43 +0200 Subject: [PATCH 2/8] Fix compose file * use correct default verion * provide container_names for better handling in later steps --- tests/docker/docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/docker/docker-compose.yml b/tests/docker/docker-compose.yml index 6a83638..2596560 100644 --- a/tests/docker/docker-compose.yml +++ b/tests/docker/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: phpipam: - image: "phpipam/phpipam-www:v${PHPIPAM_VERSION:-1.4.4}" + image: "phpipam/phpipam-www:${PHPIPAM_VERSION:-v1.4.4}" ports: - "${PHPIPAM_PORT:-443}:443" environment: @@ -11,6 +11,7 @@ services: IPAM_DATABASE_NAME: "phpipam" depends_on: - database + container_name: phpipam_test_webserver database: image: mariadb:10.3.18 ports: @@ -20,3 +21,4 @@ services: MYSQL_USER: "phpipam" MYSQL_PASSWORD: "phpipamadmin" MYSQL_DATABASE: "phpipam" + container_name: phpipam_test_db From cf6da296979e2de87c24425044638fded228cf2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:21:16 +0200 Subject: [PATCH 3/8] Fix test environment setup * remove sleep from make target `setup-phpipam` as database setup script waits on it's own * fix recognition of podman --- Makefile | 1 - tests/docker/setup_database.sh | 56 +++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 55247ed..b3f9405 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,6 @@ coverage-xml: test-all setup-phpipam: test-setup docker-compose -f tests/docker/docker-compose.yml up -d - sleep 30 sh tests/docker/setup_database.sh FORCE: diff --git a/tests/docker/setup_database.sh b/tests/docker/setup_database.sh index 0ba763a..82d684f 100644 --- a/tests/docker/setup_database.sh +++ b/tests/docker/setup_database.sh @@ -1,25 +1,51 @@ #!/bin/bash -if grep -q podman <<< $(docker --version 2> /dev/null) ; then - echo "Podman is installed" +exec 10>&1 +exec > /dev/null 2>&1 + +function info() { + echo "${@}" >&10 +} + +MYSQL_PING="mysqladmin ping -h ${DB_HOST:-127.0.0.1} -P ${DB_PORT:-3306} -u ${MYSQL_ROOT_USER:-root} -p${MYSQL_ROOT_PASSWORD:-rootpw}" + +if grep -qi podman <<< $(docker version 2> /dev/null) ; then + info "Podman is installed" DOCKER_CMD=$(which podman) fi -while ! nc -z "${DB_HOST:-127.0.0.1}" "${DB_PORT:-3306}"; do - echo "Waiting for database connection..." - sleep 1 -done +if "${DOCKER_CMD}" ps | grep -q phpipam_test_webserver && ! eval "${MYSQL_PING}" ; then + + info -n "Waiting for database connection " + while ! eval "${MYSQL_PING}" ; do + info -n "." + sleep 1 + done + info +fi + +info "Database is up" -echo "Database is up" +if [[ $(mysqlshow -u root -prootpw -h 127.0.0.1 -P 3306 phpipam 2>/dev/null | wc -l) -eq 5 ]] ; then -echo "Creating database ${DB_NAME:-phpipam}" -${DOCKER_CMD} exec -ti docker_phpipam_1 sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' + info "Creating database ${DB_NAME:-phpipam}" + ${DOCKER_CMD} exec -t phpipam_test_webserver sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' && ((init_result++)) -echo "Activating API" -mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" + info "Activating API" + mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" && ((init_result++)) -echo "Inserting API application" -mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="INSERT INTO api (app_id, app_code, app_permissions, app_security, app_lock_wait) VALUES ('ansible','aAbBcCdDeEfF00112233445566778899',2,'ssl_token',0);" + info "Inserting API application" + mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="INSERT INTO api (app_id, app_code, app_permissions, app_security, app_lock_wait) VALUES ('ansible','aAbBcCdDeEfF00112233445566778899',2,'ssl_token',0);" && ((init_result++)) + + info "Disable forced password reset" + mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE users SET passChange = 'No' WHERE username = 'Admin';" && ((init_result++)) + + [ "$init_result" -eq 4 ] && result=successful || result=failed + +else + + info "Detabase already initiated" && exit 0 + +fi -echo "Disable forced password reset" -mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE users SET passChange = 'No' WHERE username = 'Admin';" +info "Database initialisation $result" From d49035c288107f746316124c7072bb2e82bb7310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:28:09 +0200 Subject: [PATCH 4/8] Change run-on image for CI pipeline As `ubuntu-20.04` was deprecated and already removed we switched to `ubuntu-latest` instead. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a319caa..936cb21 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ on: jobs: e2e_tests: name: end to end tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: matrix: phpipam-version: ['v1.4x', 'v1.5x'] From 11814ccd905ee030b7f4f389472248eac42afb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:31:46 +0200 Subject: [PATCH 5/8] Update python versions We removed python 3.7 and 3.8 from testing scope, as these versions are not supported by github actions. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 936cb21..6c258e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: phpipam-version: ['v1.4x', 'v1.5x'] - python-version: ['3.7.x', '3.8.x', '3.9.x', '3.10.x'] + python-version: ['3.9.x', '3.10.x', '3.11.x', '3.12.0', '3.13.0'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From 5c6da21bb9e67f57cc55cd191014e8eb8dd968b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:37:27 +0200 Subject: [PATCH 6/8] Switch to setup-python@v3 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c258e8..33c7344 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: python-version: ['3.9.x', '3.10.x', '3.11.x', '3.12.0', '3.13.0'] steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - name: setup phpipam From dbe0c426ae42594428f0c6511d883095e040b265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:42:57 +0200 Subject: [PATCH 7/8] We need to upgrade docker-compose before every other step --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 33c7344..781669c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,6 +13,8 @@ jobs: phpipam-version: ['v1.4x', 'v1.5x'] python-version: ['3.9.x', '3.10.x', '3.11.x', '3.12.0', '3.13.0'] steps: + - name: Upgrade docker-compose + run: sudo apt-get install --upgrade docker-compose - uses: actions/checkout@v2 - uses: actions/setup-python@v3 with: From 812834108316be447f64e32e6a26ad69b776c93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mei=C3=9Fner?= Date: Sun, 15 Jun 2025 13:45:22 +0200 Subject: [PATCH 8/8] Add latest phpipam version to matrix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 781669c..b18e573 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - phpipam-version: ['v1.4x', 'v1.5x'] + phpipam-version: ['v1.4x', 'v1.5x', 'v1.6x', 'v1.7x'] python-version: ['3.9.x', '3.10.x', '3.11.x', '3.12.0', '3.13.0'] steps: - name: Upgrade docker-compose