Commit graph

117 commits

Author SHA1 Message Date
Adnan Hajdarević
6774079a57 Merge pull request #46 from moorereason/testing
Add testing framework for main webhook app
2015-10-31 09:29:34 +01:00
Adnan Hajdarević
334fbc814c Merge pull request #45 from moorereason/signals
Refactor signal handling and Windows support
2015-10-31 09:29:22 +01:00
Cameron Moore
802f3f572c Add testing framework for main webhook app
This commit adds a testing framework modeled after the godoc tests. It builds
webhook in a temporary directory, runs it with the supplied `hooks_test.json`
configuration, and then tests different payloads.  I use `/bin/echo` for the
test executable, so I've added build tags to exclude Windows.

Three minor (I hope) changes in functionality:

- I ended up moving everything from `init()` to `main()` because `init()` was
  firing while trying to build the tests, and it was dying since `hooks.json`
  didn't exist. I'm still not 100% sure `init()` was firing, but I didn't see
  any real need for anything to be in `init()` in the first place.

- make sure logger is using `os.Stderr`

- don't send `http.StatusBadRequest` when the Hook rules don't match.  "Bad
  Request" is used to identify malformed requests.  The request was properly
  formed and processed, so I think we should send back `http.StatusOK`.  For
  example, if I setup a webhook rule to only execute when commits are made to
  the `master` branch, we shouldn't send back `http.StatusBadRequest` when we
  ingest a payload for the `development` branch.

The test payloads are pretty verbose and could probably be shortened, but I kind
of like having an example payload for each service.  We can pare them down if we
want to do more focused, minimalist testing.
2015-10-30 21:32:48 -05:00
Adnan Hajdarević
6da00561bf Merge pull request #44 from timhughes/master
Pull request into development instead of master
2015-10-30 17:25:58 +01:00
Tim Hughes
d1b4ef767a Add travis test status badge to README.md 2015-10-30 01:17:06 +00:00
Tim Hughes
64b3256408 enable unit tests and add in init script and example hooks.json file to rpmspec 2015-10-30 00:49:38 +00:00
Tim Hughes
bfe4c148a5 add in make target 2015-10-29 21:58:29 +00:00
Tim Hughes
033764601d typo in travis.yml 2015-10-29 21:51:43 +00:00
Tim Hughes
8173f4a346 add travis.yml 2015-10-29 21:50:46 +00:00
Tim Hughes
ffd05a2101 adding a rpm spec file and init script 2015-10-29 21:43:13 +00:00
Adnan Hajdarević
fea31474bd Merge pull request #41 from moorereason/devsidefx
Remove logging side-effects from hook package
2015-10-29 19:05:15 +01:00
Cameron Moore
1c319a7a08 Refactor signal handling and Windows support
This commit drops webhook_windows.go in favor of simply pulling out the
signal handling code to separate files.
2015-10-29 11:17:15 -05:00
Cameron Moore
2947e5e0e8 Remove logging side-effects from hook package
The hook package should be self-contained and return errors instead of
relying on the log subsystem.  This commit removes the logging
side-effects from the hook package.  Custom errors are returned that
should be transparent to the caller -- they can just treat them as
simple errors if they don't care to check the type.
2015-10-29 11:00:30 -05:00
Adnan Hajdarević
409b441c31 Merge pull request #40 from adnanh/development
Add Dockerfile & Makefile
2015-10-28 11:52:31 +01:00
Adnan Hajdarević
93505b4132 Merge pull request #39 from almir/development
- create dockerfile and makefile for building docker image
2015-10-28 11:34:11 +01:00
almir
c350784507 - create dockerfile and makefile for building docker image 2015-10-28 10:54:36 +01:00
Adnan Hajdarević
7b8cc04992 Merge pull request #38 from adnanh/development
Fail if webhook cannot load hooks when not running in verbose mode (unless -nopanic flag is used)
2015-10-04 17:08:51 +02:00
Adnan Hajdarevic
d4810bebdb Merge branch 'master' into development 2015-10-04 17:06:34 +02:00
Adnan Hajdarevic
272546bb2b add nopanic flag 2015-10-04 17:06:17 +02:00
Adnan Hajdarević
2afc6e6a54 Merge pull request #35 from ciarand/patch-1
Fix reverse build tag in webhook_windows.go
2015-07-23 17:08:10 +02:00
Ciaran Downey
a5c92b88a6 Fix reverse build tag in webhook_windows.go
9c545a745f accidentally started negating
the build constraint in webhook_windows.go. This reverses that, fixing
the Windows build.
2015-07-22 14:58:54 -07:00
Adnan Hajdarević
d12bbf4036 Update README.md 2015-06-10 09:33:15 +02:00
Adnan Hajdarević
d91b34a316 Update README.md 2015-06-10 09:32:07 +02:00
Adnan Hajdarević
005e723b23 Merge pull request #34 from adnanh/development
Development
2015-06-06 14:28:54 +02:00
Adnan Hajdarevic
9977fa8c61 refactor 2015-06-06 14:28:00 +02:00
Adnan Hajdarevic
cbe2440cda add entire query and headers as well 2015-06-06 14:25:32 +02:00
Adnan Hajdarevic
9c545a745f return command output, pass whole payload as json to the command 2015-06-06 14:19:52 +02:00
Adnan Hajdarević
263c75b1b5 Update README.md 2015-06-05 11:21:52 +02:00
Adnan Hajdarević
83cbffd37c Merge pull request #33 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-06-05 11:21:06 +02:00
The Gitter Badger
b310b79fb8 Added Gitter badge 2015-06-05 09:15:27 +00:00
Adnan Hajdarevic
f1ebc440a4 match all hooks with the same id 2015-05-27 09:16:26 +02:00
Adnan Hajdarević
10732bd57b Merge pull request #30 from adnanh/development
separated windows and other platforms to different files, removed sig…
2015-05-16 13:36:20 +02:00
Adnan Hajdarevic
4350685330 separated windows and other platforms to different files, removed signal watcher from windows build file so webhook can actually compile on windows, added string as a source, so you can pass static strings to your scripts without having to wrap them around with other scripts 2015-05-16 13:32:21 +02:00
Adnan Hajdarević
6053f48b23 Merge pull request #28 from kevinlebrun/fix-for-osx-signals
Fix for OS X USR1 signal
2015-04-06 16:07:39 +02:00
Kevin Le Brun
6cd8258651 Fix for OS X USR1 signal
It seems that signals code for Linux and OS X (FreeBSD) are different. I
rely on `syscall.SIGUSR1` which should be cross-compatible.

Tested with `kill -usr1 <pid>` on OS X 10.10
2015-04-05 23:21:40 +02:00
Adnan Hajdarević
fb71ea0fae Update README.md 2015-03-31 22:24:27 +02:00
Adnan Hajdarević
aeacb6dac7 Merge pull request #24 from adnanh/development
added hook reload on USR1 signal
2015-03-31 22:14:47 +02:00
Adnan Hajdarevic
1039151a16 added hook reload on USR1 signal 2015-03-31 22:10:35 +02:00
Adnan Hajdarević
db928228c8 bumping up the minor version 2015-03-30 15:33:15 +02:00
Adnan Hajdarević
6896a34aab Merge pull request #21 from kevinlebrun/master
Allow charset to be defined in Content-Type header
2015-03-30 00:22:29 +02:00
Kevin Le Brun
5f853d8aba Allow charset to be defined in Content-Type header
The payload couldn't be parsed when charset was present in the
`Content-Type` header. The content type should begin with the MIME type
so we now check if the content type starts with `application/json` or
`application/x-www-form-urlencoded`.

This closes #20
2015-03-29 20:01:56 +02:00
Adnan Hajdarević
12c48f87cb Merge pull request #19 from moorereason/test-json
Add tests for ParseJSONParameters
2015-03-21 10:28:20 +01:00
Adnan Hajdarević
acf38c3210 Merge pull request #18 from moorereason/extract-tests
Add new tests for ExtractParameter
2015-03-21 10:26:36 +01:00
Cameron Moore
d3f368cb8f Add tests for ParseJSONParameters
This commit adds 100% coverage to Hook.ParaseJSONParameters.
2015-03-20 23:22:30 -05:00
Cameron Moore
943bc258f7 Add new tests for ExtractParameter
This commit regains 100% coverage for ExtractParameter after changes
from commit 688483d.
2015-03-20 22:43:39 -05:00
Adnan Hajdarevic
231426da57 removed leftover debug trace, fixed a panic bug 2015-03-21 01:26:04 +01:00
Adnan Hajdarević
baec1cadc5 Merge pull request #17 from adnanh/json-parameters
added parse-parameters-as-json property to hooks, fixed some bugs in old...
2015-03-21 01:18:44 +01:00
Adnan Hajdarevic
688483d6d1 added parse-parameters-as-json property to hooks, fixed some bugs in old code 2015-03-21 01:10:17 +01:00
Adnan Hajdarević
bddb523b67 Merge pull request #16 from moorereason/fix-notrule
Fix infinite loop in NotRule.Evaluate
2015-03-20 23:37:49 +01:00
Adnan Hajdarević
b8807ed434 Merge pull request #15 from moorereason/fix-negindex
Only support unsigned ints for slice indexes
2015-03-20 23:31:42 +01:00