Skip to content

Merge pull request #69 from tito10047/update-dependencies #259

Merge pull request #69 from tito10047/update-dependencies

Merge pull request #69 from tito10047/update-dependencies #259

Workflow file for this run

name: CI
on:
push:
branches: [ "develop", "main" ]
pull_request: ~
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
php-cs-fixer:
name: "Coding Standard"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: php-cs-fixer
- name: Check CS
run: php-cs-fixer fix --dry-run --diff
continue-on-error: true
phpstan:
name: "Static Analysis"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.3"
ini-values: memory_limit=-1
- name: "Install dependencies"
run: composer update --no-interaction --no-progress
- name: "Run PHPStan"
run: vendor/bin/phpstan analyse -c phpstan.neon src
continue-on-error: true
tests:
name: "Tests (PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony }}, ${{ matrix.dependencies }})"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
symfony:
- '6.4.*'
- '7.4.*'
- '8.0.*'
dependencies:
- "lowest"
- "highest"
operating-system:
- "ubuntu-latest"
exclude:
- php-version: "8.2"
symfony: '8.0.*'
- php-version: "8.3"
symfony: '8.0.*'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
- name: "Install chromium"
uses: "nanasess/setup-chromedriver@v2"
- name: "Configure Symfony"
run: 'composer config extra.symfony.require "${{ matrix.symfony }}"'
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Cache dependencies"
uses: "actions/cache@v4"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-symfony-${{ matrix.symfony }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}"
restore-keys: "php-${{ matrix.php-version }}-symfony-${{ matrix.symfony }}-${{ matrix.dependencies }}-"
- name: "Install dependencies"
run: |
if [ "${{ matrix.dependencies }}" == "lowest" ]; then
composer update --no-interaction --no-progress --prefer-lowest
else
composer update --no-interaction --no-progress
fi
- name: "Detect drivers"
run: "vendor/bin/bdi detect drivers"
- name: "Asset Mapper Install"
run: "./tests/App/AssetMapper/bin/console importmap:install"
- name: "Asset Mapper compile"
run: "./tests/App/AssetMapper/bin/console asset-map:compile"
- name: "yarn install"
run: "yarn --cwd tests/App/Webpack/ install"
- name: "yarn build"
run: "yarn --cwd tests/App/Webpack/ build"
- name: "Execute tests"
run: "composer test"
e2e-tests:
name: "E2E Test"
runs-on: ubuntu-latest
steps:
- name: Checkout bundle code
uses: actions/checkout@v4
with:
path: my-bundle
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, ctype, iconv
tools: composer
- name: Create Dummy Symfony Project
run: |
composer create-project symfony/skeleton dummy-project
- 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 }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Dependencies
run: |
cd dummy-project
composer config extra.symfony.allow-contrib true
composer config minimum-stability dev
composer config prefer-stable true
# Explicitly set the repository with path and version as requested
composer config repositories.local '{"type": "path", "url": "../my-bundle", "options": {"symlink": true, "versions": {"tito10047/altcha-bundle": "2.0.0"}}}'
composer require tito10047/altcha-bundle:"2.0.0" --no-scripts
- name: Copy E2E Test Files
run: |
cp -R my-bundle/tests_e2e/basic/* dummy-project/
- name: Run PHP Built-in Server
run: |
cd dummy-project
php -S 127.0.0.1:8000 -t public &
sleep 5
- name: Test URL
run: |
curl -s http://127.0.0.1:8000/test-bundle > response.html
RESPONSE=$(cat response.html)
if [[ "$RESPONSE" == *"altcha-widget"* ]]; then
echo "Altcha widget found in response."
else
echo "Altcha widget NOT found in response!"
exit 1
fi
if [[ "$RESPONSE" == *"altcha.min.js"* || "$RESPONSE" == *"tito10047--altcha-bundle--altcha"* ]]; then
echo "Altcha assets/controller found."
else
echo "Altcha assets/controller NOT found!"
exit 1
fi
- name: Upload HTML Response on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-response-html
path: response.html