From de4b4fc8297ecdc02943ad4511db28988b8a2223 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2026 14:26:00 +0100 Subject: [PATCH 1/2] PHP: Expose test database env variables to setup commands This makes it possible to initialize the databases in the setup commands as needed. --- .github/workflows/php-unit.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/php-unit.yml b/.github/workflows/php-unit.yml index 62542fa..0c01b6d 100644 --- a/.github/workflows/php-unit.yml +++ b/.github/workflows/php-unit.yml @@ -43,6 +43,19 @@ jobs: steps: - uses: Icinga/github-actions/.github/actions/php-and-dependencies@main name: Setup PHP and dependencies + env: &phpunit-env + ICINGAWEB_TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} + ICINGAWEB_TEST_PGSQL_PORT: ${{ job.services.pgsql.ports['5432'] }} + MYSQL_TESTDB_HOST: 127.0.0.1 + MYSQL_TESTDB_PORT: ${{ job.services.mysql.ports['3306'] }} + MYSQL_TESTDB: icinga_unittest + MYSQL_TESTDB_USER: icinga_unittest + MYSQL_TESTDB_PASSWORD: icinga_unittest + PGSQL_TESTDB_HOST: 127.0.0.1 + PGSQL_TESTDB_PORT: ${{ job.services.pgsql.ports['5432'] }} + PGSQL_TESTDB: icinga_unittest + PGSQL_TESTDB_USER: icinga_unittest + PGSQL_TESTDB_PASSWORD: icinga_unittest with: php-version: ${{ inputs.php-version }} php-extensions: ${{ inputs.php-extensions }} @@ -58,19 +71,7 @@ jobs: run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run PHPUnit - env: - ICINGAWEB_TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} - ICINGAWEB_TEST_PGSQL_PORT: ${{ job.services.pgsql.ports['5432'] }} - MYSQL_TESTDB_HOST: 127.0.0.1 - MYSQL_TESTDB_PORT: ${{ job.services.mysql.ports['3306'] }} - MYSQL_TESTDB: icinga_unittest - MYSQL_TESTDB_USER: icinga_unittest - MYSQL_TESTDB_PASSWORD: icinga_unittest - PGSQL_TESTDB_HOST: 127.0.0.1 - PGSQL_TESTDB_PORT: ${{ job.services.pgsql.ports['5432'] }} - PGSQL_TESTDB: icinga_unittest - PGSQL_TESTDB_USER: icinga_unittest - PGSQL_TESTDB_PASSWORD: icinga_unittest + env: *phpunit-env # Unlike linting and static analysis, which report errors via the GitHub Actions API and # therefore (have to) use relative paths, we can use working-directory here because # PHPUnit provides absolute paths and GitHub Actions problem matchers work with absolute paths. From 7f07f8a4075c5363bb69f43118aebd15d9413c70 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2026 14:46:30 +0100 Subject: [PATCH 2/2] PHP: Explicitly set `MARIADB_ROOT_PASSWORD` Previously, a random password was generated by the container, making it impossible to execute setup commands with the root user. --- .github/workflows/php-unit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-unit.yml b/.github/workflows/php-unit.yml index 0c01b6d..e1a7811 100644 --- a/.github/workflows/php-unit.yml +++ b/.github/workflows/php-unit.yml @@ -122,10 +122,10 @@ jobs: # Service will not be started if image is empty. image: ${{ inputs.databases && 'mariadb' || '' }} env: - MARIADB_RANDOM_ROOT_PASSWORD: yes MARIADB_DATABASE: icinga_unittest MARIADB_USER: icinga_unittest MARIADB_PASSWORD: icinga_unittest + MARIADB_ROOT_PASSWORD: icinga_unittest options: >- --health-cmd "mariadb-admin ping" --health-interval 10s