Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Aug 22, 2024
0 parents commit 1b2cc5c
Show file tree
Hide file tree
Showing 28 changed files with 4,579 additions and 0 deletions.
117 changes: 117 additions & 0 deletions .composer-require-checker.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"php-core-extensions": [
"core", "standard",

"ctype", "date", "fileinfo", "filter", "iconv", "json", "pcre", "reflection", "session", "simplexml", "spl", "xml",

"curl", "gd", "intl", "mbstring", "mysqli", "zlib", "pdo", "pgsql", "gettext",

"exif", "pcntl"
],
"symbol-whitelist": [
"// PHP symbols",
"null",
"false", "true",
"static", "self", "parent",
"array", "bool", "callable", "float", "int", "iterable", "object", "string", "void",

"// random native PHP functions",
"// these are moved in random native extension in PHP 8.2, but this extension does not exists in previous PHP versions",
"mt_rand",
"rand",
"random_int",

"// Galette constants (not detected as they are dynamically declared)",
"GALETTE_ATTACHMENTS_PATH",
"GALETTE_BASE_PATH",
"GALETTE_CACHE_DIR",
"GALETTE_CARD_COLS",
"GALETTE_CARD_HEIGHT",
"GALETTE_CARD_ROWS",
"GALETTE_CARD_WIDTH",
"GALETTE_COMPAT_VERSION",
"GALETTE_CONFIG_PATH",
"GALETTE_SYSCONFIG_PATH",
"GALETTE_DATA_PATH",
"GALETTE_DB_VERSION",
"GALETTE_DOCUMENTS_PATH",
"GALETTE_DOWNLOADS_URI",
"GALETTE_EXPORTS_PATH",
"GALETTE_FILES_PATH",
"GALETTE_HOSTED",
"GALETTE_IMPORTS_PATH",
"GALETTE_LOGS_PATH",
"GALETTE_MODE",
"GALETTE_DEBUG",
"GALETTE_NIGHTLY",
"GALETTE_PHOTOS_PATH",
"GALETTE_PLUGINS_PATH",
"GALETTE_ROOT",
"GALETTE_TELEMETRY_URI",
"GALETTE_TEMPIMAGES_PATH",
"GALETTE_THEME",
"GALETTE_THEMES_PATH",
"GALETTE_VERSION",
"GALETTE_X_FORWARDED_FOR_INDEX",
"_CURRENT_THEME_PATH",
"GALETTE_URI",
"GALETTE_MYSQL_MIN",
"GALETTE_MARIADB_MIN",
"GALETTE_PGSQL_MIN",
"GALETTE_TESTS",
"GALETTE_DISPLAY_VERSION",
"GALETTE_PHP_MIN",

"// Galette db constants (not detected as they are dynamically declared)",
"HOST_DB",
"NAME_DB",
"PORT_DB",
"PREFIX_DB",
"PWD_DB",
"TYPE_DB",
"USER_DB",

"//XHProf constants",

"//know but not detected Galette function,",
"remove_remarks",
"isValidWebUrl",
"remove_remarks",
"split_sql_file",
"_T",
"__",
"_Tn",
"_Tx",
"_Tnx",

"// XHProf PECL extension",
"XHProfRuns_Default",
"xhprof_disable",
"xhprof_enable",
"GALETTE_XHPROF_PATH",
"XHPROF_PATH",
"XHPROF_URL",
"XHPROF_FLAGS_CPU",
"XHPROF_FLAGS_MEMORY",
"XHPROF_FLAGS_NO_BUILTINS",
"XHPROF_HOST",

"// DI functions",
"DI\\autowire",
"DI\\Container",
"DI\\ContainerBuilder",
"DI\\Bridge\\Slim\\App",
"DI\\Attribute\\Inject",

"// Not detected, do not know why.",
"Psr\\Http\\Server\\RequestHandlerInterface",
"Install"
],
"scan-files": [
"*.php",
"lib/**/.php",
"scripts/*.php",
"scripts/**/*.php",
"webroot/*.php"
]
}
232 changes: 232 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
name: Linux

on:
push:
branches:
- master
- develop
- 'feature/*'
- 'hotfix/*'
- 'release/*'
tags:
- '*'
pull_request:
# Enable manual run
workflow_dispatch:

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
name: "Lint on PHP ${{ matrix.php-versions }}"

strategy:
matrix:
php-versions: [ '8.1', '8.3' ]
coverage: [none]
fail-fast: false

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-activities

- 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
- name: CS
run: |
cd galette-core/galette/plugins/plugin-activities
../../vendor/bin/phpcs lib/ ./*.php
- name: Twig CS
run: |
cd galette-core/galette/plugins/plugin-activities
../../vendor/bin/twigcs templates/default --severity error --display blocking
- name: Check missing symbols
run: |
cd galette-core/galette/plugins/plugin-activities
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-activities
../../vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
- name: Headers checks
run: |
cd galette-core/galette/plugins/plugin-activities
../../vendor/bin/docheader --docheader=../../../.docheader check lib ./*.php
- name: Install Node
uses: actions/setup-node@v4

- name: Build JS
run: |
cd galette-core/galette/plugins/plugin-activities
npm install
npm run-script build
unit-tests:
runs-on: ubuntu-latest

strategy:
matrix:
include:
#always tests higher stable php version with lower db version
#enable coverage on higher stable php version with higher postrgesql version
#lower php version
- { php-version: "8.1", db-image: "mysql:5.7", coverage: none, always: false }
- { php-version: "8.1", db-image: "mysql:8.1", coverage: none, always: false }
- { php-version: "8.1", db-image: "mariadb:10.4", coverage: none, always: false }
- { php-version: "8.1", db-image: "mariadb:11", coverage: none, always: false }
- { php-version: "8.1", db-image: "postgres:11", coverage: none, always: false }
- { php-version: "8.1", db-image: "postgres:16", coverage: none, always: false }
#higher stable php version
- { php-version: "8.3", db-image: "mysql:5.7", coverage: none, always: true }
- { php-version: "8.3", db-image: "mysql:8.1", coverage: none, always: false }
- { php-version: "8.3", db-image: "mariadb:10.4", coverage: none, always: true }
- { php-version: "8.3", db-image: "mariadb:11", coverage: none, always: false }
- { php-version: "8.3", db-image: "postgres:11", coverage: none, always: true }
- { php-version: "8.3", db-image: "postgres:16", coverage: none, always: true }
fail-fast: false

env:
skip: ${{ matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette-activities' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags'))) }}
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
MYSQL_USER: galette_tests
MYSQL_PASSWORD: g@l3tte
MYSQL_ROOT_PASSWORD: g@l3tte
MYSQL_DATABASE: galette_tests
# Open network ports for both mysql and pgsql
ports:
- 3306:3306
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi fi'"
--health-interval=10s
--health-timeout=5s
--health-retries=10
name: PHP ${{ matrix.php-version }} ${{ matrix.db-image }} ${{ (matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')))) && ' (skipped)' || matrix.coverage == 'xdebug' && ' (with coverage)' || ''}}

steps:
- name: PHP
if: env.skip != 'true'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl
coverage: ${{ matrix.coverage }}
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 "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi"
- name: Checkout Galette core
if: env.skip != 'true'
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-activities

- name: "Restore dependencies cache"
if: env.skip != 'true'
uses: actions/cache@v4
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
if: env.skip != 'true'
run: |
cd galette-core
bin/install_deps
- 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
PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette-core/galette/plugins/plugin-activities/scripts/pgsql.sql -U galette_tests -h localhost
if: env.skip != 'true' && startsWith(matrix.db-image, 'postgres')

- name: Init for MariaDB
run: |
mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
mysql -e 'use galette_tests; source galette-core/galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
mysql -e 'use galette_tests; source galette-core/galette/plugins/plugin-activities/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb'))

- name: Unit tests
if: env.skip != 'true'
run: |
cd galette-core/galette/plugins/plugin-activities
../../vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteActivities/
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.exvim*
dist/
tempcache/
tests/coverage/
_disabled
Loading

0 comments on commit 1b2cc5c

Please sign in to comment.