feat: add SSO service and JWT/SAML tests (#1) #22
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: Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['8.1', '8.2'] | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_DATABASE: wordpress_test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP ${{ matrix.php }} | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: mysqli, mbstring, intl | |
| coverage: none | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --no-progress --prefer-dist | |
| - name: Install WordPress test suite | |
| run: | | |
| WP_TESTS_DIR=/tmp/wordpress-tests-lib | |
| WP_CORE_DIR=/tmp/wordpress | |
| # Download WordPress | |
| mkdir -p "$WP_CORE_DIR" | |
| curl -sL https://wordpress.org/latest.tar.gz | tar xz --strip-components=1 -C "$WP_CORE_DIR" | |
| # Download WordPress test suite | |
| mkdir -p "$WP_TESTS_DIR" | |
| WP_VERSION=$(php -r "require '$WP_CORE_DIR/wp-includes/version.php'; echo \$wp_version;") | |
| WP_BRANCH="${WP_VERSION%.*}" | |
| curl -sL "https://github.com/WordPress/wordpress-develop/archive/refs/heads/${WP_BRANCH}.tar.gz" | tar xz --strip-components=1 -C "$WP_TESTS_DIR" "wordpress-develop-${WP_BRANCH}/tests/phpunit/includes" "wordpress-develop-${WP_BRANCH}/tests/phpunit/data" | |
| # Move extracted contents to expected layout | |
| mv "$WP_TESTS_DIR/tests/phpunit/includes" "$WP_TESTS_DIR/includes" | |
| mv "$WP_TESTS_DIR/tests/phpunit/data" "$WP_TESTS_DIR/data" | |
| rm -rf "$WP_TESTS_DIR/tests" | |
| # Create wp-tests-config.php | |
| cat > "$WP_TESTS_DIR/wp-tests-config.php" <<'WPCONFIG' | |
| <?php | |
| define( 'ABSPATH', '/tmp/wordpress/' ); | |
| define( 'DB_NAME', 'wordpress_test' ); | |
| define( 'DB_USER', 'root' ); | |
| define( 'DB_PASSWORD', 'root' ); | |
| define( 'DB_HOST', '127.0.0.1' ); | |
| define( 'DB_CHARSET', 'utf8' ); | |
| define( 'DB_COLLATE', '' ); | |
| $table_prefix = 'wptests_'; | |
| define( 'WP_TESTS_DOMAIN', 'example.org' ); | |
| define( 'WP_TESTS_EMAIL', 'admin@example.org' ); | |
| define( 'WP_TESTS_TITLE', 'Test Blog' ); | |
| define( 'WP_PHP_BINARY', 'php' ); | |
| define( 'WPLANG', '' ); | |
| WPCONFIG | |
| # Verify installation | |
| if [ ! -f "$WP_TESTS_DIR/includes/functions.php" ]; then | |
| echo "ERROR: WordPress test suite installation failed" | |
| ls -la "$WP_TESTS_DIR/" || true | |
| exit 1 | |
| fi | |
| echo "WordPress test suite installed successfully" | |
| - name: Run PHPUnit | |
| run: vendor/bin/phpunit |