From cba8950bf6ad8f9d56f451d5c4e3171736809b59 Mon Sep 17 00:00:00 2001 From: hungtd Date: Thu, 2 Mar 2023 14:48:59 +0700 Subject: [PATCH 1/2] github action, enable test zend ldap --- .github/workflows/phpunit.yml | 31 +++++++++++++++++++++++++++++++ tests/TestConfiguration.env.php | 28 +++++++++++++++------------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 1fb879f4f8..5adf5dda5c 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -33,6 +33,18 @@ jobs: TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED: true TESTS_ZEND_CACHE_LIBMEMCACHED_HOST: 127.0.0.1 TESTS_ZEND_CACHE_LIBMEMCACHED_PORT: 11211 + + # https://hub.docker.com/r/bitnami/openldap + LDAP_ROOT: "dc=example,dc=com" + LDAP_ALLOW_ANON_BINDING: false + LDAP_SKIP_DEFAULT_TREE: "yes" + LDAP_ADMIN_USERNAME: "admin" + LDAP_ADMIN_PASSWORD: "insecure" + LDAP_CONFIG_ADMIN_USERNAME: "admin" + LDAP_CONFIG_ADMIN_PASSWORD: "configpassword" + TESTS_ZEND_LDAP_ONLINE_ENABLED: true + TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED: true + LOCALES: "fr_FR@euro fr_FR fr_BE.UTF-8 de en_US" services: memcache: @@ -69,6 +81,20 @@ jobs: --health-timeout 5s --health-retries 5 + openldap: + image: bitnami/openldap:2.5 + ports: + - 1389:1389 + env: + LDAP_ROOT: ${{ env.LDAP_ROOT }} + LDAP_ALLOW_ANON_BINDING: ${{ env.LDAP_ALLOW_ANON_BINDING }} + LDAP_SKIP_DEFAULT_TREE: ${{ env.LDAP_SKIP_DEFAULT_TREE }} + LDAP_ADMIN_USERNAME: ${{ env.LDAP_ADMIN_USERNAME }} + LDAP_ADMIN_PASSWORD: ${{ env.LDAP_ADMIN_PASSWORD }} + LDAP_CONFIG_ADMIN_ENABLED: "yes" + LDAP_CONFIG_ADMIN_USERNAME: ${{ env.LDAP_CONFIG_ADMIN_USERNAME }} + LDAP_CONFIG_ADMIN_PASSWORD: ${{ env.LDAP_CONFIG_ADMIN_PASSWORD }} + strategy: fail-fast: false matrix: @@ -104,6 +130,11 @@ jobs: extensions: memcached, memcache ini-values: ${{ env.PHP_INI_VALUES }} + - name: Setup LDAP + run: | + sudo apt-get install -y libnss-ldap libpam-ldap ldap-utils + tests/resources/openldap/docker-entrypoint-initdb.d/init.sh + - name: "Run tests on PHP ${{ matrix.php-version }} (Experimental: ${{ matrix.experimental }})" run: phpunit -c tests/phpunit.xml continue-on-error: ${{ matrix.experimental }} \ No newline at end of file diff --git a/tests/TestConfiguration.env.php b/tests/TestConfiguration.env.php index 201aabac4a..96b282453e 100644 --- a/tests/TestConfiguration.env.php +++ b/tests/TestConfiguration.env.php @@ -400,21 +400,23 @@ * ALT_DN: CN=Alice Baker,OU=Sales,DC=foo,DC=net * ALT_PASSWORD: apass */ -defined('TESTS_ZEND_LDAP_HOST') || define('TESTS_ZEND_LDAP_HOST', getenv('TESTS_ZEND_LDAP_HOST') ?: 'localhost'); -//defined('TESTS_ZEND_LDAP_PORT') || define('TESTS_ZEND_LDAP_PORT', getenv('TESTS_ZEND_LDAP_PORT') ?: 389); -defined('TESTS_ZEND_LDAP_USE_START_TLS') || define('TESTS_ZEND_LDAP_USE_START_TLS', getenv('TESTS_ZEND_LDAP_USE_START_TLS') ?: true); -//defined('TESTS_ZEND_LDAP_USE_SSL') || define('TESTS_ZEND_LDAP_USE_SSL', getenv('TESTS_ZEND_LDAP_USE_SSL') ?: false); -defined('TESTS_ZEND_LDAP_USERNAME') || define('TESTS_ZEND_LDAP_USERNAME', getenv('TESTS_ZEND_LDAP_USERNAME') ?: 'CN=someUser,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', getenv('TESTS_ZEND_LDAP_PRINCIPAL_NAME') ?: 'someUser@example.com'); -defined('TESTS_ZEND_LDAP_PASSWORD') || define('TESTS_ZEND_LDAP_PASSWORD', getenv('TESTS_ZEND_LDAP_PASSWORD') ?: null); -defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') || define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', getenv('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') ?: true); -defined('TESTS_ZEND_LDAP_BASE_DN') || define('TESTS_ZEND_LDAP_BASE_DN', getenv('TESTS_ZEND_LDAP_BASE_DN') ?: 'OU=Sales,DC=example,DC=com'); -//defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') || define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', getenv('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') ?: '(&(objectClass=posixAccount)(uid=%s))'); +defined('TESTS_ZEND_LDAP_HOST') || define('TESTS_ZEND_LDAP_HOST', getenv('TESTS_GENERATE_REPORT') ?: 'localhost'); +defined('TESTS_ZEND_LDAP_PORT') || define('TESTS_ZEND_LDAP_PORT', getenv('TESTS_ZEND_LDAP_PORT') ?: 1389); +defined('TESTS_ZEND_LDAP_USE_START_TLS') || define('TESTS_ZEND_LDAP_USE_START_TLS', getenv('TESTS_ZEND_LDAP_USE_START_TLS') ?: false); +defined('TESTS_ZEND_LDAP_USE_SSL') || define('TESTS_ZEND_LDAP_USE_SSL', getenv('TESTS_ZEND_LDAP_USE_SSL') ?: false); +defined('TESTS_ZEND_LDAP_USERNAME') || define('TESTS_ZEND_LDAP_USERNAME', getenv('TESTS_ZEND_LDAP_USERNAME') ?: 'cn=admin,dc=example,dc=com'); +defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', getenv('TESTS_ZEND_LDAP_PRINCIPAL_NAME') ?: 'admin@example.com'); +defined('TESTS_ZEND_LDAP_PASSWORD') || define('TESTS_ZEND_LDAP_PASSWORD', getenv('TESTS_ZEND_LDAP_PASSWORD') ?: 'insecure'); +defined('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') || define('TESTS_ZEND_LDAP_BIND_REQUIRES_DN', getenv('TESTS_ZEND_LDAP_BIND_REQUIRES_DN') ?: 'true'); +defined('TESTS_ZEND_LDAP_BASE_DN') || define('TESTS_ZEND_LDAP_BASE_DN', getenv('TESTS_ZEND_LDAP_BASE_DN') ?: 'dc=example,dc=com'); +defined('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') || define('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT', getenv('TESTS_ZEND_LDAP_ACCOUNT_FILTER_FORMAT') ?: '(&(objectClass=account)(uid=%s))'); defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME', getenv('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME') ?: 'example.com'); defined('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT') || define('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT', getenv('TESTS_ZEND_LDAP_ACCOUNT_DOMAIN_NAME_SHORT') ?: 'EXAMPLE'); -defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', getenv('TESTS_ZEND_LDAP_ALT_USERNAME') ?: 'anotherUser'); -defined('TESTS_ZEND_LDAP_ALT_DN') || define('TESTS_ZEND_LDAP_ALT_DN', getenv('TESTS_ZEND_LDAP_ALT_DN') ?: 'CN=Another User,OU=Sales,DC=example,DC=com'); -defined('TESTS_ZEND_LDAP_ALT_PASSWORD') || define('TESTS_ZEND_LDAP_ALT_PASSWORD', getenv('TESTS_ZEND_LDAP_ALT_PASSWORD') ?: null); +defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', getenv('TESTS_ZEND_LDAP_ALT_USERNAME') ?: 'user1'); +defined('TESTS_ZEND_LDAP_ALT_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_ALT_PRINCIPAL_NAME', getenv('TESTS_ZEND_LDAP_ALT_PRINCIPAL_NAME') ?: 'user1@example.com'); +defined('TESTS_ZEND_LDAP_ALT_DN') || define('TESTS_ZEND_LDAP_ALT_DN', getenv('TESTS_ZEND_LDAP_ALT_DN') ?: 'uid=user1,dc=example,dc=com'); +defined('TESTS_ZEND_LDAP_ALT_PASSWORD') || define('TESTS_ZEND_LDAP_ALT_PASSWORD', getenv('TESTS_ZEND_LDAP_ALT_PASSWORD') ?: 'user1'); +defined('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE') || define('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE', getenv('TESTS_ZEND_LDAP_WRITEABLE_SUBTREE') ?: 'ou=test,dc=example,dc=com'); /** * Zend_Locale tests From 93adc40bfb772c0a4ce7cacbb5729013b0e7eaf2 Mon Sep 17 00:00:00 2001 From: hungtd Date: Thu, 2 Mar 2023 15:40:21 +0700 Subject: [PATCH 2/2] Move php lint source into step of workflow PHPUnit Reduce ci runtime by reduce number container Ref source: https://github.com/zf1s/zf1/blob/4f4cb797f2abe409d7e84f1ed8229480b2bc8d7e/.github/workflows/tests.yml --- .github/workflows/lint.yml | 59 ----------------------------------- .github/workflows/phpunit.yml | 17 +++++++--- 2 files changed, 13 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 95ff004e9a..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: run PHP lint with supported PHP versions - -on: [push, pull_request] - -jobs: - php-lint-php71: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 7.1 - uses: prestashop/github-action-php-lint/7.1@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" - php-lint-php72: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 7.2 - uses: prestashop/github-action-php-lint/7.2@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" - php-lint-php73: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 7.3 - uses: prestashop/github-action-php-lint/7.3@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" - php-lint-php74: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 7.4 - uses: prestashop/github-action-php-lint/7.4@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" - php-lint-php80: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 8.0 - uses: prestashop/github-action-php-lint/8.0@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" - php-lint-php81: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: PHP syntax checker 8.1 - uses: prestashop/github-action-php-lint/8.1@v1.1 - with: - folder-to-exclude: "! -path \"./tests/Zend/Loader/_files/*\"" \ No newline at end of file diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 5adf5dda5c..ce8b2395ec 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -120,15 +120,24 @@ jobs: - name: Provider config base on env for intergrate test run: cp tests/TestConfiguration.env.php tests/TestConfiguration.php - - + - name: Install PHP with extensions uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - tools: phpunit:9 + tools: cs2pr extensions: memcached, memcache ini-values: ${{ env.PHP_INI_VALUES }} + env: + # https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741 + fail-fast: true + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Lint PHP source files + run: | + bin/parallel-lint --exclude vendor --exclude tests/Zend/Loader/_files/ParseError.php . --checkstyle | cs2pr - name: Setup LDAP run: | @@ -136,5 +145,5 @@ jobs: tests/resources/openldap/docker-entrypoint-initdb.d/init.sh - name: "Run tests on PHP ${{ matrix.php-version }} (Experimental: ${{ matrix.experimental }})" - run: phpunit -c tests/phpunit.xml + run: bin/phpunit -c tests/phpunit.xml continue-on-error: ${{ matrix.experimental }} \ No newline at end of file