fixing github actions steps and configuration #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: COmanage Registry setup + PHPUnit (multi-PHP, multi-DB) | |
| on: | |
| workflow_dispatch: | |
| push: | |
| pull_request: | |
| jobs: | |
| setup-and-test: | |
| runs-on: | |
| - codebuild-comanage-pipeline-${{ github.run_id }}-${{ github.run_attempt }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ["8.3"] | |
| db_engine: ["postgres", "mysql", "mariadb"] | |
| env: | |
| COMANAGE_REGISTRY_DIR: /srv/comanage-registry | |
| # Values used by your PHPUnit setup test | |
| COMANAGE_REGISTRY_ADMIN_GIVEN_NAME: Admin | |
| COMANAGE_REGISTRY_ADMIN_FAMILY_NAME: User | |
| COMANAGE_REGISTRY_ADMIN_USERNAME: admin | |
| COMANAGE_REGISTRY_SECURITY_SALT: phpunit-security-salt | |
| # Values used by tests/bootstrap.php to create containers (host/port are set dynamically after start) | |
| COMANAGE_REGISTRY_DATABASE: registry_test | |
| COMANAGE_REGISTRY_DATABASE_USER: test_user | |
| COMANAGE_REGISTRY_DATABASE_USER_PASSWORD: test_password | |
| COMANAGE_REGISTRY_DATABASE_PERSISTENT: "false" | |
| steps: | |
| - name: Show OS info | |
| shell: bash | |
| run: | | |
| cat /etc/os-release | |
| uname -a | |
| - name: Checkout (only for workflow files) | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| git clone \ | |
| --depth=1 \ | |
| --branch "${GITHUB_REF_NAME}" \ | |
| "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" \ | |
| "${COMANAGE_REGISTRY_DIR}" | |
| - name: Install PHP ${{ matrix.php }} and extensions | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| software-properties-common ca-certificates gnupg | |
| sudo add-apt-repository -y ppa:ondrej/php | |
| sudo apt-get update | |
| PHP_VER="${{ matrix.php }}" | |
| sudo apt-get install -y --no-install-recommends \ | |
| php${PHP_VER}-cli \ | |
| php${PHP_VER}-mbstring \ | |
| php${PHP_VER}-intl \ | |
| php${PHP_VER}-ldap \ | |
| php${PHP_VER}-xml \ | |
| php${PHP_VER}-zip \ | |
| php${PHP_VER}-pdo \ | |
| php${PHP_VER}-mysql \ | |
| php${PHP_VER}-pgsql \ | |
| php${PHP_VER}-gd \ | |
| php${PHP_VER}-xsl \ | |
| php${PHP_VER}-memcached \ | |
| php${PHP_VER}-curl | |
| # Force the correct version via update-alternatives | |
| sudo update-alternatives --set php /usr/bin/php${PHP_VER} | |
| # Also override via /usr/local/bin which is earlier in PATH | |
| sudo ln -sf /usr/bin/php${PHP_VER} /usr/local/bin/php | |
| # Persist for subsequent steps | |
| echo "PHP_VER=${PHP_VER}" >> "$GITHUB_ENV" | |
| # Prepend /usr/local/bin to PATH for all subsequent steps | |
| echo "/usr/local/bin" >> "$GITHUB_PATH" | |
| - name: Install OS packages needed for setup | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| wget curl tar ca-certificates \ | |
| git unzip \ | |
| libicu-dev \ | |
| libldap2-dev \ | |
| libxml2 \ | |
| zlib1g \ | |
| libsodium23 \ | |
| libpng-dev \ | |
| libjpeg-dev \ | |
| libfreetype6-dev \ | |
| libxslt1.1 \ | |
| libmemcached11 \ | |
| tree | |
| - name: Show versions | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| php -v | |
| composer --version | |
| docker --version | |
| - name: Create local/config/database.php placeholder | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| cd "${COMANAGE_REGISTRY_DIR}"/local/config | |
| sudo touch database.php | |
| sudo chown www-data:www-data database.php | |
| sudo tee "database.php" > /dev/null <<'EOF' | |
| <?php | |
| // Placeholder: actual connection is configured dynamically by tests/bootstrap.php via Testcontainers | |
| return []; | |
| EOF | |
| - name: Show working directory | |
| shell: bash | |
| run: | | |
| tree -L 3 "${COMANAGE_REGISTRY_DIR}" | |
| - name: Run PHPUnit (DB_ENGINE=${{ matrix.db_engine }}) | |
| shell: bash | |
| working-directory: /srv/comanage-registry/app | |
| env: | |
| DB_ENGINE: ${{ matrix.db_engine }} | |
| run: | | |
| set -euxo pipefail | |
| cd "${COMANAGE_REGISTRY_DIR}"/app | |
| DB_ENGINE="${DB_ENGINE}" vendor/bin/phpunit --testsuite app |