From 10019cec74aeebd973892f529fd820f031bf64bc Mon Sep 17 00:00:00 2001 From: Deltik Date: Fri, 16 Feb 2018 07:02:00 -0600 Subject: [PATCH] Better local env config to avoid VCS conflicts Local environments can now be configured with ./config.yml with a sample configuration available in ./config.sample.yml --- .gitignore | 3 ++- README.md | 44 ++++++++++++++++++++++++++++++++------ codeception.yml | 8 +++---- config.sample.yml | 40 ++++++++++++++++++++++++++++++++++ e107 | 2 +- lib/config.php | 18 ++++++++++++++++ secrets.yml | 8 ------- tests/acceptance.suite.yml | 2 +- 8 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 config.sample.yml create mode 100644 lib/config.php delete mode 100644 secrets.yml diff --git a/.gitignore b/.gitignore index ebb2ca13b..09edeb2f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/secrets.yml +/config.yml +/config.local.yml /tests/_output/* /tests/_support/_generated/* composer.lock diff --git a/README.md b/README.md index f1faa4c2c..84e52d74a 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ e107 Test Suites ``` 3. Configure the testing environment. - * **Automatic deployments:** Edit `secrets.yml` to enable deploying to a cPanel account. See the "Automatic Test Deployments » Configuration" section below for details. - * **Manual deployments:** See the "Manual Test Deployments » Configuration" section below for instructions. + * **Automatic deployments:** Copy `config.sample.yml` into a file called `config.yml` and edit `config.yml` enable deploying to a cPanel account. See the "Automatic Test Deployments » Configuration" section below for details. + * **Manual deployments:** See the "Manual Test Deployment » Configuration" section below for instructions. 4. On PHP 5.6 or newer, install dependencies with [Composer](https://getcomposer.org/): ```sh @@ -74,19 +74,28 @@ The test suites can deploy themselves onto a cPanel account automatically. ### Configuration -To set up automatically deployed tests, edit `secrets.yml` in the root folder of this repository and input the following configuration information: +To set up automatically deployed tests, copy the file called `config.sample.yml` in the root folder of this repository to a new file called `config.yml` (or create a new file called `config.yml`), open `config.yml`, and input the following configuration information: ```yaml +# Configure this section for automated test deployments to cPanel cpanel: + + # If set to true, this section takes precedence over the "manual" section. enabled: true + + # cPanel domain without the port number hostname: 'SHARED-HOSTNAME.YOUR-HOSTING-PROVIDER.EXAMPLE' + + # cPanel account username username: 'TEST-ACCOUNT-USER' + + # cPanel account password password: 'TEST-ACCOUNT-PASS' ``` ## Manual Test Deployment -If you do not have a cPanel account that meets the requirements, you can deploy tests manually. +If you do not have a cPanel account that meets the requirements or if you would prefer not to use a cPanel account, you can deploy tests manually. ### Configuration @@ -95,8 +104,31 @@ If you do not have a cPanel account that meets the requirements, you can deploy 3. Create a MySQL or MariaDB user. 4. Grant the MySQL/MariaDB user `ALL PRIVILEGES` on the MySQL/MariaDB database. 5. Put the app on the web server and note its URL. -6. Write the URL to `tests/acceptance.suite.yml` in your copy of this repository where the `url` setting for the `PhpBrowser` module is. -7. Write the database configuration to `codeception.yml` in your copy of this repository under the `\Helper\DelayedDb` module. +6. Copy the file called `config.sample.yml` in the root folder of this repository to a new file called `config.yml` (or create a new file called `config.yml`), open `config.yml`, and input the following configuration information: + ```yaml + # Configure this section for manual test deployments + manual: + + # URL to the app that you deployed manually; needed for acceptance tests + url: 'http://set-this-if-running-acceptance-tests-manually.local' + + # Only MySQL/MariaDB is supported + db: + # Hostname or IP address; use 'localhost' for a local server + host: 'set-this-if-running-tests-manually.local' + + # Port number of the server + port: '3306' + + # Database name; must exist already + dbname: 'e107' + + # Username; must exist already + user: 'root' + + # Password; set to blank string for no password + password: '' + ``` ## Code Coverage diff --git a/codeception.yml b/codeception.yml index 212f4e2f4..337234784 100644 --- a/codeception.yml +++ b/codeception.yml @@ -13,16 +13,16 @@ coverage: - e107/*.php - e107/**/*.php params: - - secrets.yml + - lib/config.php extensions: enabled: - Codeception\Extension\RunFailed modules: enabled: - \Helper\DelayedDb: - dsn: 'mysql:host=set-this-if-running-tests-manually.local;dbname=e107' - user: 'root' - password: '' + dsn: 'mysql:host=%manual.db.host%;port=%manual.db.port%;dbname=%manual.db.dbname%' + user: '%manual.db.user%' + password: '%manual.db.password%' populate: true dump: 'tests/_data/e107_v2.1.8.sample.sql' - \Helper\DeployerFactory: diff --git a/config.sample.yml b/config.sample.yml new file mode 100644 index 000000000..09a4c536f --- /dev/null +++ b/config.sample.yml @@ -0,0 +1,40 @@ +--- + +# Configure this section for automated test deployments to cPanel +cpanel: + + # If set to true, this section takes precedence over the "manual" section. + enabled: false + + # cPanel domain without the port number + hostname: '' + + # cPanel account username + username: '' + + # cPanel account password + password: '' + + +# Configure this section for manual test deployments +manual: + + # URL to the app that you deployed manually; needed for acceptance tests + url: 'http://set-this-if-running-acceptance-tests-manually.local' + + # Only MySQL/MariaDB is supported + db: + # Hostname or IP address; use 'localhost' for a local server + host: 'set-this-if-running-tests-manually.local' + + # Port number of the server + port: '3306' + + # Database name; must exist already + dbname: 'e107' + + # Username; must exist already + user: 'root' + + # Password; set to blank string for no password + password: '' diff --git a/e107 b/e107 index d1a69b0c1..fd7b9e352 160000 --- a/e107 +++ b/e107 @@ -1 +1 @@ -Subproject commit d1a69b0c16ad06c45078b428aa12913df9959966 +Subproject commit fd7b9e352e0b72b797c9b109c47dbe0dd8351fc5 diff --git a/lib/config.php b/lib/config.php new file mode 100644 index 000000000..4966305e3 --- /dev/null +++ b/lib/config.php @@ -0,0 +1,18 @@ +