Merge pull request #695 from joomla-extensions/dependabot/npm_and_yar… #104
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: CI Weblinks | |
| on: | |
| push: | |
| branches: [ main, 5.x-dev ] | |
| pull_request: | |
| branches: [ main, 5.x-dev ] | |
| jobs: | |
| composer: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: joomlaprojects/docker-images:php8.3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-dependencies | |
| phpcs: | |
| runs-on: ubuntu-latest | |
| needs: composer | |
| container: | |
| image: joomlaprojects/docker-images:php8.3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-dependencies | |
| - name: Run PHP CS Fixer and PHPCS | |
| run: | | |
| ./vendor/bin/php-cs-fixer fix -vvv --dry-run --diff | |
| ./vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml src/ | |
| npm: | |
| runs-on: ubuntu-latest | |
| needs: phpcs | |
| container: | |
| image: joomlaprojects/docker-images:php8.3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-dependencies | |
| with: | |
| npm-cache: 'true' | |
| prepare_tests: | |
| runs-on: ubuntu-latest | |
| needs: npm | |
| strategy: | |
| matrix: | |
| joomla-version: ['5.4', '6.0', '6.1'] | |
| container: | |
| image: joomlaprojects/docker-images:cypress8.3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/setup-dependencies | |
| with: | |
| npm-cache: 'true' | |
| - uses: ./.github/actions/setup-cypress | |
| - name: Determine Nightly URL for Joomla ${{ matrix.joomla-version }} | |
| id: joomla-info | |
| run: | | |
| URL=$(curl -s "https://api.github.com/repos/joomla/joomla-cms/releases" | \ | |
| grep -oP '"browser_download_url":\s*"[^"]*'"${{ matrix.joomla-version }}"'[^"]*Full_Package\.zip"' | \ | |
| sed 's/"browser_download_url":\s*"//;s/"$//' | \ | |
| head -1) | |
| if [ -z "$URL" ]; then | |
| echo "::error::Could not find URL for version ${{ matrix.joomla-version }} in joomla/joomla-cms releases." | |
| exit 1 | |
| fi | |
| echo "📦 Joomla ${{ matrix.joomla-version }} URL: $URL" | |
| echo "url=$URL" >> $GITHUB_OUTPUT | |
| echo "url_hash=$(echo -n "$URL" | md5sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT | |
| - name: Cache Joomla Zip | |
| id: cache-joomla | |
| uses: actions/cache@v4 | |
| with: | |
| path: joomla.zip | |
| key: joomla-core-${{ matrix.joomla-version }}-${{ steps.joomla-info.outputs.url_hash }} | |
| - name: Download Joomla ${{ matrix.joomla-version }} | |
| if: steps.cache-joomla.outputs.cache-hit != 'true' | |
| run: | | |
| echo "⬇️ Downloading from: ${{ steps.joomla-info.outputs.url }}" | |
| curl -LfsS "${{ steps.joomla-info.outputs.url }}" -o joomla.zip | |
| - name: Build and Verify | |
| run: | | |
| echo "📦 Downloaded Joomla ${{ matrix.joomla-version }} from: ${{ steps.joomla-info.outputs.url }}" | |
| vendor/bin/robo build | |
| if ! unzip -t joomla.zip > /dev/null; then | |
| unzip -t joomla.zip > /dev/null | |
| echo "ERROR: joomla.zip is invalid or not found." | |
| exit 1 | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts-j${{ matrix.joomla-version }} | |
| path: | | |
| dist/ | |
| joomla.zip | |
| retention-days: 1 | |
| phpstan: | |
| runs-on: ubuntu-latest | |
| needs: prepare_tests | |
| strategy: | |
| matrix: | |
| joomla-version: ['5.4', '6.0', '6.1'] | |
| container: | |
| image: joomlaprojects/docker-images:php8.3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts-j${{ matrix.joomla-version }} | |
| - uses: ./.github/actions/setup-dependencies | |
| - name: Run PHPStan | |
| continue-on-error: true | |
| run: | | |
| unzip -q joomla.zip -d joomla | |
| ./vendor/bin/phpstan analyse src --level=5 --no-progress --no-interaction | |
| system-tests: | |
| runs-on: ubuntu-latest | |
| needs: [prepare_tests, phpstan] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| joomla-version: ['5.4', '6.0', '6.1'] | |
| php-version: ['8.2', '8.3', '8.4'] | |
| db: [mysql, mariadb, pgsql] | |
| include: | |
| - db: mysql | |
| db-type: mysqli | |
| db-host: mysql | |
| image: mysql:8.0 | |
| db-prefix: mysql_ | |
| alter-user-cmd: | | |
| apt-get update && apt-get install -y default-mysql-client | |
| mysql -h mysql -u root -proot --skip-ssl -e "ALTER USER 'joomla_ut'@'%' IDENTIFIED WITH mysql_native_password BY 'joomla_ut'; FLUSH PRIVILEGES;" | |
| - db: mariadb | |
| db-type: mysqli | |
| db-host: mariadb | |
| db-prefix: mariadb_ | |
| image: mariadb:10.4 | |
| alter-user-cmd: "apt-get update && apt-get install -y mariadb-client" | |
| - db: pgsql | |
| db-type: pgsql | |
| db-host: postgres | |
| db-prefix: pgsql_ | |
| image: postgres:12-alpine | |
| alter-user-cmd: "apt-get update && apt-get install -y postgresql-client" | |
| - joomla-version: '6.0' | |
| db: mariadb | |
| image: mariadb:10.6 | |
| - joomla-version: '6.1' | |
| db: mariadb | |
| image: mariadb:10.6 | |
| exclude: | |
| - joomla-version: '5.4' | |
| php-version: '8.4' | |
| - joomla-version: '6.0' | |
| php-version: '8.2' | |
| - joomla-version: '6.1' | |
| php-version: '8.2' | |
| container: | |
| image: joomlaprojects/docker-images:cypress${{ matrix.php-version }} | |
| services: | |
| mysql: | |
| image: ${{ matrix.db == 'mysql' && matrix.image || 'mysql:8.0' }} | |
| env: | |
| MYSQL_ROOT_PASSWORD: ${{ matrix.db == 'mysql' && 'root' || 'unused' }} | |
| MYSQL_USER: ${{ matrix.db == 'mysql' && 'joomla_ut' || 'unused' }} | |
| MYSQL_PASSWORD: ${{ matrix.db == 'mysql' && 'joomla_ut' || 'unused' }} | |
| MYSQL_DATABASE: ${{ matrix.db == 'mysql' && 'test_joomla' || 'unused' }} | |
| mariadb: | |
| image: ${{ matrix.db == 'mariadb' && matrix.image || 'mariadb:10.4' }} | |
| env: | |
| MARIADB_ROOT_PASSWORD: ${{ matrix.db == 'mariadb' && 'root' || 'unused' }} | |
| MARIADB_USER: ${{ matrix.db == 'mariadb' && 'joomla_ut' || 'unused' }} | |
| MARIADB_PASSWORD: ${{ matrix.db == 'mariadb' && 'joomla_ut' || 'unused' }} | |
| MARIADB_DATABASE: ${{ matrix.db == 'mariadb' && 'test_joomla' || 'unused' }} | |
| postgres: | |
| image: ${{ matrix.db == 'pgsql' && 'postgres:12-alpine' || 'postgres:12-alpine' }} | |
| env: | |
| POSTGRES_USER: ${{ matrix.db == 'pgsql' && 'root' || 'unused' }} | |
| POSTGRES_PASSWORD: ${{ matrix.db == 'pgsql' && 'root' || 'unused' }} | |
| POSTGRES_DB: ${{ matrix.db == 'pgsql' && 'test_joomla' || 'unused' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts-j${{ matrix.joomla-version }} | |
| - uses: ./.github/actions/setup-dependencies | |
| with: | |
| npm-cache: 'true' | |
| - name: Extract Joomla | |
| run: unzip -q joomla.zip -d joomla | |
| - uses: ./.github/actions/setup-cypress | |
| - name: Setup and run ${{ matrix.db }} | |
| run: | | |
| ${{ matrix.alter-user-cmd }} | |
| DB_USER=${{ matrix.db == 'pgsql' && 'root' || 'joomla_ut' }} | |
| DB_PASS=${{ matrix.db == 'pgsql' && 'root' || 'joomla_ut' }} | |
| cp -r joomla /tests/www/${{ matrix.db }} | |
| cp dist/pkg-weblinks-current.zip /tests/www/${{ matrix.db }}/ | |
| cd /tests/www/${{ matrix.db }}/ | |
| apache2ctl -D FOREGROUND & | |
| php installation/joomla.php install --verbose --site-name="Joomla test" --admin-email=admin@example.org --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=${{ matrix.db-type }} --db-host=${{ matrix.db-host }} --db-name=test_joomla --db-pass=$DB_PASS --db-user=$DB_USER --db-encryption=0 --db-prefix=${{ matrix.db-prefix }} | |
| php cli/joomla.php extension:install --path=/tests/www/${{ matrix.db }}/pkg-weblinks-current.zip | |
| mkdir -p tmp/api_rate_limit tmp/plg_system_ratelimit | |
| chown -R www-data:www-data /tests/www/${{ matrix.db }}/ | |
| chmod -R 777 /tests/www/${{ matrix.db }}/ | |
| echo "=== Test Environment ===" | |
| php cli/joomla.php --version | head -1 | |
| php -v | head -1 | |
| [ "${{ matrix.db }}" = "pgsql" ] && psql -h ${{ matrix.db-host }} -U $DB_USER -d test_joomla -t -c 'SELECT version();' | head -1 | xargs || mysql -h ${{ matrix.db-host }} -u $DB_USER -p$DB_PASS --skip-ssl -e 'SELECT VERSION();' -s -N | |
| echo "========================" | |
| cd $GITHUB_WORKSPACE | |
| npx cypress run --browser=chrome --e2e --config video=false --env cmsPath=/tests/www/${{ matrix.db }},db_type=${{ matrix.db-type }},db_host=${{ matrix.db-host }},db_name=test_joomla,db_user=$DB_USER,db_password=$DB_PASS,db_prefix=${{ matrix.db-prefix }},logFile=/var/log/apache2/error.log --config baseUrl=http://localhost/${{ matrix.db }} | |
| - name: Upload Screenshots on Failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: screenshots-j${{ matrix.joomla-version }}-${{ matrix.db }}-php${{ matrix.php-version }} | |
| path: tests/cypress/output/screenshot | |
| retention-days: 7 |