Open webdevilopers opened 5 years ago
Thanks to @radmen I was able to identify the problem. The tests were throwing deprecation notices that would let the process fail. The notices could be hidden by this configuration in phpunit.xml
:
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>
Solution provided here by @BigZ:
Symfony 2:
set :tests_path, fetch(:app_path) + "/../tests"
set :vendor_path, fetch(:app_path) + "/../vendor"
namespace :deploy do
before :starting, "tasks:run_tests"
end
namespace :tasks do
task :run_tests do
run_locally do
execute :php, fetch(:vendor_path) + "/phpunit/phpunit/phpunit --configuration " + fetch(:app_path) + "/phpunit.xml " + fetch(:tests_path)
end
end
end
If you are using the PHPUnit Bridge and Symfony >= 3:
set :tests_path, "tests"
set :vendor_path, "vendor"
namespace :deploy do
before :starting, "tasks:run_tests"
end
namespace :tasks do
task :run_tests do
run_locally do
execute :php, fetch(:vendor_path) + "/bin/simple-phpunit --configuration phpunit.xml " + fetch(:tests_path)
end
end
end
Anybody interested in adding this task to this repo?
Hi @webdevilopers
I think the tests should be run in a Continuous Integration, not in capistrano.
just make test && make deploy if you really want to do it on your machine because this task is heavily related to the fact that you use phpunit and a specific configuration file.
PS: if you want to force weak deprecation notice, you can set it per-command, like SYMFONY_DEPRECATIONS_HELPER=weak php vendor/bin/phpunit
SYMFONY_DEPRECATIONS_HELPER=weak php vendor/bin/phpunit
Thanks for the hint @BigZ !
Maybe it is an interesting feature to run unit tests either locally before deploying or on production after deploy.
I'm no ruby expert so this was my first approach:
Based on this question:
But I'm not sure how to get a return value to inform cap to continue. Currently this solution will stop deployment even when tests pass.
Trace: