Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 131 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,142 @@

# This file is part of Phalcon.
#
# (c) Phalcon Team <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.

name: REST API v6 CI
on:
push:
paths-ignore:
- '**.md'
- '**.txt'
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

env:
fail-fast: true

# PHP extensions required by Composer
EXTENSIONS: json, mbstring, pdo, pdo_mysql

permissions: { }
jobs:
sonarqube:
name: SonarQube
runs-on: ubuntu-latest

# PHP CodeSniffer inspection
phpcs:
name: "Quality gate"
if: "!contains(github.event.head_commit.message, 'ci skip')"

permissions:
contents: read

runs-on: ubuntu-22.04

strategy:
fail-fast: true
matrix:
php:
- '8.2'
- '8.3'
- '8.4'
steps:
- uses: actions/checkout@v4

- name: "Setup PHP"
uses: shivammathur/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarQube Scan
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
tools: pecl
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--prefer-dist"

- name: "PHPCS"
run: |
composer cs

# - name: "PHPStan"
# run: |
# composer analyze

unit-tests:
needs: phpcs

permissions:
contents: read # to fetch code (actions/checkout)

name: Unit tests / PHP-${{ matrix.php }}
runs-on: ubuntu-22.04

strategy:
matrix:
php:
- '8.2'
- '8.3'
- '8.4'

services:
mariadb:
image: mariadb:10.6
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_USER: phalcon
MYSQL_DATABASE: phalcon
MYSQL_PASSWORD: secret

steps:
- uses: actions/checkout@v4

- name: "Setup PHP"
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.EXTENSIONS }}
tools: pecl
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Install development dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
composer-options: "--prefer-dist"

- name: "Setup Tests"
shell: bash
run: |
cp config/.env.ci .env

- name: "Run Unit Tests"
if: always()
run: |
composer test-unit

- name: "Run Migrations"
if: always()
run: |
composer migrate

- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: ./
args: >
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
-Dsonar.sources=src/
-Dsonar.exclusions=vendor/**,cv/**,tests/**
-Dsonar.sourceEncoding=UTF-8
-Dsonar.language=php
-Dsonar.tests=tests/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.bash_history
vendor
composer.lock
.env
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0

Under development
49 changes: 49 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Contributing to Phalcon

Phalcon is an open source project and a volunteer effort. Phalcon welcomes contribution from everyone. Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.

Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.

## Contributions

Contributions to Phalcon should be made in the form of GitHub pull requests. Each pull request will be reviewed by a core contributor (someone with permission to merge patches). Feedback can be provided and potentially changes requested or the pull request will be merged. All contributions should
follow this format, even those from core contributors.

## Questions & Support

We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address all of them. Thus we only accept bug reports, new feature requests and pull requests in GitHub. Our great community and contributors are happy to help you though! Please use these community resources for obtaining help.

_Please use the [Documentation](https://phalcon.io/docs) before anything else. You can also use the search feature in our documents to find what you are looking for. If your question is still not answered, there are more options below._

* Questions should go to [GitHub Discussions](https://phalcon.io/discussions)
* Come join the Phalcon [Discord](https://phalcon.io/discord)
* Our social network accounts are:
* [Telegram](https://phalcon.io/telegram)
* [Gab](https://phalcon.io/gab)
* [MeWe](https://phalcon.io/mewe)
* [Twitter](https://phalcon.io/t)
* [Facebook](https://phalcon.io/fb)
* If you still believe that what you found is a bug, please
[open an issue](https://github.com/phalcon/cphalcon/issues/new)

Please report bugs when you've exhausted all of the above options.

## Bug Report Checklist

* Make sure you are using the latest released version of the composer packages.
* If you have found a bug it is important to add relevant reproducibility information to your issue to allow us to reproduce the bug and fix it quicker. Add a script, small program or repository providing the necessary code to make everyone reproduce the issue reported easily.
* Be sure that information such as OS, Phalcon version and PHP version are part of the bug report

## Pull Request Checklist

* Don't submit your pull requests to the `master` branch. Branch from the required branch and, if needed, rebase to the proper branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes
* Don't put submodule updates in your pull request unless they are to landed commits
* Add tests relevant to the fixed bug or new feature. Test classes should follow the [PSR-12 coding style guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-coding-style-guide.md).

## Requesting Features

If you have a change or new feature in mind, please fill out an NFR on GitHub.


Thanks!
Phalcon Team
Empty file added bin/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"analyze": "phpstan analyse -c phpstan.neon --memory-limit=512M",
"cs": "vendor/bin/phpcs --standard=phpcs.xml",
"cs-fix": "vendor/bin/phpcbf --standard=phpcs.xml",
"migrate": "vendor/bin/phinx migrate",
"test-unit": "vendor/bin/phpunit -c phpunit.xml.dist --display-all-issues"
}
}
16 changes: 16 additions & 0 deletions config/.env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PROJECT_NAME="rest"

# Mariadb
DB_HOST="127.0.0.1"
DB_PORT=3306
DB_USER="root"
DB_PASS="secret"
DB_NAME="phalcon"
DB_CHARSET="utf8"

# Redis
DATA_REDIS_HOST="app-cache"
DATA_REDIS_PORT=6379
DATA_REDIS_NAME="0"

XDEBUG_MODE=coverage
16 changes: 16 additions & 0 deletions config/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PROJECT_NAME="rest"

# Mariadb
DB_HOST="app-db"
DB_PORT=3306
DB_USER="root"
DB_PASS="secret"
DB_NAME="phalcon"
DB_CHARSET= "utf8"

# Redis
DATA_REDIS_HOST="app-cache"
DATA_REDIS_PORT=6379
DATA_REDIS_NAME="0"

XDEBUG_MODE=coverage
Empty file added config/.gitkeep
Empty file.
100 changes: 100 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
services:

app-8.2:
build:
dockerfile: ./resources/docker/Dockerfile
args:
PHP_VERSION: 8.2
hostname: rest-api-app-8.2
container_name: "${PROJECT_NAME}-api-8.2"
tty: true
working_dir: /app
volumes:
- ./:/app
depends_on:
- app-db
- app-cache
networks:
- app-network
environment:
- APP_ENV=development
- APP_ENV_ADAPTER=dotenv
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s

app-8.3:
build:
dockerfile: ./resources/docker/Dockerfile
args:
PHP_VERSION: 8.3
hostname: rest-api-app-8.3
container_name: "${PROJECT_NAME}-api-8.3"
tty: true
working_dir: /app
volumes:
- ./:/app
depends_on:
- app-db
- app-cache
networks:
- app-network
environment:
- APP_ENV=development
- APP_ENV_ADAPTER=dotenv
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s

app-8.4:
build:
dockerfile: ./resources/docker/Dockerfile
args:
PHP_VERSION: 8.4
hostname: rest-api-app-8.4
container_name: "${PROJECT_NAME}-api-8.4"
tty: true
working_dir: /app
volumes:
- ./:/app
depends_on:
- app-db
- app-cache
networks:
- app-network
environment:
- APP_ENV=development
- APP_ENV_ADAPTER=dotenv
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s

app-db:
container_name: "${PROJECT_NAME}-db"
image: mariadb:10.6
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_USER=phalcon
- MYSQL_DATABASE=phalcon
- MYSQL_PASSWORD=secret
networks:
- app-network

app-cache:
container_name: "${PROJECT_NAME}-cache"
image: redis:5-alpine
networks:
- app-network

networks:
app-network:
driver: bridge
Empty file added docs/.gitkeep
Empty file.
35 changes: 35 additions & 0 deletions phinx.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

use Dotenv\Dotenv;

require_once __DIR__ . '/vendor/autoload.php';

// Load environment
$envs = array_merge(getenv(), $_ENV);

Dotenv::createImmutable(__DIR__)->load();

$_ENV = array_merge($envs, $_ENV);

return [
'paths' => [
'migrations' => './resources/db/migrations',
'seeds' => './resources/db/seeds',
],
'environments' => [
'default_migration_table' => "ut_migrations",
'default_environment' => 'development',
'development' => [
'adapter' => $_ENV['DB_ADAPTER'] ?? 'mysql',
'host' => $_ENV['DB_HOST'] ?? '127.0.0.1',
'name' => $_ENV['DB_NAME'] ?? 'phalcon',
'user' => $_ENV['DB_USER'] ?? 'root',
'pass' => $_ENV['DB_PASS'] ?? 'secret',
'port' => $_ENV['DB_PORT'] ?? 3306,
'charset' => $_ENV['DB_CHARSET'] ?? 'utf8',
],
],
'version_order' => 'creation',
];
Loading
Loading