Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit c941ac1

Browse files
committed
Travis test for composer-based Magento installation scenario
1 parent 6ea0898 commit c941ac1

File tree

12 files changed

+194
-48
lines changed

12 files changed

+194
-48
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ dist: xenial
66
stages:
77
- name: "Basic Tests"
88
- name: "Extended Tests"
9-
if: type = cron
9+
if: branch = master
1010
jobs:
1111
include:
1212
- stage: "Basic Tests"
1313
script:
1414
- travis_wait 15 sudo bash ./tests/run-tests-on-travis.sh testNoCustomConfigBasicTest
1515
- stage: "Extended Tests"
1616
script: travis_wait 30 sudo bash ./tests/run-tests-on-travis.sh testCe23WithSampleDataMysqlSearchNoNfs
17-
# - script: travis_wait 30 sudo bash ./tests/run-tests-on-travis.sh anotherTestGoesHere
17+
- script: travis_wait 20 sudo bash ./tests/run-tests-on-travis.sh testCeFromComposerNoNfs
1818

1919
env:
2020
global:
@@ -51,6 +51,7 @@ after_script:
5151
- sudo kubectl logs -l app=magento -c monolith-xdebug
5252
- sudo kubectl logs -l app=magento -c monolith
5353
- sudo kubectl logs -l app=magento -c nginx
54-
- sudo cat /etc/exports
55-
- sudo cat ./tests/logs/*
5654
- sudo cat ./logs/*
55+
- sudo cat ./tests/tmp/test/current-test.log
56+
- sudo cat ./tests/tmp/test/magento2-devbox/log/*
57+
- sudo cat /etc/exports

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.com/magento/magento2-kubernetes-devbox.svg?branch=master)](https://travis-ci.com/magento/magento2-kubernetes-devbox)
44
<!--[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)-->
5-
[![Semver](http://img.shields.io/SemVer/2.0.0.png?color=blue)](http://semver.org/spec/v2.0.0.html)
5+
<!--[![Semver](http://img.shields.io/SemVer/2.0.0.png?color=blue)](http://semver.org/spec/v2.0.0.html)-->
66
<!--[![Latest GitHub release](docs/images/release_badge.png)](https://github.com/paliarush/magento2-vagrant-for-developers/releases/latest)-->
77

88
* [What You get](#what-you-get)
@@ -109,19 +109,18 @@ The software listed below should be available in [PATH](https://en.wikipedia.org
109109
cd magento2-devbox
110110
111111
# NFS configuration is needed just once for each project, it will prompt for your password to make changes on the host
112+
112113
bash scripts/host/configure_nfs_exports.sh
113114
114115
bash init_project.sh
115116
```
117+
<!--
116118
To initialize project with checkout container,
117119
clone sources to checkout directory and use -e parameter to init_project.sh call.
118120
```
119121
bash init_project.sh -e
120122
```
121-
If you have issues with nfs. To use filesystem mount instead of nfs use -d parameter to init_project.sh call.
122-
```
123-
bash init_project.sh -d
124-
```
123+
-->
125124
126125
1. Use the `magento2-devbox` directory as the project root in PHP Storm (not `magento2-devbox/magento`). This is important, because in this case PHP Storm will be configured automatically by [init_project.sh](init_project.sh).<!-- If NFS files sync is disabled in [config](etc/config.yaml.dist) and ![](docs/images/windows-icon.png)on Windows hosts [verify the deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md).-->
127126
@@ -289,7 +288,7 @@ The following configuration files are used by default:
289288
- [Actually applied Dockerfile for monolith with xDebug and customizations](etc/docker/monolith-with-xdebug/Dockerfile)
290289
- [Kubernetes config for Monolith](etc/helm/templates/magento2-deployment.yaml)
291290
- [Kubernetes Helm variables](etc/helm/values.yaml)
292-
- [Configs for Checkout service](etc/helm/charts/checkout)
291+
<!--- [Configs for Checkout service](etc/helm/charts/checkout)-->
293292
<!--It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes: PHP, Apache, Mysql, Varnish, RabbitMQ.
294293
Do not edit any symlinks using PhpStorm because it may break your installation.
295294
@@ -399,9 +398,13 @@ Note: See [Working with npm](https://www.npmjs.com/package/n#working-with-npm) i
399398
### DevBox tests
400399

401400
The tests are executed on every PR on Travis CI. It is possible to configure the same tests to run on the forked repository.
401+
In order to run composer-based Magento tests for the fork, repo.magento.com credentials must be set to `COMPOSER_AUTH` [environment variable](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings) on Travis CI, the variable value should be:
402+
```
403+
'{"http-basic": {"repo.magento.com": {"username": "<public_key>","password": "<secret_key>"}}}'
404+
```
402405

403-
An extended testsuite is executed nightly on the master branch. On every PR by default only basic smoke tests are executed.
404-
It is possible to execute an extended testsuite on every PR build by commenting out `if: type = cron` in the [.travis.yaml](./.travis.yml)
406+
An extended testsuite by default is executed against the master branch only.
407+
It is possible to execute an extended testsuite on every build by commenting out `if: branch = master` in the [.travis.yaml](./.travis.yml)
405408

406409
The same tests can be run on local using the following command. :warning: only one devbox can be running on the same host at the same time. The tests will destroy existing devbox installation.
407410

etc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
config.yaml
2+
composer/auth.json

etc/composer/auth.json.dist

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"github-oauth": {
3-
},
42
"http-basic": {
53
"repo.magento.com": {
64
"username": "your-magento-repo-public-key",
75
"password": "your-magento-repo-secret-key"
86
}
97
}
10-
}
8+
}

init_project.sh

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,20 @@ function composerCreateProject()
129129
{
130130
if [[ ! -d ${magento_ce_dir} ]]; then
131131
status "Downloading Magento codebase using 'composer create-project'"
132-
bash "${devbox_dir}/scripts/host/composer.sh" create-project ${composer_project_name} "${magento_ce_dir}" --repository-url=${composer_project_url}
133-
134-
# TODO: Workaround for Magento 2.2+ until PHP is upgraded to 7.1 on the guest
135-
cd "${magento_ce_dir}"
136-
composer_dir="${devbox_dir}/scripts/host"
137-
composer_phar="${composer_dir}/composer.phar"
138-
php_executable="$(bash "${devbox_dir}/scripts/host/get_path_to_php.sh")"
139-
project_version="$("${php_executable}" "${composer_phar}" show --self | grep version)"
140-
matching_version_pattern='2.[23].[0-9]+'
141-
if [[ ${project_version} =~ ${matching_version_pattern} ]]; then
142-
status "Composer require zendframework/zend-code:~3.1.0 (needed for Magento 2.2+ only)"
143-
cd "${magento_ce_dir}"
144-
bash "${devbox_dir}/scripts/host/composer.sh" require "zendframework/zend-code:~3.1.0"
145-
fi
132+
bash "${devbox_dir}/scripts/host/m_composer.sh" create-project ${composer_project_name} "${magento_ce_dir}" --repository-url=${composer_project_url}
133+
134+
# # TODO: Workaround for Magento 2.2+ until PHP is upgraded to 7.1 on the guest
135+
# cd "${magento_ce_dir}"
136+
# composer_dir="${devbox_dir}/scripts/host"
137+
# composer_phar="${composer_dir}/composer.phar"
138+
# php_executable="$(bash "${devbox_dir}/scripts/host/get_path_to_php.sh")"
139+
# project_version="$("${php_executable}" "${composer_phar}" show --self | grep version)"
140+
# matching_version_pattern='2.[23].[0-9]+'
141+
# if [[ ${project_version} =~ ${matching_version_pattern} ]]; then
142+
# status "Composer require zendframework/zend-code:~3.1.0 (needed for Magento 2.2+ only)"
143+
# cd "${magento_ce_dir}"
144+
# bash "${devbox_dir}/scripts/host/m_composer.sh" require "zendframework/zend-code:~3.1.0"
145+
# fi
146146
fi
147147
}
148148

@@ -203,17 +203,6 @@ if [[ ${force_project_cleaning} -eq 1 ]]; then
203203
fi
204204
fi
205205

206-
if [[ ! -d ${magento_ce_dir} ]]; then
207-
if [[ "${checkout_source_from}" == "composer" ]]; then
208-
composerCreateProject
209-
elif [[ "${checkout_source_from}" == "git" ]]; then
210-
checkoutSourceCodeFromGit
211-
else
212-
error "Value specified for 'checkout_source_from' is invalid. Supported options: composer OR git"
213-
exit 1
214-
fi
215-
fi
216-
217206
status "Initializing dev box"
218207
cd "${devbox_dir}"
219208

@@ -265,6 +254,17 @@ else
265254
bash "${devbox_dir}/scripts/host/k_rebuild_environment.sh"
266255
fi
267256

257+
if [[ ! -d ${magento_ce_dir} ]]; then
258+
if [[ "${checkout_source_from}" == "composer" ]]; then
259+
composerCreateProject
260+
elif [[ "${checkout_source_from}" == "git" ]]; then
261+
checkoutSourceCodeFromGit
262+
else
263+
error "Value specified for 'checkout_source_from' is invalid. Supported options: composer OR git"
264+
exit 1
265+
fi
266+
fi
267+
268268
monolith_ip="$(minikube service magento2-monolith --url | grep -oE '[0-9][^:]+' | head -1)"
269269
status "Saving Magento monolith container IP to etc/config.yaml (${monolith_ip})"
270270
sed -i.back "s|ip_address: \".*\"|ip_address: \"${monolith_ip}\"|g" "${config_path}"

scripts/guest/composer.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ composer_auth_json="${devbox_dir}/etc/composer/auth.json"
1414
# commented out due to composer conflicts
1515
# ${php_executable} "${composer_phar}" global require "hirak/prestissimo:^0.3"
1616

17-
cd "${DEVBOX_ROOT}/magento"
1817
if [[ -f ${composer_auth_json} ]]; then
1918
status "Exporting etc/auth.json to environment variable"
2019
export COMPOSER_AUTH="$(cat "${composer_auth_json}")"
2120
fi
2221

22+
if [[ -d "${DEVBOX_ROOT}/magento" ]]; then
23+
cd "${DEVBOX_ROOT}/magento"
24+
fi
25+
2326
status "composer --no-interaction "$@""
2427
composer --no-interaction "$@" 2> >(log) > >(log)
2528

scripts/host/configure_ubuntu_travis.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ sed -i "s|minikube start --cpus=2 --memory=4096|sudo minikube start --cpus=2 --m
1414
sed -i "s|&& eval \$(minikube docker-env) ||g" ./scripts/host/k_rebuild_environment.sh
1515
sed -i "s/use_nfs:\ 1/use_nfs:\ 0/g" ./etc/config.yaml.dist
1616
sed -i "s/nfs_server_ip:\ \"0\.0\.0\.0\"/nfs_server_ip:\ \"$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')\"/g" ./etc/config.yaml.dist
17+
echo "${COMPOSER_AUTH}" > ./etc/composer/auth.json

scripts/host/m_reinstall.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ source "${devbox_dir}/scripts/functions.sh"
66

77
magento_app_code_dir="${devbox_dir}/magento/app/code/Magento"
88

9-
cd "${magento_app_code_dir}"
10-
11-
status "Deleting TestModule directories"
12-
ls | grep "TestModule" | xargs rm -rf
9+
if [[ -d "${magento_app_code_dir}" ]]; then
10+
cd "${magento_app_code_dir}"
11+
status "Deleting TestModule directories"
12+
ls | grep "TestModule" | xargs rm -rf
13+
fi
1314

1415
cd "${devbox_dir}"
1516

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# [To apply changes: init_project.sh -fc] Possible values: git, composer
2+
checkout_source_from: "composer"
3+
4+
composer_project:
5+
# Current section used only if 'checkout_source_from' is set to 'composer'
6+
7+
# [To apply changes: init_project.sh -fc]
8+
# Custom version can be provided by using '={version}' appended to repo name. E.g. name: "magento/project-community-edition=2.2.0". Otherwise, default version is used
9+
name: "magento/project-community-edition"
10+
# Make sure to specify valid keys for this repository in etc/composer/auth.json
11+
url: "https://repo.magento.com"
12+
13+
repository_url:
14+
# Current section used only if 'checkout_source_from' is set to 'git'
15+
16+
# [To apply changes: init_project.sh -fc]
17+
# git@github.com:magento/magento2ce.git OR custom one. Use '::' to specify a specific branch, e.g: git@github.com:magento/magento2.git::2.1
18+
ce: "git@github.com:magento/magento2.git"
19+
# git@github.com:magento/magento2ee.git OR custom one
20+
ee: ""
21+
# can be replaced with custom repository. Use '::' to specify a specific branch, e.g: git@github.com:magento/magento2-sample-data.git::2.1-develop
22+
ce_sample_data: "git@github.com:magento/magento2-sample-data.git"
23+
# git@github.com:magento/magento2-sample-data-ee.git OR custom one
24+
ee_sample_data: ""
25+
26+
guest:
27+
# [To apply changes: init_project.sh -f] NFS will be used for folder synchronization on *nix and OSX hosts by default.
28+
use_nfs: 0
29+
# [To apply changes: init_project.sh -f] The placeholder IP will be replaced with auto-detected value, unless modified manually before execution of "init_project.sh" script.
30+
nfs_server_ip: "0.0.0.0"
31+
# [To apply changes: devbox reload] Default is 2Gb, around 3Gb is necessary to run functional tests.
32+
memory: 2048
33+
# Recommended number of CPUs is 2
34+
cpus: 1
35+
ip_address: "192.168.10.2"
36+
forwarded_ssh_port: 3000
37+
38+
environment:
39+
# [To apply changes: devbox reload] Valid versions: 5.6, 7.0, 7.1, 7.2
40+
php_version: "7.0"
41+
composer_prefer_source: 0
42+
# [To apply changes: m-reinstall OR m-varnish enable/disable]
43+
use_varnish: 0
44+
# [To apply changes: m-reinstall] Possible values: mysql, elasticsearch
45+
search_engine: "elasticsearch"
46+
47+
magento:
48+
# [To apply changes: m-switch-to-ce -f OR m-switch-to-ee -f]
49+
install_sample_data: 0
50+
# [To apply changes: m-switch-to-ce -f OR m-switch-to-ee -f] Generate customer (customer@example.com:123123qQ), category, simple product, configurable product after successful Magento installation
51+
generate_basic_data: 1
52+
# [To apply changes: init_project.sh -f]
53+
host_name: "magento2.devbox2"
54+
# [To apply changes: m-reinstall]
55+
admin_frontname: "admin"
56+
language: "en_US"
57+
timezone: "America/Chicago"
58+
currency: "USD"
59+
admin_user: "admin"
60+
admin_password: "123123q"
61+
# [Changes applied on m-clear-cache] Available options: developer, production, default
62+
mode: "developer"
63+
64+
debug:
65+
# [Changes applied on m-clear-cache] Enable template path and block name hints on storefront
66+
magento_storefront: 0
67+
# [Changes applied on m-clear-cache] Enable template path hints in the admin panel
68+
magento_admin: 0
69+
# [Changes applied immediately] Enable detailed output from all scripts provided by current devbox project
70+
devbox_project: 0

tests/include/auth.json.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"github-oauth": {
3-
},
42
"http-basic": {
53
"repo.magento.com": {
64
"username": "",

0 commit comments

Comments
 (0)