Skip to content

Commit

Permalink
Merge branch 'features' into pr_8617
Browse files Browse the repository at this point in the history
  • Loading branch information
npracht committed Dec 1, 2020
2 parents 7968682 + a0bff58 commit ebb2415
Show file tree
Hide file tree
Showing 372 changed files with 8,248 additions and 3,350 deletions.
2 changes: 1 addition & 1 deletion .env.dist
Expand Up @@ -2,7 +2,7 @@
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=mautictest
DB_USER=travis
DB_USER=root
DB_PASSWD=
MAUTIC_TABLE_PREFIX=
MAUTIC_ENV=test
Expand Down
7 changes: 2 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,9 +1,6 @@
<!--
Any PR related to Mautic 2 issues is not relavant anymore, please consider upgrading your code to the Mautic 3 series (staging/3.0 branch).
-->
| Q | A
| -------------------------------------- | ---
| Branch? | staging for features or enhancements / 3.0 for bug fixes <!-- see below -->
| Branch? | "features" for features or enhancements / 3.2 for bug fixes <!-- see below -->
| Bug fix? | yes/no
| New feature? | yes/no
| Deprecations? | yes/no
Expand All @@ -18,7 +15,7 @@ Additionally (see https://contribute.mautic.org/contributing-to-mautic/developer
- Always add tests and ensure they pass.
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against the staging branch.
- Features and deprecations must be submitted against the "features" branch.
-->

<!--
Expand Down
17 changes: 17 additions & 0 deletions .github/ci-files/local.php
@@ -0,0 +1,17 @@
<?php
/**
* Parameter overrides for GitHub Actions.
*/
$parameters = [
'api_enabled' => true,
'api_enable_basic_auth' => true,
'db_driver' => 'pdo_mysql',
'db_host' => '127.0.0.1',
'db_table_prefix' => null,
'db_port' => getenv('DB_PORT'),
'db_name' => 'mautictest',
'db_user' => 'root',
'db_password' => '',
'admin_email' => 'github-actions@mautic.org',
'admin_password' => 'GitHubActionsIsAwesome',
];
195 changes: 195 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,195 @@
name: release
on:
push:
tags:
- '*'

jobs:
release:
name: Create draft release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Our build script needs access to all previous tags, so we add fetch-depth: 0
with:
fetch-depth: 0

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql

- name: Get tag name
run: echo "MAUTIC_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Install dependencies
# Force Composer to v1.10
run: |
composer self-update --1
composer global require hirak/prestissimo
composer validate
composer install --prefer-dist --no-progress --no-suggest
- name: Build release files
run: |
php build/package_release.php -b=${{ env.MAUTIC_VERSION }}
echo 'MAUTIC_SHA1_CONTENTS<<EOF' >> $GITHUB_ENV
cat build/packages/build-sha1-all >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: "Prerelease or not?"
run: |
STABILITY=$(jq -r '.stability' app/release_metadata.json)
if [[ "${STABILITY}" == 'stable' ]]; then
PRERELEASE=false
else
PRERELEASE=true
fi
echo "IS_PRERELEASE=${PRERELEASE}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.MAUTIC_VERSION }}
release_name: Mautic Community ${{ env.MAUTIC_VERSION }}
draft: true
prerelease: ${{ env.IS_PRERELEASE }}
body: |
TODO add release notes here!
${{ env.MAUTIC_SHA1_CONTENTS }}
- name: Upload full package ${{ env.MAUTIC_VERSION }}.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/packages/${{ env.MAUTIC_VERSION }}.zip
asset_name: ${{ env.MAUTIC_VERSION }}.zip
asset_content_type: application/zip

- name: Upload update package ${{ env.MAUTIC_VERSION }}-update.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/packages/${{ env.MAUTIC_VERSION }}-update.zip
asset_name: ${{ env.MAUTIC_VERSION }}-update.zip
asset_content_type: application/zip

- name: Store full package artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.MAUTIC_VERSION }}.zip
path: ./build/packages/${{ env.MAUTIC_VERSION }}.zip

- name: Store update package artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.MAUTIC_VERSION }}-update.zip
path: ./build/packages/${{ env.MAUTIC_VERSION }}-update.zip

test-fresh-install:
name: Test a fresh installation
needs: release
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: mautictest
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
# We need this so we can get the local.php override file
- uses: actions/checkout@v2

- name: Get tag name
run: echo "MAUTIC_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql

- name: Download full installation package from previous step
uses: actions/download-artifact@v2
with:
name: ${{ env.MAUTIC_VERSION }}.zip

- name: Install Mautic
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
unzip -q ${{ env.MAUTIC_VERSION }}.zip -d ./mautic-testing
cp ./.github/ci-files/local.php ./mautic-testing/app/config/local.php
cd ./mautic-testing
php bin/console mautic:install http://localhost
test-update-install:
name: Test updating from previous version
needs: release
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: mautictest
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
# We need this so we can get the local.php override file
- uses: actions/checkout@v2

- name: Get tag name and minimum Mautic version
run: |
echo "MAUTIC_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo "MAUTIC_MINIMUM_VERSION=$(jq -r '.minimum_mautic_version' app/release_metadata.json)" >> $GITHUB_ENV
echo "MAUTIC_PHP_MINIMUM_VERSION=$(jq -r '.minimum_php_version' app/release_metadata.json)" >> $GITHUB_ENV
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.MAUTIC_PHP_MINIMUM_VERSION }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql

- name: "Download and install minimum Mautic version: ${{ env.MAUTIC_MINIMUM_VERSION }}"
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: |
curl -sSL https://github.com/mautic/mautic/releases/download/${{ env.MAUTIC_MINIMUM_VERSION }}/${{ env.MAUTIC_MINIMUM_VERSION }}.zip -o ${{ env.MAUTIC_MINIMUM_VERSION }}.zip
unzip -q ${{ env.MAUTIC_MINIMUM_VERSION }}.zip -d ./mautic-testing
cp ./.github/ci-files/local.php ./mautic-testing/app/config/local.php
cd ./mautic-testing
php bin/console mautic:install http://localhost
- name: "Download update package artifact ${{ env.MAUTIC_VERSION }}-update.zip"
uses: actions/download-artifact@v2
with:
name: ${{ env.MAUTIC_VERSION }}-update.zip
path: ./mautic-testing

- name: "Attempt update from ${{ env.MAUTIC_MINIMUM_VERSION }} to ${{ env.MAUTIC_VERSION }}"
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
working-directory: ./mautic-testing
run: |
php bin/console mautic:update:apply --force --update-package=${{ env.MAUTIC_VERSION }}-update.zip
php bin/console mautic:update:apply --finish
115 changes: 115 additions & 0 deletions .github/workflows/tests.yml
@@ -0,0 +1,115 @@
name: Mautic tests and validations

on:
push:
branches:
- staging
- features
- '[0-9]+\.[0-9]+'
pull_request:

jobs:
phpunit:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
db-types: ['mysql', 'mariadb']

name: PHPUnit ${{ matrix.php-versions }} ${{ matrix.db-types }}

services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: mautictest
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

mariadb:
image: mariadb:10.3
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: mautictest
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql
coverage: pcov

- name: Set SYMFONY_ENV to test
run: echo "SYMFONY_ENV=test" >> $GITHUB_ENV

- name: Install dependencies
# Force Composer to v1.10
run: |
composer self-update --1
composer global require hirak/prestissimo
composer validate
composer install --prefer-dist --no-progress --no-suggest
- name: Run tests - database = ${{ matrix.db-types }}
run: |
export DB_PORT_STRING="${{ matrix.db-types }}_port"
export DB_PORT=${!DB_PORT_STRING}
if [[ "${{ matrix.php-versions }}" == "7.4" ]] && [[ "${{ matrix.db-types }}" == "mysql" ]]; then
composer test -- --coverage-clover=coverage.xml
bash <(curl -s https://codecov.io/bash)
else
composer test
fi
env:
mysql_port: ${{ job.services.mysql.ports[3306] }}
mariadb_port: ${{ job.services.mariadb.ports[3306] }}

misc:
runs-on: ubuntu-latest

strategy:
matrix:
commands: ['PHPSTAN', 'Rector', 'CS Fixer']

name: ${{ matrix.commands }}

steps:
- uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql

- name: Install dependencies
# Force Composer to v1.10
run: |
composer self-update --1
composer global require hirak/prestissimo
composer validate
composer install --prefer-dist --no-progress --no-suggest
- name: Run ${{ matrix.commands }}
run: |
if [[ "${{ matrix.commands }}" == "PHPSTAN" ]]; then
composer phpstan
elif [[ "${{ matrix.commands }}" == "Rector" ]]; then
composer rector -- --dry-run --no-progress-bar
elif [[ "${{ matrix.commands }}" == "CS Fixer" ]]; then
bin/php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no --show-progress=dots \
--diff $(git diff -- '*.php' --name-only --diff-filter=ACMRTUXB "HEAD~..HEAD")
else
echo "Invalid command"
exit 1
fi
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.*
!.github
!.gitignore
!.htaccess
!.gitkeep
Expand Down
11 changes: 11 additions & 0 deletions .htaccess
Expand Up @@ -104,6 +104,11 @@
Require all denied
</FilesMatch>

# Deny access via HTTP requests to composer files.
<FilesMatch "^(composer\.json|composer\.lock)$">
Require all denied
</FilesMatch>

# Except those whitelisted bellow.
<FilesMatch "^(index|index_dev|filemanager|upgrade)\.php$">
Require all granted
Expand All @@ -118,6 +123,12 @@
Deny from all
</FilesMatch>

# Deny access via HTTP requests to composer files
<FilesMatch "^(composer\.json|composer\.lock)$">
Order deny,allow
Deny from all
</FilesMatch>

# Except those whitelisted bellow.
<FilesMatch "^(index|index_dev|filemanager|upgrade)\.php$">
Order allow,deny
Expand Down

0 comments on commit ebb2415

Please sign in to comment.