-
Notifications
You must be signed in to change notification settings - Fork 127
switch to docker image instead of installing Mautic locally #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mollux
wants to merge
40
commits into
mautic:main
Choose a base branch
from
mollux:better-testing-method
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
17f7f85
switch to docker image instead of installing Mautic locally
mollux f19ec72
correct db name
mollux 9d89fa7
other creds
mollux a8238c5
no empty password allowed
mollux 7ec4294
correct copy
mollux dfb16c9
give mautic a name
mollux 4f76fc3
does this work?
mollux 80538a1
no tty
mollux 951de60
first step
mollux 950d6fd
we need the source obviously
mollux d47a158
no dev env
mollux a5753ee
more params
mollux 1a8a07f
more config
mollux b4949db
reshuffle
mollux 5d6cc2a
correct filename
mollux 90ef07c
dollars
mollux 585ad80
faster tests? + logs
mollux bb1b684
install after changing algo
mollux cf2b7a1
logs
mollux 29cec55
permissions
mollux e26654c
faster?
mollux 13fa1bf
debug user password
mollux 4cffa6f
clear cache before
mollux 27f8e89
why are they failing?
mollux e51c738
let's see if non-parallel works
mollux bb1dd6a
uncomment
mollux 63b44ac
switch to supported version
mollux f7ea514
let's try multiple images
mollux a2302fd
quoting
mollux b8d9198
correct images and path
mollux 014a22f
correct paths
mollux 31dea6c
we need mysql binary
mollux 780ad62
new log dir
mollux cca1f49
workaround for failing tests
mollux 64a43bc
get logs from correct dir
mollux f91d97e
better naming
mollux d17ded9
bump version
mollux 3b6a893
cleanup
mollux 95a1d02
test API on both 7.4 and 8.0
mollux 4945f72
let's test something
mollux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
apt-get update && apt-get install default-mysql-client -y | ||
|
||
cd /var/www | ||
|
||
cat << 'EOF' > docroot/app/config/parameters_local.php | ||
<?php | ||
/** | ||
* Parameter overrides for GitHub Actions. | ||
*/ | ||
$parameters = [ | ||
'api_enabled' => true, | ||
'api_enable_basic_auth' => true, | ||
]; | ||
EOF | ||
|
||
cat << 'EOF2' > docroot/app/config/security_local.php | ||
<?php | ||
|
||
$this->import('security.php'); | ||
|
||
// Support HTTP basic auth for test logins | ||
$container->loadFromExtension('security', | ||
[ | ||
'firewalls' => [ | ||
'main' => [ | ||
// Support HTTP basic auth for test logins | ||
'http_basic' => true, | ||
], | ||
], | ||
'encoders' => [ | ||
'Symfony\Component\Security\Core\User\User' => [ | ||
'algorithm' => 'md5', | ||
'encode_as_base64' => false, | ||
'iterations' => 0, | ||
], | ||
'Mautic\UserBundle\Entity\User' => [ | ||
'algorithm' => 'md5', | ||
'encode_as_base64' => false, | ||
'iterations' => 0, | ||
], | ||
], | ||
] | ||
); | ||
EOF2 | ||
|
||
php bin/console cache:clear --no-warmup | ||
|
||
php bin/console mautic:install http://localhost/ --force --mailer_from_name="GitHub Actions" --mailer_from_email="github-actions@mautic.org" --mailer_transport="smtp" --mailer_host="mailhog" --mailer_port="1025" --admin_username=admin --admin_password=mautic --admin_email="bla@bla.be" | ||
|
||
mysql -uroot -proot -hmysql mautictest -e "INSERT INTO plugin_integration_settings (plugin_id, name, is_published, supported_features, api_keys, feature_settings) VALUES (NULL, 'Twilio', 1, 'a:0:{}', 'a:2:{s:8:\"username\";s:169:\"bzFmNlIydWRSZXlIN2lQVkdpanJ4aTQ2NUh6RVdDbHlLRVhsWGZ4b0kyZVNxLzYrQ1J6V1RvMnlhVEp0c245TEp6eStQekx5ZVhLWjB1YVdoR3RnR2dHQ3k1emVVdGt5NzZKUmtjUnJ3c1E9|L8tbZRIYhwatT7Mq+HAdYA==\";s:8:\"password\";s:169:\"T2d2cFpXQWE5YVZnNFFianJSYURRYUtGRHBNZGZjM1VETXg2Wm5Va3NheW43MjVWUlJhTVlCL2pYMDBpbElONStiVVBNbEM3M3BaeGJMNkFKNUFEN1pTNldSRjc4bUM4SDh1SE9OY1k5MTg9|TeuSvfx4XSUOvp0O7T49Cg==\";}', 'a:4:{s:20:\"sending_phone_number\";N;s:22:\"disable_trackable_urls\";i:0;s:16:\"frequency_number\";N;s:14:\"frequency_time\";N;}');" | ||
php bin/console mautic:plugins:reload | ||
|
||
cp -rp docroot/app/assets/images/* docroot/media/images/ | ||
|
||
chown -R www-data:www-data /var/www |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,116 +18,93 @@ on: | |||||
jobs: | ||||||
phpunit: | ||||||
runs-on: ubuntu-20.04 | ||||||
name: PHPUnit tests | ||||||
name: PHPUnit ${{ matrix.php_version }} ${{ matrix.mautic_version }} | ||||||
strategy: | ||||||
matrix: | ||||||
mautic_version: ["5.x-dev", "4.x-dev"] | ||||||
php_version: ["7.4", "8.0", "8.1"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per #286 PHP 7 is no longer supported.
Suggested change
|
||||||
|
||||||
services: | ||||||
mysql: | ||||||
image: mysql:5.7 | ||||||
env: | ||||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||||||
MYSQL_ROOT_PASSWORD: root | ||||||
MYSQL_DATABASE: mautictest | ||||||
ports: | ||||||
- 3306 | ||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||||||
- 3306:3306 | ||||||
options: >- | ||||||
--shm-size=2gb | ||||||
--name=mysql | ||||||
--tmpfs=/var/lib/mysql | ||||||
--health-cmd="mysqladmin ping" | ||||||
--health-interval=10s | ||||||
--health-timeout=5s | ||||||
--health-retries=3 | ||||||
|
||||||
mailhog: | ||||||
image: mailhog/mailhog:latest | ||||||
ports: | ||||||
- 1025:1025 | ||||||
|
||||||
redis: | ||||||
image: redis:6 | ||||||
ports: | ||||||
- 6379:6379 | ||||||
|
||||||
mautic: | ||||||
image: ghcr.io/mollux/docker-mautic:${{ matrix.mautic_version }} | ||||||
env: | ||||||
MAUTIC_DB_HOST: mysql | ||||||
MAUTIC_DB_USER: root | ||||||
MAUTIC_DB_PASSWORD: root | ||||||
MAUTIC_DB_NAME: mautictest | ||||||
MAUTIC_RUN_CRON_JOBS: "false" | ||||||
ports: | ||||||
- 80:80 | ||||||
options: | ||||||
--health-cmd="curl --fail http://localhost || exit 1" | ||||||
--health-interval=10s | ||||||
--health-timeout=5s | ||||||
--health-retries=10 | ||||||
--name=mautic | ||||||
steps: | ||||||
- uses: actions/checkout@v3 | ||||||
|
||||||
- name: Prepare Mautic installation | ||||||
run: | | ||||||
sudo docker cp .github/ci-files/prepare_mautic.sh mautic:/tmp/prepare_mautic.sh | ||||||
sudo docker exec mautic chmod 755 /tmp/prepare_mautic.sh | ||||||
sudo docker exec mautic /tmp/prepare_mautic.sh | ||||||
|
||||||
- name: Copy our API library config into the tests/ folder | ||||||
run: cp -a ./.github/ci-files/local.config.php tests/local.config.php | ||||||
|
||||||
- name: Setup PHP, with composer and extensions | ||||||
uses: shivammathur/setup-php@v2 | ||||||
with: | ||||||
php-version: 8.0 | ||||||
ini-values: session.save_handler=redis, session.save_path="tcp://127.0.0.1:6379" | ||||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql | ||||||
php-version: ${{ matrix.php_version }} | ||||||
coverage: pcov | ||||||
|
||||||
- name: Set SYMFONY_ENV to test | ||||||
run: echo "SYMFONY_ENV=test" >> $GITHUB_ENV | ||||||
|
||||||
- name: Install Apache | ||||||
# We need the sed command at the bottom to set the PHP session save path to a directory that's writable for PHP | ||||||
# NOTE: update the PHP version below as well if you're updating PHP! | ||||||
run: | | ||||||
sudo add-apt-repository ppa:ondrej/php -y | ||||||
sudo add-apt-repository ppa:ondrej/apache2 -y | ||||||
sudo apt-get install apache2 libapache2-mod-php8.0 | ||||||
sudo a2enmod rewrite | ||||||
sudo sed -i 's,^session.save_handler =.*$,session.save_handler = redis,' /etc/php/8.0/apache2/php.ini | ||||||
sudo sed -i 's,^;session.save_path =.*$,session.save_path = "tcp://127.0.0.1:6379",' /etc/php/8.0/apache2/php.ini | ||||||
sudo service apache2 restart | ||||||
cat /etc/php/8.0/apache2/php.ini | grep session | ||||||
|
||||||
- name: Install dependencies | ||||||
run: | | ||||||
composer validate --strict | ||||||
composer install --prefer-dist --no-progress | ||||||
|
||||||
- name: Clone Mautic main branch or specific PR from GitHub | ||||||
run: | | ||||||
gh repo clone mautic/mautic -- --single-branch --depth 1 | ||||||
if [[ "${{ github.event.inputs.pr }}" != "" ]]; then | ||||||
pushd mautic | ||||||
gh pr checkout ${{ github.event.inputs.pr }} | ||||||
popd | ||||||
fi | ||||||
env: | ||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||||||
|
||||||
- name: Move files to web root | ||||||
run: | | ||||||
shopt -s dotglob | ||||||
sudo chmod -R 777 /var/www/html | ||||||
sudo chown -R www-data:www-data /var/www/html | ||||||
rm -rf /var/www/html/* | ||||||
mv $GITHUB_WORKSPACE/mautic/* /var/www/html/ | ||||||
|
||||||
- name: Install Mautic | ||||||
env: | ||||||
DB_PORT: ${{ job.services.mysql.ports[3306] }} | ||||||
run: | | ||||||
composer install --prefer-dist --no-progress | ||||||
cp $GITHUB_WORKSPACE/.github/ci-files/local.php ./app/config/local.php | ||||||
php bin/console mautic:install http://localhost/ \ | ||||||
--force --mailer_from_name="GitHub Actions" --mailer_from_email="github-actions@mautic.org" \ | ||||||
--mailer_transport="smtp" --mailer_host="localhost" --mailer_port="1025" --env=dev | ||||||
php bin/console cache:warmup --no-interaction --env=dev | ||||||
working-directory: /var/www/html/ | ||||||
|
||||||
# Enable Twilio plugin with random credentials (needed for MessagesTest to function, doesn't actually contact Twilio API). | ||||||
- name: Enable Twilio plugin | ||||||
run: | | ||||||
mysql -uroot -P${{ job.services.mysql.ports[3306] }} -h127.0.0.1 -e "USE mautictest; INSERT INTO plugin_integration_settings (plugin_id, name, is_published, supported_features, api_keys, feature_settings) VALUES (NULL, 'Twilio', 1, 'a:0:{}', 'a:2:{s:8:\"username\";s:169:\"bzFmNlIydWRSZXlIN2lQVkdpanJ4aTQ2NUh6RVdDbHlLRVhsWGZ4b0kyZVNxLzYrQ1J6V1RvMnlhVEp0c245TEp6eStQekx5ZVhLWjB1YVdoR3RnR2dHQ3k1emVVdGt5NzZKUmtjUnJ3c1E9|L8tbZRIYhwatT7Mq+HAdYA==\";s:8:\"password\";s:169:\"T2d2cFpXQWE5YVZnNFFianJSYURRYUtGRHBNZGZjM1VETXg2Wm5Va3NheW43MjVWUlJhTVlCL2pYMDBpbElONStiVVBNbEM3M3BaeGJMNkFKNUFEN1pTNldSRjc4bUM4SDh1SE9OY1k5MTg9|TeuSvfx4XSUOvp0O7T49Cg==\";}', 'a:4:{s:20:\"sending_phone_number\";N;s:22:\"disable_trackable_urls\";i:0;s:16:\"frequency_number\";N;s:14:\"frequency_time\";N;}');" | ||||||
php bin/console mautic:plugins:reload --env=dev | ||||||
working-directory: /var/www/html | ||||||
|
||||||
- name: Set correct ownership so Apache can access the files | ||||||
run: sudo chown -R www-data:www-data /var/www/html | ||||||
|
||||||
- name: Run tests | ||||||
run: vendor/bin/paratest -p 3 --coverage-clover coverage.xml | ||||||
run: vendor/bin/phpunit --coverage-clover coverage.xml | ||||||
|
||||||
- name: Upload code coverage | ||||||
run: bash <(curl -s https://codecov.io/bash) | ||||||
|
||||||
|
||||||
- name: gather logs | ||||||
if: always() | ||||||
run: | | ||||||
sudo docker cp mautic:/var/www/docroot/var/logs/ /tmp/logs | ||||||
|
||||||
- name: Upload logs as artifacts | ||||||
uses: actions/upload-artifact@v2 | ||||||
uses: actions/upload-artifact@v3 | ||||||
if: always() | ||||||
with: | ||||||
name: mautic-logs | ||||||
path: /var/www/html/var/logs/ | ||||||
name: mautic-logs-${{ matrix.mautic_version }} | ||||||
path: /tmp/logs/ | ||||||
|
||||||
- name: Slack Notification if tests fail | ||||||
uses: rtCamp/action-slack-notify@v2 | ||||||
|
@@ -139,15 +116,17 @@ jobs: | |||||
cs: | ||||||
runs-on: ubuntu-20.04 | ||||||
name: CS tests | ||||||
strategy: | ||||||
matrix: | ||||||
php_version: ["7.4", "8.0"] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem.
Suggested change
|
||||||
|
||||||
steps: | ||||||
- uses: actions/checkout@v3 | ||||||
|
||||||
- name: Setup PHP, with composer and extensions | ||||||
uses: shivammathur/setup-php@v2 | ||||||
with: | ||||||
php-version: 8.0 | ||||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql | ||||||
php-version: ${{ matrix.php_version }} | ||||||
|
||||||
- name: Install dependencies | ||||||
run: | | ||||||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mollux can you please remove the email values from this command as it will now fail due to mautic/mautic#12216
And set them in the config file directly.