1

I would like to automate testing and merging / deploying my application.

Fist I do testing via Chimp and ESLint:

$ chimp --ddp=http://localhost:3000 --mocha --path=tests --browser=phantomjs

and

$ eslint ./

If these tests are passing completly, I would like to merge the development branch to the master branch:

git checkout master
git merge development

Is it possible to automate these steps? So if any test is failing, no merge should be done.

user3142695
  • 15,844
  • 47
  • 176
  • 332

1 Answers1

0

You could declare those steps in a script, testing the exit status for each command before processing the other commands.

For instance, you can have a pre-commit hook calling your javascript commands. See "Commit in git only if tests pass"


But this kind of sequence belongs to a Continuous Integration tool (Travis, CircleCI, CodeShip and of course Jenkins).

You can there define each command in its own build step: if one fail, the other steps won't execute.

.git/hooks/pre-commit:

#!/bin/sh
tests.sh || exit 1

With tests.sh a script in your $PATH, returning an exit status 0 if everything when well.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • But isn't for example *Jenkins* something which is working on the server? And I want to do this local? After testing and merging, I would push the data to the server. Or doesn't this make any sense? – user3142695 Jul 30 '16 at 07:18
  • *You could declare those steps in a script*: What kind of script? And how do I get the status of the test into this script? – user3142695 Jul 30 '16 at 07:19
  • @user3142695 You can use a Jenkins server locally: `java -war jenkins.war`: done. – VonC Jul 30 '16 at 07:21
  • I do get this error: `Unrecognized option: -war Error: Could not create the Java Virtual Machine.` – user3142695 Jul 30 '16 at 07:23
  • @user3142695 what java -version returns? – VonC Jul 30 '16 at 07:27
  • it returns `1.8.0_102` – user3142695 Jul 30 '16 at 07:28
  • @user3142695 I mean the full complete exact output? Is it a jdk or a jre? What OS are you on? – VonC Jul 30 '16 at 07:30
  • @user3142695 Sorry, I just re-read https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins: `java -jar jenkins.jar` – VonC Jul 30 '16 at 07:31
  • @user3142695 Then https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project – VonC Jul 30 '16 at 07:32
  • @user3142695 Note: I have edited the answer with a simpler approach: a pre-commit hook. – VonC Jul 30 '16 at 07:32