jadjoubran / laravel5-angular-material-starter

Get started with Laravel 5.3 and AngularJS (material)
https://laravel-angular.readme.io/
MIT License
1.66k stars 400 forks source link

e2e with Makefile for tests #368

Closed ptondereau closed 8 years ago

ptondereau commented 8 years ago

According to the trello's task; Makefile might be the right solution.

Indeed, here is a PoC:

First create a Makefile file at the root of the repo then I suggest to put this in for your goal:

test: remove-deps
    make simple-install

simple-install:
    composer create-project jadjoubran/laravel5-angular-material-starter --prefer-dist
    cd laravel5-angular-material-starter
    npm install -g gulp bower
    npm install
    bower install
    config-install
    vendor/bin/phpunit
    # Add here JS tests n shits because I don't know how to launch them...

remove-deps:
    rm -rf laravel5-angular-material-starter
    rm -rf vendor
    rm -rf node_modules
    rm -rf bower_components

config-install:
    cp .env.example .env
    mysql -e 'create database laravel;'
    export DB_DATABASE=laravel
    export DB_USERNAME=travis
    export DB_PASSWORD=
    php artisan key:generate
    php artisan jwt:generate
    php artisan migrate

To finish, your .travis.yml should look like this:

language: php

php:
  - 5.5
  - 5.6
  - 7.0
  - hhvm

before_script:
  - travis_retry composer self-update

script: make test

But sure, you can add other Makefile or command to run in it!

Don't know if it's what you want but we never know...

Cheers!

jadjoubran commented 8 years ago

Thanks @ptondereau 😄 I've never used a Makefile with travis before so I will read up on this as soon as possible

jadjoubran commented 8 years ago

btw @chihab, according to @ptondereau this will solve the previous reported issue

chihab commented 8 years ago

Thanks @ptondereau.

I did a lot of Makefiles before back when I was programming C, never came to my mind to use it on a PHP/JS project ! :)

Makefile and .travis config file are a lot similar as they both run commands (in a shell environment) in a particular order.

Before deciding the way to do it, what would be the best trigger for building and testing a stable release using composer create-project ? I would say on each stable release but how could travis know that ? (It probably depends on the way we link composer stable release to the stable tag/branch on our repo).

flick36 commented 8 years ago

Hate to be the one that point this but Makefiles won't work in Windows if they're written in Standard Unix so we will need to be carefull about that, or especify that it's required to have Cygwin installed, so it can runs without troubles, that by the way it's included in Laragon as discused in https://github.com/jadjoubran/laravel5-angular-material-starter/issues/290#issuecomment-230073483

chihab commented 8 years ago

Thanks @flick36, we could use a Makefile here since we're doing doing CI using Travis CI, which can test on Linux and OS X only. However, the commands run in the Makefile should better be platform agnostic since they would normally be run by project users.

Once we'll have a stable branch, the one targeted by composer create-project, each PR/commit on that particular branch would run the "composer create-project" whilst the others branches would run only the the classical travis build steps.

We could do this using TRAVIS_BRANCH environment variable prepared by Travis-ci which gives us the name of the branch in which a PR or a commit has been done. We'd do something like:

install:
 - script: ./scripts/run-install.sh

before_script:
 - mysql -e 'create database laravel;'
 - export DB_DATABASE=laravel
 - export DB_USERNAME=travis
 - export DB_PASSWORD=

script:  
- php artisan migrate --force && gulp && vendor/bin/phpunit

./scripts/run-install.sh

#!/bin/bash  
set -ev
if [ "${TRAVIS_BRANCH}" = "stable" ]; then
    composer install && cd laravel5-angular-material-starter
else
    cp .env.example .env
    php artisan key:generate
    php artisan jwt:generate    
fi
npm install -g gulp bower && npm install && bower install

For that, we'd need a stable branch, @jadjoubran. :)

jadjoubran commented 8 years ago

@chihab would you recommend keeping master for stable and then having new releases in branches?

chihab commented 8 years ago

@jadjoubran yes ! as suggested by this very known post by Vincent Driessen: http://nvie.com/posts/a-successful-git-branching-model/

We consider origin/master to be the main branch where the source code of HEAD always reflects a production-ready state.

The shell script above would be:

if [ "${TRAVIS_BRANCH}" = "master" ]; then
...
fi

:)

jadjoubran commented 8 years ago

@chihab I actually use this for all my projects.. why not use it here as well 😄 Thanks for the recommendation Btw master is stable right now, and I just pushed a develop branch where I'll be working from now on

Would anyone be interested in sending a PR? thanks a lot!

chihab commented 8 years ago

Okay thanks @jadjoubran. I'll send a PR asap.

jadjoubran commented 8 years ago

Closing since this is going to be the last release (supposedly) for Angular 1