Add tests #33
Workflow file for this run
This file contains 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: Linux | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- 'feature/*' | |
- 'hotfix/*' | |
- 'release/*' | |
pull_request: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-versions: [ '8.1', '8.3' ] | |
coverage: [none] | |
fail-fast: false | |
name: PHP ${{ matrix.php-versions }} on ubuntu-latest | |
steps: | |
- name: PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer | |
coverage: ${{ matrix.coverage }} | |
- name: Checkout Galette core | |
uses: actions/checkout@v4 | |
with: | |
repository: galette/galette | |
path: galette-core | |
fetch-depth: 1 | |
ref: develop | |
- name: Checkout plugin | |
uses: actions/checkout@v4 | |
with: | |
path: galette-core/galette/plugins/plugin-oauth2 | |
- 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: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install dependencies | |
run: | | |
cd galette-core/galette | |
composer install --ignore-platform-reqs | |
cd plugins/plugin-oauth2 | |
composer install --ignore-platform-reqs | |
- name: CS | |
run: | | |
cd galette-core/galette/plugins/plugin-oauth2 | |
../../vendor/bin/phpcs lib/ | |
- name: Check missing symbols | |
run: | | |
cd galette-core/galette/plugins/plugin-oauth2 | |
composer require maglnet/composer-require-checker -W | |
vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json ../../composer.json | |
if: matrix.php-versions == '8.3' | |
- name: PHPStan checks | |
run: | | |
cd galette-core/galette/plugins/plugin-oauth2 | |
../../vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress | |
if: matrix.php-versions == '8.1' | |
- name: Headers checks | |
run: | | |
cd galette-core/galette/plugins/plugin-oauth2 | |
../../vendor/bin/docheader check lib ./*.php | |
unit-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
#lower php version | |
- { php-version: "8.1", db-image: "postgres:16", coverage: none, always: false } | |
#higher stable php version | |
- { php-version: "8.3", db-image: "postgres:16", coverage: none, always: true } | |
fail-fast: false | |
env: | |
DB: ${{ matrix.db-image }} | |
services: | |
# Label used to access the service container | |
db: | |
# Docker Hub image | |
image: ${{ matrix.db-image }} | |
# Provide env variables for both mysql and pgsql | |
env: | |
POSTGRES_USER: galette_tests | |
POSTGRES_PASSWORD: g@l3tte | |
POSTGRES_DB: galette_tests | |
# Open network ports for pgsql | |
ports: | |
- 5432:5432 | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd="bash -c 'pg_isready'" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=10 | |
name: PHP ${{ matrix.php-version }} ${{ matrix.db-image }} | |
steps: | |
- name: PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer, pecl | |
extensions: apcu | |
ini-values: apc.enable_cli=1 | |
- name: "Show versions" | |
if: env.skip != 'true' | |
run: | | |
php --version | |
composer --version | |
echo "node $(node --version)" | |
echo "npm $(npm --version)" | |
docker exec ${{ job.services.db.id }} bash -c "psql --version" | |
- name: Checkout Galette core | |
uses: actions/checkout@v4 | |
with: | |
repository: galette/galette | |
path: galette-core | |
fetch-depth: 1 | |
ref: develop | |
- name: Checkout plugin | |
uses: actions/checkout@v4 | |
with: | |
path: galette-core/galette/plugins/plugin-oauth2 | |
- name: "Restore dependencies cache" | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.composer/cache/ | |
~/.npm/_cacache/ | |
key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}" | |
restore-keys: | | |
${{ runner.os }}-galette-${{ matrix.php-version }}- | |
- name: Install dependencies | |
run: | | |
cd galette-core | |
bin/install_deps | |
cd galette/plugins/plugin-oauth2 | |
composer install --ignore-platform-reqs | |
- name: Init for PostgreSQL | |
env: | |
POSTGRES_HOST: localhost | |
POSTGRES_PORT: 5432 | |
run: | | |
PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette-core/galette/install/scripts/pgsql.sql -U galette_tests -h localhost | |
- name: Unit tests | |
run: | | |
cd galette-core/galette/plugins/plugin-oauth2 | |
../../vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteOAuth2/ |