Add test that covers the new mutants (#26) #73
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: Integration Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| integration-tests: | |
| name: Integration Tests with PHP ${{ matrix.php-versions }} | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 127.0.0.1:6379:6379 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@db91e1a0e48e84637d325a7ee4d2677e146ceec4 # v2.36.0 | |
| with: | |
| php-version: '8.4' | |
| extensions: mbstring, intl, pdo_sqlite, sodium | |
| coverage: none | |
| - name: Install dependencies | |
| run: composer install --no-progress --prefer-dist | |
| - name: Clone mini-fedi-server | |
| run: git clone https://github.com/soatok/mini-fedi-server.git | |
| - name: Clone pkd-server-php | |
| run: git clone https://github.com/fedi-e2ee/pkd-server-php.git | |
| - name: Initialize mini-fedi-server | |
| run: | | |
| cd mini-fedi-server | |
| composer install --no-progress --prefer-dist | |
| sqlite3 config/database.sqlite < sql/sqlite/mini-fedi.sql | |
| # Use localhost for hostname to satisfy domain validation in Params.php | |
| echo '{"debug":true,"domain":"localhost","hostname":"localhost"}' > config/vars.json | |
| mkdir -p config/local | |
| # Use local config to fix database path (relative to the config/local dir) | |
| cat > config/local/database.php << 'EOF' | |
| <?php | |
| use ParagonIE\EasyDB\EasyDBCache; | |
| use PDO; | |
| return new EasyDBCache(new PDO('sqlite:' . __DIR__ . '/../database.sqlite')); | |
| EOF | |
| - name: Initialize pkd-server-php database | |
| run: | | |
| cd pkd-server-php | |
| composer install --no-progress --prefer-dist | |
| mkdir -p config/local | |
| # Configure local database | |
| cat > config/local/database.php << 'EOF' | |
| <?php | |
| use ParagonIE\EasyDB\EasyDBCache; | |
| use PDO; | |
| return new EasyDBCache(new PDO('sqlite:' . __DIR__ . '/../integration-test.db')); | |
| EOF | |
| # Configure local params with localhost | |
| cat > config/local/params.php << 'EOF' | |
| <?php | |
| use FediE2EE\PKDServer\Meta\Params; | |
| return new Params( | |
| hashAlgo: 'sha256', | |
| otpMaxLife: 120, | |
| actorUsername: 'pubkeydir', | |
| hostname: 'localhost', | |
| cacheKey: sodium_bin2hex(random_bytes(32)), | |
| httpCacheTtl: 15, | |
| ); | |
| EOF | |
| # Patch server bugs for persistent PHP processes (php -S) | |
| sed -i 's/require_once/require/g' autoload.php | |
| find config -name "*.php" -exec sed -i 's/require_once/require/g' {} + | |
| # Initialize database | |
| php cmd/init-database.php | |
| - name: Start mini-fedi-server | |
| run: | | |
| cd mini-fedi-server | |
| php -S localhost:65233 -t public public/index.php > /tmp/mini-fedi.log 2>&1 & | |
| - name: Start pkd-server-php | |
| run: | | |
| cd pkd-server-php | |
| php -S localhost:65234 -t public public/index.php > /tmp/pkd-server.log 2>&1 & | |
| - name: Wait for servers to be ready | |
| run: | | |
| echo "Waiting for mini-fedi-server..." | |
| for i in {1..20}; do | |
| curl -s http://localhost:65233 > /dev/null && break | |
| sleep 1 | |
| done | |
| echo "Waiting for pkd-server-php..." | |
| for i in {1..20}; do | |
| curl -s http://localhost:65234 > /dev/null && break | |
| sleep 1 | |
| done | |
| - name: Run Integration Tests | |
| env: | |
| PKD_SERVER_URL: http://localhost:65234 | |
| run: ./vendor/bin/phpunit tests/integration | |
| - name: Cat mini-fedi-server logs on failure | |
| if: failure() | |
| run: cat /tmp/mini-fedi.log | |
| - name: Cat pkd-server-php logs on failure | |
| if: failure() | |
| run: cat /tmp/pkd-server.log |